Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Turn Off Monitor

Turn Off Monitor

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hkulten
    wrote on last edited by
    #1

    Hi all, I would like to be able to turn off/on the monitor programmatically. In fact, I can do that with this piece of code: HWND hWnd = GetSafeHwnd(); ::SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); The problem is when the mouse is moving, the display is turning on back. I tried to use a global mouse hook (implemented in a DLL) which is called and enabled by my main MFC application. The hook works great ! Then, in my application, I have this : InstallHookMouse(); // Install mouse hook which lock all mouse messages DisplayOff(); // Turn off the monitor When I move the mouse while the display is turned off, it turns on back. :wtf: Have I to program a mouse filter driver to lock definitively this mouse and then, the monitor will not turn on back (until my application will decide to turn it on), or is there another solution ? :zzz: Thanks. :)

    D M 2 Replies Last reply
    0
    • H hkulten

      Hi all, I would like to be able to turn off/on the monitor programmatically. In fact, I can do that with this piece of code: HWND hWnd = GetSafeHwnd(); ::SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); The problem is when the mouse is moving, the display is turning on back. I tried to use a global mouse hook (implemented in a DLL) which is called and enabled by my main MFC application. The hook works great ! Then, in my application, I have this : InstallHookMouse(); // Install mouse hook which lock all mouse messages DisplayOff(); // Turn off the monitor When I move the mouse while the display is turned off, it turns on back. :wtf: Have I to program a mouse filter driver to lock definitively this mouse and then, the monitor will not turn on back (until my application will decide to turn it on), or is there another solution ? :zzz: Thanks. :)

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      hkulten wrote: The problem is when the mouse is moving, the display is turning on back. When I move the mouse while the display is turned off, it turns on back. If you turn the monitor off programmatically, how is it expected to turn back on other than via the mouse or keyboard?


      "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

      M H 2 Replies Last reply
      0
      • D David Crow

        hkulten wrote: The problem is when the mouse is moving, the display is turning on back. When I move the mouse while the display is turned off, it turns on back. If you turn the monitor off programmatically, how is it expected to turn back on other than via the mouse or keyboard?


        "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        :laugh:


        Maximilien Lincourt Your Head A Splode - Strong Bad

        1 Reply Last reply
        0
        • H hkulten

          Hi all, I would like to be able to turn off/on the monitor programmatically. In fact, I can do that with this piece of code: HWND hWnd = GetSafeHwnd(); ::SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); The problem is when the mouse is moving, the display is turning on back. I tried to use a global mouse hook (implemented in a DLL) which is called and enabled by my main MFC application. The hook works great ! Then, in my application, I have this : InstallHookMouse(); // Install mouse hook which lock all mouse messages DisplayOff(); // Turn off the monitor When I move the mouse while the display is turned off, it turns on back. :wtf: Have I to program a mouse filter driver to lock definitively this mouse and then, the monitor will not turn on back (until my application will decide to turn it on), or is there another solution ? :zzz: Thanks. :)

          M Offline
          M Offline
          Maximilien
          wrote on last edited by
          #4

          hkulten wrote: ::SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); the SC_MONITORPOWER doesn't really turn the monitor off, it only make use of the power-saving feature of the monitor ( just like the screensaver does )


          Maximilien Lincourt Your Head A Splode - Strong Bad

          H 1 Reply Last reply
          0
          • D David Crow

            hkulten wrote: The problem is when the mouse is moving, the display is turning on back. When I move the mouse while the display is turned off, it turns on back. If you turn the monitor off programmatically, how is it expected to turn back on other than via the mouse or keyboard?


            "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

            H Offline
            H Offline
            hkulten
            wrote on last edited by
            #5

            That's right. I badly expressed myself. X| :zzz: As the same way I can turn off the display programmatically, I will turn it back on programmatically. I don't want the user can turn on the screen. That's why I tried to lock mouse moves, but it does not work. Any solution(s) ? :cool:

            D 1 Reply Last reply
            0
            • M Maximilien

              hkulten wrote: ::SendMessage(hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF); the SC_MONITORPOWER doesn't really turn the monitor off, it only make use of the power-saving feature of the monitor ( just like the screensaver does )


              Maximilien Lincourt Your Head A Splode - Strong Bad

              H Offline
              H Offline
              hkulten
              wrote on last edited by
              #6

              Yes you are right, but my purpose is to use this power-saving feature from my application. I want to be able to turn on/off monitor when I need, and no turn back on of the display when the mouse is moving. Maybe are there softwares which can do that ? :~ Thanks.

              1 Reply Last reply
              0
              • H hkulten

                That's right. I badly expressed myself. X| :zzz: As the same way I can turn off the display programmatically, I will turn it back on programmatically. I don't want the user can turn on the screen. That's why I tried to lock mouse moves, but it does not work. Any solution(s) ? :cool:

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                Unless you can convince me otherwise, I consider that to be very non user-friendly. If I'm working on the computer and some application decides that the monitor needs to go off and I can't turn it back on by moving the mouse, I would seriously consider removing that application.


                "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                H 1 Reply Last reply
                0
                • D David Crow

                  Unless you can convince me otherwise, I consider that to be very non user-friendly. If I'm working on the computer and some application decides that the monitor needs to go off and I can't turn it back on by moving the mouse, I would seriously consider removing that application.


                  "The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)

                  H Offline
                  H Offline
                  hkulten
                  wrote on last edited by
                  #8

                  Yes, you're right for this point, but my application is targeting PC which displays multimedia messages on screens (LCD or Plasma) and, normally, there are no interactive users on these machines. My application must turn off/on screens when no messages are displayed in order to save LCD/Plasma life time. My solution works well because, for that kind of PC, there are no users, but I want to develop my application properly, and I cannot accept that the screen could turn on without my application. :) Maybe this is not possible on Windows platform to turn off properly the screen. :( The last thing I would say is that I could do that on Atari ST platform, and fifteen years later, I could not do the same thing on Windows platform fifteen years old :confused: ?!! I think this is the progress... Thanks for your response.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups