I have written the following code to blank the screen as well as lock
the inputs to the computer
//Code on the VNC server side
void ClassA::BlankScreenRequest(bool nBlank)
{
BOOL bRetVal = 0;
if (nBlank)
{
//Blank the screen
BlockInput(TRUE);
SetProcessShutdownParameters(0x100, 0);
bRetVal = SystemParametersInfo(SPI_GETPOWEROFFTIMEOUT, 0,
&m_OldPowerOffTimeout, 0);
bRetVal = SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT, 3600, NULL,
0);
bRetVal = SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 1, NULL, 0);
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)
2);
}
else // Monitor On
{
BlockInput(FALSE);
if (m_OldPowerOffTimeout!=0){
bRetVal = SystemParametersInfo(SPI_SETPOWEROFFTIMEOUT,
m_OldPowerOffTimeout, NULL, 0);
}
bRetVal = SystemParametersInfo(SPI_SETPOWEROFFACTIVE, 0, NULL, 0);
m_OldPowerOffTimeout = 0;
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)
-1);
}
}
Using the above code I can blank the screen and at the same time see
the screen on the viewer computer. But if the mouse/keyboard are
operated at any end (Server or Viewer) then the server screen is
switched on back.
I want the server screen to remain OFF till a SCREEN_ON command is
sent from the viewer computer.
Actually I want to switch off the power of the monitor screen at my
applications command. Please help me.
Hi,
Try something like this:
SendMessage() WM_SYSCOMMAND, SC_MONITORPOWER, 2
DefWindowProc() WM_SYSCOMMAND, SC_MONITORPOWER, 2
http://msdn2.microsoft.com/en-us/library/ms644950.aspx
http://msdn2.microsoft.com/en-us/library/ms646360.aspx
http://msdn2.microsoft.com/en-us/library/ms633572.aspx
Kellie.
SendMessage() WM_SYSCOMMAND, SC_MONITORPOWER, 2
to the server till the monitor is UnBlanked.
I too will send
WM_SYSCOMMAND, SC_MONITORPOWER, 2
message in a thread so that I keep the monitor blank at my will.