Results 1 to 11 of 11

Thread: Turn a monitor off

  1. #1
    Frenzied Member
    Join Date
    Sep 08
    Posts
    1,030

    Turn a monitor off

    Here is my code:

    Code:
        Public Declare Function PostMessage Lib "user32.dll" _
    Alias "PostMessageA" _
    (ByVal hwnd As IntPtr, _
    ByVal wMsg As Int32, _
    ByVal wParam As Int32, _
    ByVal lParam As Int32) As Int32
    
        Public Const WM_SYSCOMMAND = &H112&
        Public Const SC_MONITORPOWER = &HF170&
    And here is the actual code to do the task:

    Code:
    PostMessage(Me.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2&)
    This puts the monitor into standby. Can I please have some help to modify the code to turn the monitor off, and also the code to turn it back on.

    Thanks

  2. #2
    Hyperactive Member
    Join Date
    Jan 07
    Posts
    333

    Re: Turn a monitor off

    From this article:
    http://www.codeproject.com/Articles/...on-off-monitor
    To turn on you need set the last parameter of that function to -1.

    I would think that standby is the best you can as you can't control the power to the monitor, and I don't beleive the have a soft shutdown feature like PCs do.

    Hth
    Rico

    Using: VB.net & MS SQL

  3. #3
    .NUT jmcilhinney's Avatar
    Join Date
    May 05
    Location
    Sydney, Australia
    Posts
    80,872

    Re: Turn a monitor off

    I doubt that there is any such code. As far as I'm aware, the only way to actually turn one of my monitors off, both at home and at work, is to physically press the power switch. Think about it. If you are wanting to turn the monitor off then that means no messages from the computer, so how could you possibly turn it back on again?

  4. #4
    Frenzied Member
    Join Date
    Sep 08
    Posts
    1,030

    Re: Turn a monitor off

    I was thinking of doing it on a timer. Say... turn monitor off and then turn back on in 5 minutes. Or even better, when the O button is pressed, the monitor turns back on.

  5. #5
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Turn a monitor off

    I would have to join in and say that is not something that would seem possible. Putting a monitor into standby and bringing it back is quite different than turning it off and back on. Once the monitor is actually off you must turn it on manually.

    The only exception I could think of would be if you created a device that you could attach to your serial or usb port which would act as a remote control unit and allow you to interface with it from the PC. Of course most PC monitors do not use a remote so even that would not work but it would be possible where the monitor in use supports a remote control.

  6. #6
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 02
    Location
    Idaho
    Posts
    20,410

    Re: Turn a monitor off

    We like off to mean off, but that is increasingly not the case. Most monitors don't have a feature to start up, but I don't think that was always the case, and it may not be the case for this situation. I have some vague memory of early systems where the monitor power cord plugged into the PC box itself. If that were the case, then it would be possible for the PC to have circuitry to control power to the monitor, and thereby it would have the capability to turn off the monitor. I have seen other intermediate systems that have features like this, though none could be controlled by the PC. Still, I wouldn't find it very surprising to find that somebody had such a system.
    My usual boring signature: Nothing

  7. #7
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Turn a monitor off

    I have not saw a system where the montior power was controlled by the PC since the DOS days and AT machines. Many of those still used a seperate switch on the montior but many AT power supplys had an outlet that you could plug your montior into. The PS was not designed to allow the PC to turn off the power to that port though. I did have one system where there was no power switch on the monitor and the switch on the desktop unit powered up both the monitor and the CPU still to turn off the monitor you had to turn off the CPU.

    I seem to remember that some of the old IBM AT systems were this way.

  8. #8
    Angel of Code Niya's Avatar
    Join Date
    Nov 11
    Posts
    3,144

    Re: Turn a monitor off

    To me it seems modern monitors have blurred the difference between off and standby. They're practically the same thing. I've had monitors where when you press the power button, the little "on" light turns orange, the same as if it went into sleep/standby mode.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | Create Sortable BindingList(not mine) | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading


    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  9. #9
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Turn a monitor off

    My HDTV is that way as well, when it is in standby it looks the same as when it is off but when it is off I have to hit the power to get it to come back where in standby I can just wiggle the mouse.

  10. #10
    Loquacious User Shaggy Hiker's Avatar
    Join Date
    Aug 02
    Location
    Idaho
    Posts
    20,410

    Re: Turn a monitor off

    That's true. Even if it does turn off, it is still drawing some minor amount of power. When my LCD monitors are off, the power draw is darn near zero, but it isn't quite zero. It is less than the box or the speakers, though.
    My usual boring signature: Nothing

  11. #11
    PowerPoster
    Join Date
    Feb 12
    Location
    West Virginia
    Posts
    4,957

    Re: Turn a monitor off

    In the case of those which support remotes such as the TV I am using they must draw enough to power the remote receiver in order to be powered on by remote.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •