Page 1 of 1

Windows 7 Display on/off event issue?

Posted: Fri Jul 31, 2015 2:13 pm
by rajan_m
Hi,

I'm trying to capture display on/off event using following code, able to capture off event but not on.

Code: Select all

WXLRESULT MyFrame::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
{
	wxTextCtrl* textctrl = (wxTextCtrl*)FindWindowById(MOUSE_TEXT,this);
 
	if(nMsg == WM_SYSCOMMAND )
	{
		if(wParam == SC_MONITORPOWER)
		{
			if(lParam == -1)
				textctrl->AppendText("monitor on\n");	//not working

			if(lParam == 2)
				textctrl->AppendText("monitor off"));	//working
		}
	}
}
I'm not understanding where its going wrong. Help me to solve this issue.

Regards,
Rajan.M

Re: Windows 7 Display on/off event issue?

Posted: Fri Jul 31, 2015 2:34 pm
by DenDev
It might be caused by a signing issue, have you tried casting -1 to WXLPARAM?

Code: Select all

...
if(lParam == (WXLPARAM)-1) textctrl->AppendText("monitor on\n");
...
If this does not help you can try to log the value of lParam on order to see what the value is when the monitor is turned on.

Re: Windows 7 Display on/off event issue?

Posted: Fri Jul 31, 2015 2:45 pm
by doublemax
If i understand the MSDN documentation correctly, these commands can be used to actively change the monitor power status, not to get notified when it changes.