Blank the monitor screen

26 views
Skip to first unread message

sande...@gmail.com

unread,
Nov 22, 2007, 9:29:00 AM11/22/07
to ranes...@gmail.com
Hi
My name is Sandesh. I am working on VNC code. I have a VNC server
and a VNC viewer.
In this software the viewer can see the server screen on a remote
computer.
I want to blank the screen on server side when the screen blank
command is sent from the viewer side.

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.

Kellie Fitton

unread,
Nov 22, 2007, 3:55:27 PM11/22/07
to


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.

kingmax_007

unread,
Nov 23, 2007, 12:24:29 AM11/23/07
to
------------------------------------------------
Thanks for the reply
The server program which needs to blank and un-blank the screen is
a window service program.
Can I have a windows procedure for a service program to handle the
DefWindowProc() +WM_SYSCOMMAND, SC_MONITORPOWER, 2
event.


kingmax_007

unread,
Nov 23, 2007, 12:33:06 AM11/23/07
to

kingmax_007

unread,
Nov 23, 2007, 8:42:28 AM11/23/07
to
HI
I have solved the problem.
The UltraVNC also I think keeps the monitor blank by continuously
sending

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.


Reply all
Reply to author
Forward
0 new messages