Click here to Skip to main content
6,629,377 members and growing! (24,751 online)
Email Password   helpLost your password?
General Reading » Hardware & System » Hardware     Intermediate

Turn on/off monitor

By Dalibor Drzik

Sets the state of the display.
VC6, Dev
Posted:25 Jul 2005
Views:100,675
Bookmarked:50 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
33 votes for this article.
Popularity: 6.78 Rating: 4.46 out of 5
3 votes, 9.1%
1

2
3 votes, 9.1%
3
2 votes, 6.1%
4
25 votes, 75.8%
5

Introduction

The SendMessage function is useful to handle monitor states - the display is going to low power, the display is being shut off and the display is turned on.

Code explanation

While using SendMessage function, you have to set four parameters:

  • hWnd

    Handle to the window whose window procedure will receive the message. If you don't want to bother creating a window to send the message to, you can send the message to all top level windows (HWND_BROADCAST) or you can use GetDesktopWindow function sending the message to the desktop window.

  • Msg

    Specifies the message to be sent (WM_SYSCOMMAND).

  • wParam

    Specifies additional message-specific information (SC_MONITORPOWER).

  • lParam
    • 1 - the display is going to low power.
    • 2 - the display is being shut off.
    • -1 - the display is being turned on (undocumented value).
// Turn off monitor

Sleep(500); // Eliminate user's interaction for 500 ms

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);

// Turn on monitor

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1);

// Low power monitor

Sleep(500); // Eliminate user's interaction for 500 ms

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 1);

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Dalibor Drzik


Member
Wink
Occupation: Web Developer
Location: Slovakia Slovakia

Other popular Hardware & System articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 45 (Total in Forum: 45) (Refresh)FirstPrevNext
GeneralThank you so much! PinmemberMember 211670615:52 21 May '09  
Generalhow to calculate the time between monitor off and on Pinmembersrinag4918:37 11 Sep '08  
GeneralMonitior control--in Windows xp Pinmembernnuurraa20:56 29 Feb '08  
QuestionShall it stay countinously? Pinmemberthamizhinpan8:57 15 Oct '07  
AnswerRe: Shall it stay countinously? PinmemberDalibor Drzik2:39 16 Oct '07  
GeneralRe: Shall it stay countinously? Pinmemberkingmax_00721:09 18 Nov '07  
GeneralKeeping the Monitor Turned ON PinmemberSukhjinder_K7:40 6 Sep '07  
AnswerRe: Keeping the Monitor Turned ON PinmemberDalibor Drzik12:22 6 Sep '07  
GeneralRe: Keeping the Monitor Turned ON PinmemberSukhjinder_K1:33 7 Sep '07  
Generalkeeping the monitor turned off Pinmemberauldthief23:36 13 Jun '07  
Generalplz help!!! Pinmembermisha2dope22:51 3 Apr '07  
AnswerRe: plz help!!! PinmemberDalibor Drzik8:50 4 Apr '07  
QuestionDifference between standby and off? Pinmemberoeriksen13:01 11 Oct '06  
AnswerRe: Difference between standby and off? PinmemberDalibor Drzik8:37 4 Apr '07  
Questioncan't keep blank when mediaplayer playing next song Pinmemberaftcast8:18 6 Jul '06  
AnswerRe: can't keep blank when mediaplayer playing next song PinmemberDalibor Drzik8:38 4 Apr '07  
GeneralControl your monitor by software PinmemberRobsori22:25 13 Jun '06  
GeneralRe: Control your monitor by software PinmemberMember 472880419:12 2 Jun '08  
GeneralRe: Control your monitor by software PinmemberMember 472880423:08 2 Jun '08  
GeneralFYI PinsitebuilderMichael Dunn9:07 13 Jun '06  
AnswerRe: FYI PinmemberDalibor Drzik8:29 4 Apr '07  
GeneralAnd how to turn off harddisk? Pinmemberandreasm822:26 11 Jun '06  
GeneralDetect monitor changes? PinmemberJudge429:43 3 Apr '06  
AnswerRe: Detect monitor changes? PinmemberDalibor Drzik4:11 24 Apr '06  
GeneralGood Job! PinmemberJohn R. Shaw17:46 16 Mar '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 25 Jul 2005
Editor: Smitha Vijayan
Copyright 2005 by Dalibor Drzik
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project