Reputation: 121
how to minimize window to maximize window using shortcut key in window application using c# ?
Upvotes: 0
Views: 3598
Reputation: 1357
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/
Upvotes: 0
Reputation: 11
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;
}
}
Upvotes: 0
Reputation: 2538
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;
}
}
Upvotes: 2
Reputation: 25287
Looking at your accept rate, I will give you the steps:
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.
Upvotes: 0