Skip to content

Instantly share code, notes, and snippets.

@jaranflaath
Created July 28, 2011 13:59
Show Gist options
  • Save jaranflaath/1111600 to your computer and use it in GitHub Desktop.
Save jaranflaath/1111600 to your computer and use it in GitHub Desktop.
WndProc override C#
protected override void WndProc(ref Message m)
{
int message = m.Msg;
int wparam = 0;
if(m.WParam != null)
{
wparam = m.WParam.ToInt32();
}
if (message == WMConstants.WM_SYSCOMMAND)
{
switch (wparam)
{
case WMConstants.SC_MINIMIZE:
{
Hide();
return;
}
default:
{
break;
}
}
}
else if(message == WMConstants.WM_DEVICECHANGE)
{
switch(wparam)
{
case WMConstants.DBT_DEVICEARRIVAL:
{
supportedDevicesManager.CheckForNewDevices();
break;
}
case WMConstants.DBT_DEVICEREMOVECOMPLETE:
{
supportedDevicesManager.CheckForRemovedDevices();
break;
}
default:
break;
}
}
base.WndProc(ref m);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment