Tutorial :how to minimize window to maximize window using shortcut key in window application using c#?



Question:

how to minimize window to maximize window using shortcut key in window application using c# ?


Solution:1

Set Form Propertie "KeyPreview" = true.

Then use this code:

        private void Form1_KeyDown(object sender, KeyEventArgs e)      {          if (e.KeyCode == Keys.B)          {              WindowState = FormWindowState.Minimized;          }      }  


Solution:2

Looking at your accept rate, I will give you the steps:

As a sidenote, please start accepting answers. You can do it by clicking the "tick" next to an answer that helped you solve your problem.


Solution:3

thanxs man its working and if we can change our state with this key follow this code..

 if (e.Key == Key.F11)              {                  if (this.WindowState == WindowState.Maximized)                  {                      this.WindowState = WindowState.Normal;                  }                  else                  {                      this.WindowState = WindowState.Maximized;                  }              }  


Solution:4

Werewolve mentioned correct link!

When application is minimized it will not receive any keyboard input. Otherwise applications would not who was the keyboard target.

If you want your application to receive signal when specific keys combination where pressed you should register this combination by calling RegisterHotKey Windows API function.

Your form showing/maximising action could be invoked by this signal/


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »