Click here to Skip to main content
Click here to Skip to main content

Turn on/off monitor

By , 24 Jul 2005
Rate this:
Please Sign up or sign in to vote.


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

// Turn on monitor

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


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
Web Developer
Slovakia Slovakia
Wink | ;-)

Comments and Discussions

QuestionRequest_To_Elaborate_Code PinmemberMember 815523825-Dec-13 2:51 
Questionmonitor blinks PinmemberSanjeevCharla6-Feb-13 15:42 
QuestionCan this work under remote desktop? Pinmembergeorge0880722-Dec-12 4:56 
I use remote desktop to logon to another machine. Since I don't need to use the monitor, I want to turn off the monitor. However, it seems this doesn't take effect. I guess it's because of the window handle is confined to the current remote desktop session. Is there a way to turn off the physical monitor in this case? Thanks!
GeneralMy vote of 5 Pinmembersunny_rajwadi23-May-12 0:11 
QuestionReally Turn Off Monitor Pinmembernano2k20-Oct-11 3:08 
GeneralThank you so much! PinmemberMember 211670621-May-09 14:52 
Questionhow to calculate the time between monitor off and on Pinmembersrinag4911-Sep-08 17:37 
GeneralMonitior control--in Windows xp Pinmembernnuurraa29-Feb-08 19:56 
QuestionShall it stay countinously? Pinmemberthamizhinpan15-Oct-07 7:57 
AnswerRe: Shall it stay countinously? PinmemberDalibor Drzik16-Oct-07 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 25 Jul 2005
Article Copyright 2005 by Dalibor Drzik
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid