|
-
Oct 21st, 2000, 01:28 AM
#1
Thread Starter
Member
I made a game with a 'Hide' button. This hides the game. I'd like the user to be able to press a certain key to either exit or make the game visible again.
Any ideas on how to do this?
Thanks
-
Oct 21st, 2000, 06:46 AM
#2
transcendental analytic
What do you mean by Hide? Is it a picturebox on which your game is on that you hide, or do you minimze it or do you just make the window invisible?
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Oct 21st, 2000, 06:51 AM
#3
Frenzied Member
hmmm try this:
Code:
'When the user presses V it either hides or show the form.
'When pressing C it closes the form
'Place another form in your project (Form2)
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyV Then
Form2.Visible = Not Form2.Visible
End If
If KeyCode = vbKeyC Then Unload Form2
End Sub
Private Sub Form_Load()
KeyPreview = True
Form2.Show , Me
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next
End
End Sub
Hope that helped a bit!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 21st, 2000, 09:04 AM
#4
If the Form doesn't have focus then use GetAsyncKeyState API.
Add the following to a Form with a Timer
Code:
Private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer
Sub UnloadForms
Dim frm As Form
For Each frm In Forms
Unload frm
Set frm = Nothing
Next frm
End Sub
Private Sub Timer1_Timer()
'Show Form1 if C is pressed
If GetAsyncKeyState(vbKeyC) Then Form1.Show
'Unload if Q is pressed
If GetAsyncKeyState(vbKeyQ) Then UnloadForms
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|