Created
March 27, 2012 12:52
-
-
Save millsy/2215551 to your computer and use it in GitHub Desktop.
Prevent Move, Minimise and Maximise of Window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void WndProc(ref Message message) | |
{ | |
const int WM_SYSCOMMAND = 0x0112; | |
const int SC_MOVE = 0xF010; | |
const int SC_MAXIMIZE = 0xF030; | |
const int SC_MINIMIZE = 0xF020; | |
const int SC_RESTORE = 0xF120; | |
switch (message.Msg) | |
{ | |
case WM_SYSCOMMAND: | |
int command = message.WParam.ToInt32() & 0xfff0; | |
if (command == SC_MOVE || command == SC_MAXIMIZE || command == SC_MINIMIZE || command == SC_RESTORE) | |
{ | |
Console.WriteLine("SC_MOVE SC_MAX SC_MIN SC_RESTORE"); | |
return; | |
} | |
break; | |
} | |
base.WndProc(ref message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Further info on overriding the WndProc method can be found here - http://msdn.microsoft.com/en-us/library/system.windows.forms.control.wndproc.aspx