Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How to show a hidden window with a shortcut key

How to show a hidden window with a shortcut key

Scheduled Pinned Locked Moved Visual Basic
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    re infecta
    wrote on last edited by
    #1

    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.

    D K H 3 Replies Last reply
    0
    • R re infecta

      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.

      D Offline
      D Offline
      Dave Sexton
      wrote on last edited by
      #2

      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 Sub

      Then 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.

      1 Reply Last reply
      0
      • R re infecta

        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.

        K Offline
        K Offline
        Kschuler
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • R re infecta

          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.

          H Offline
          H Offline
          hannesHTG
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups