I want to prevent my desktop application from being maximized. It should not become maximized by any means - by double clicking on title bar, or by clicking Windows + Up arrow on the keyboard, etc.
-> I disable both the MaximizeBox and MinimizeBox.
-> I also set the MaximumSize and MinimumSize for my WinForm
Still when I press Windows + Up arrow, my win form Shifts to top left of the screen, I mean it gets maximized.
So please tell me any way to prevent this thing happening...
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
There is a property of the Form class named "MaximumBox" you have to set False in the properties window of your form... This actually will disable the form from being maximized by any way... Also if you want to control your form sizes you can work with such properties as "MinimumSize, MaximumSize" setting their values at your discretion or creating an event handler for the MaximumSizeChanged and MinimumSizeChanged events...
You can try to RegisterHotKey Win+Up if your window or application is activated and unregister this hot key if it is deactivated. You must catch the hotkey and return appropriate value to prevent further processing.
Look at
WM_ACTIVATEAPP
,WM_ACTIVATE
andWM_NCACTIVATE
. The first can be used if you want to disable the Win+UP for all your windows.One thing you can do is set the MaximumSize and MinimumSize in the same value but not 0,0.
The form has a property called
MaximizeBox
- set this to false.In regard to your second question, check out this question and it's answers for the best ways to implement keyboard shortcuts in WinForms.
Setting the MaximumSize equal to the Size (or some size) at least stops the windows from going full-screen. It still snaps to the top left corner but it's still a window at least and looks right - like it's Windows being stupid instead of your program.
You can prevent the windows snapping to the upper left corner by setting:
in the move event of the form.