Trying to Hide then Show my winForm.

I have for WinForm that I want to press a hotkey and show and hide the form.

I can press Insert and hide the form and I see its icon in my Win7 task bar but when I press Insert again it doesn't show. Is my coding logic wrong to make it work? Maybe when its hidden the Insert key isn't being 'seen'? Although the code I am using I got somewhere on the internet that says it will work at the app level.

Thank you...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
        virtual bool PreFilterMessage(Message% m)
        {
            // Detect key down messages. 
            if (m.Msg == WM_KEYDOWN)
            {
                Keys keyCode =  (Keys)((int)m.WParam) & Keys::KeyCode;
                //MessageBox::Show("IMessageFilter.PreFilterMessage: '" + keyCode.ToString() + "' pressed.");
                // Determine whether the keystroke is a number from the top of 
                // the keyboard, or a number from the keypad. 
                //MessageBox::Show("IMessageFilter.PreFilterMessage: '" + keyCode.ToString() + "' pressed.");
                if ((keyCode == Keys::D0) || (keyCode == Keys::NumPad0))
                   {
                        //MessageBox::Show("IMessageFilter.PreFilterMessage: '" + keyCode.ToString() + "' consumed.");
                        return true;
                   }
                if (keyCode == Keys::Insert)
                   {
                        //MessageBox::Show("IMessageFilter.PreFilterMessage: '" + keyCode.ToString() + "' consumed.");
						if (popup == true)
						{
							popup = false;
							this->Hide();
						}
						else
						{
							popup = true;
							this->Show();
						}
                        return true;
                  }
            }
            // Forward all other messages. 
            return false;
        }
Topic archived. No new replies allowed.