How to show a hidden window with a shortcut key
-
Hello, I have added a notify icon component along with a context menu. I'm using these to be able to hide/show the main form of my application. I was wondering is it possible to make the window appear with a shortcut key (e.g. by pressing F11)? The problem is that when the main form is hidden [Me.Hide()] the KeyPress events are not working. I think this is because the form is "out of focus" and therefore can't monitor keypresses. Can you come up with a solution? Maybe with a timer? With best regards, R.I.
-
Hello, I have added a notify icon component along with a context menu. I'm using these to be able to hide/show the main form of my application. I was wondering is it possible to make the window appear with a shortcut key (e.g. by pressing F11)? The problem is that when the main form is hidden [Me.Hide()] the KeyPress events are not working. I think this is because the form is "out of focus" and therefore can't monitor keypresses. Can you come up with a solution? Maybe with a timer? With best regards, R.I.
Here's a small example. I hope it does what you're looking for. Try this using 2 forms. In Form1 add a button control & this code
Private Sub Button1_Click(...) Handles Button1.Click
'open form2 & hide the startup form (form1)
Dim f2 As New Form2
Me.Hide()
f2.Show()
End SubThen in Form2 on the KeyUp event add this code
Public f1 As Form1
Private Sub Form2\_KeyUp(...) Handles Me.KeyUp 'show the main form after pushing F11 If e.KeyCode = Keys.F11 Then f1 = Application.OpenForms.Item("Form1") f1.Visible = True End If End Sub
Hope that helps.
-
Hello, I have added a notify icon component along with a context menu. I'm using these to be able to hide/show the main form of my application. I was wondering is it possible to make the window appear with a shortcut key (e.g. by pressing F11)? The problem is that when the main form is hidden [Me.Hide()] the KeyPress events are not working. I think this is because the form is "out of focus" and therefore can't monitor keypresses. Can you come up with a solution? Maybe with a timer? With best regards, R.I.
Another way to accomplish this is to use a menu control. Make a menu item that uses a shortcut key, and then set that menu item's visible property to false. This will cause it not to show up in the menu, but whenever you press the shortcut key you assigned to it, the on_click event will fire.
-
Hello, I have added a notify icon component along with a context menu. I'm using these to be able to hide/show the main form of my application. I was wondering is it possible to make the window appear with a shortcut key (e.g. by pressing F11)? The problem is that when the main form is hidden [Me.Hide()] the KeyPress events are not working. I think this is because the form is "out of focus" and therefore can't monitor keypresses. Can you come up with a solution? Maybe with a timer? With best regards, R.I.
I would actually advise you to use the mclHotKey component, found here : http://www.codeproject.com/useritems/mclhotkey.asp[^] HTG CodeGuru.com Article Reviewer - > http://www.codeguru.com/forum/member.php?u=56188