Catch WM_POWERBROADCAST

rmatthew

Well-known member
Joined
Dec 30, 2002
Messages
115
Location
Texas
I have read that the system will broadcast power status changes on WM_POWERBROADCAST. Ok - call me stupid but I cant seem to find an example on how to receive/trap these messages. I have not needed to do this kind of thing in the past (so I guess it is something I have missed along the way :) ) Any help would be appreciated.

Thanks
 
Im not sure if this will work for you, but you can override the WndProc of your form to check for messages. Some wont get sent still as theyre being passed on to appropriate controls - but you can try it and see if it works.

Im sorry this is C# - just noticed this is the VB forum. I dont know how to convert override into VB.NET :)

Code:
protected override void WndProc(ref System.Windows.Forms.Message msg)
{
	// Replace WM_LBUTTONDOWN with WM_POWER... (I dont konw its value)
	const int WM_LBUTTONDOWN = 0x201;
	if(msg.Msg == WM_LBUTTONDOWN)
	{
		// Do something
		Debug.WriteLine("hit");
	}
	base.WndProc(ref msg);
}

-nerseus
 
Back
Top