By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,299 Members | 731 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,299 IT Pros & Developers. It's quick & easy.

Hide and unhide

P: 3
Hello all i am rather new to the whole c # and .net language. my question is in regards to the c# portion of the matter. this is my code block which i have for hiding and unhiding::

Expand|Select|Wrap|Line Numbers
  1.         private void Form1_KeyDown(object sender, KeyEventArgs e)
  2.         {
  3.             if (e.Alt && e.KeyCode.ToString() == "F")
  4.             {
  5.                 // When the user presses both the 'Alt' key and 'F' key,
  6.                 // KeyPreview is set to False, and a message appears.
  7.                 // This message is only displayed when KeyPreview is set to True.
  8.                 this.Visible = false;
  9.                 MessageBox.Show("KeyPreview is True, and this is from the FORM.");
  10.             }
  11.         }
  12.         private void textBox1_KeyDown(object sender, KeyEventArgs e)
  13.         {
  14.             if (e.Alt && e.KeyCode.ToString() == "F")
  15.             {
  16.                 // When the user presses both the 'Alt' key and 'F' key,
  17.                 // KeyPreview is set to False, and a message appears.
  18.                 // This message is only displayed when KeyPreview is set to False.
  19.                 this.KeyPreview = true;
  20.                 MessageBox.Show("KeyPreview is False, and this is from the CONTROL.");
  21.             }
  22.         }

now what my main question is how do i call to a form after it hidden per a keyboard shortcut... i do not want a system tray icon to show or anything this a key combination to bring it back. what it appears is that i may have to use another method due to the fact that i can't input to the form directly if it is hidden. any help is greatly appreciated.

Trae Wathen
Jun 4 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 7,872
You need to create what I believe is refered to as a "global hook", your program will monitor keyboard events even when it does not have the focus.
I cannot remember how to do this (it might require a dllimport) but google "global hook in c#" or something.
They are not natively supported in .NET
And :
Jun 4 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.