Skip to content

Instantly share code, notes, and snippets.

@millsy
Created March 27, 2012 12:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save millsy/2215551 to your computer and use it in GitHub Desktop.
Save millsy/2215551 to your computer and use it in GitHub Desktop.
Prevent Move, Minimise and Maximise of Window
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);
}
@millsy
Copy link
Author

millsy commented Mar 27, 2012

Further info on overriding the WndProc method can be found here - http://msdn.microsoft.com/en-us/library/system.windows.forms.control.wndproc.aspx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment