Hide form question
Hello,
Is it possible to hide a form until a certain key combination is pressed? I.E. the form is hidden from view until I press CTRL + SHIFT + A ? If it is possible, can someone please point me into the right direction to getting something like this to work?
Thanks in advance,
David
[310 byte] By [
Uzeal] at [2007-11-11 8:18:39]

# 1 Re: Hide form question
Hello!
I think you might be looking for "GetAsyncKeyState". It allows you to return the state of a certian key.
Here's a small example...
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.WindowState = FormWindowState.Minimized
Me.Hide()
End Sub
Private Sub Form1_KeysDown(ByVal sender As System.Object, ByVal e As KeyEventArgs) Handles MyBase.KeyDown
If CTRLUp() = False Then
If SHIFTUp() = False Then
If e.KeyCode = Keys.A Then
Me.WindowState = FormWindowState.Normal
Me.Show()
End If
End If
End If
End Sub
Private Function CTRLUp() As Boolean
Dim iButtonState As Integer
iButtonState = GetAsyncKeyState(Keys.ControlKey)
CTRLUp = (iButtonState = 0)
End Function
Private Function SHIFTUp() As Boolean
Dim iButtonState As Integer
iButtonState = GetAsyncKeyState(Keys.ShiftKey)
SHIFTUp = (iButtonState = 0)
End Function
There is great stuff all over MSDN & Google about this API if you would like to learn more.
Hope this helps. Happy Programming! :)
Jugg
Jugg at 2007-11-11 17:25:36 >
