how to minimize window to maximize window using shortcut key in window application using c# ?
Asked
Active
Viewed 3,473 times
4 Answers
2
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;
}
}

Werewolve
- 2,448
- 5
- 24
- 38
-
its work when u can see form but when minimized then what happend??i wont have sictuation that minimize to maximized window form? – HITESH May 03 '10 at 09:12
-
see my comment in the other answer – Werewolve May 03 '10 at 09:17
0
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;
}
}

BuddhiP
- 6,231
- 5
- 36
- 56

Nisarg Trivedi
- 11
- 1
0
Looking at your accept rate, I will give you the steps:
- Add a KeyDown event handler on to the form you want minimized/maximized.
- Add code to check for the key combination you want
- Use
Form.WindowState
to set the state you require.
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.

Community
- 1
- 1

Kyle Rosendo
- 25,001
- 7
- 80
- 118
-
its work when u can see form but when minimized then what happend??i wont have sictuation that minimize to maximized window form? – HITESH May 03 '10 at 09:12
-
then you must register a Globale Windows HotKey. See here: http://dotnet-snippets.de/dns/globale-hotkeys-tastenkombinationen-SID356.aspx – Werewolve May 03 '10 at 09:15
-
i m tell u that when i have minimized application then how to maximized application...? – HITESH May 03 '10 at 10:06
0
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/

Community
- 1
- 1

Dmitriy Zapevalov
- 1,357
- 8
- 13