Google 网上论坛不再支持新的 Usenet 帖子或订阅项。历史内容仍可供查看。

Blank the monitor screen

已查看 26 次
跳至第一个未读帖子

sande...@gmail.com

未读,
2007年11月22日 09:29:002007/11/22
收件人 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

未读,
2007年11月22日 15:55:272007/11/22
收件人


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

未读,
2007年11月23日 00:24:292007/11/23
收件人
------------------------------------------------
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

未读,
2007年11月23日 00:33:062007/11/23
收件人

kingmax_007

未读,
2007年11月23日 08:42:282007/11/23
收件人
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.


0 个新帖子