Results 1 to 25 of 25

Thread: [RESOLVED] monitor question

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Resolved [RESOLVED] monitor question

    anyone know how i can turn my montior screen off on the click of a vb button?

  2. #2
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: monitor question

    Yes, you could look for Power Managemnet options. I'm not sure of the actual code, but its to do with that
    Zeegnahtuer?

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: monitor question

    i found this somewhere, but now sure if it poweroff.exe even exists

    poweroff.exe -scheduled -seconds 2 -notray monitor_off

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: monitor question

    I didnt have it on my system - XP Pro SP1
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: monitor question

    Not tested this, but apparantly it works...

    VB Code:
    1. Option Explicit
    2. Private Declare Function SendMessage Lib _
    3. "user32" Alias "SendMessageA" (ByVal hWnd As Long, _
    4. ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
    5.  
    6.  
    7. Const SC_MONITORPOWER = &HF170&
    8. Public Const MONITOR_ON = -1&
    9. Public Const MONITOR_OFF = 2&
    10. Const WM_SYSCOMMAND = &H112
    11.  
    12. 'Turn Monitor on:
    13. 'SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON
    14. '
    15. 'Turn Monitor off:
    16. 'SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF
    Zeegnahtuer?

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: monitor question

    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: monitor question

    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: monitor question

    So thats where you found it thegreatone
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: monitor question

    thanks m8, i tested that code, the screen goes black, then when i move my mouse, it goes on again..

    any way to make it go off properly?

    (oops, just saw everybodies replies after i submitted this post, reading everyone elses now lol)

  10. #10
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: monitor question

    Quote Originally Posted by RobDog888
    So thats where you found it thegreatone
    Originally yeah, i've had it on my PC for a while now, never got round to testing it, lol.

    Still, beat ya *sticks tongue out*

    EDIT: Pouncer theres no way to physically turn the monitor off.
    Zeegnahtuer?

  11. #11
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: monitor question

    The code is probably doing a screensaver power off so when you move the mouse it wakes it up and powers on.

    Edit: At least I had a VBF link.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  12. #12
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: monitor question

    Quote Originally Posted by RobDog888
    The code is probably doing a screensaver power off so when you move the mouse it wakes it up and powers on.

    Edit: At least I had a VBF link.
    Its using the power management options, just like my monitor does after 5mins of being inactive, lol

    EDIT: I might have done originally i dunno, i've had that code ages now
    Zeegnahtuer?

  13. #13

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2005
    Posts
    1,364

    Re: monitor question

    hm i tested the one robdog found too, doesnt work for me at all

    i guess ill stick with thegreastones

  14. #14
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: monitor question

    Glad it worked for you. I tested it and it works for me as well Great

    Now do us a favour by pulling down the thread tools menu and selecting "Mark thread resolved"

    Thanks
    Zeegnahtuer?

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: monitor question

    They are all the same basically.

    These are the APIs for the Monitor. Maybe they will shed some light on the issue.


    VB Code:
    1. Declare Function EnumDisplayMonitors Lib "user32.dll" (ByVal hdc As Long, ByRef lprcClip As Any, ByVal lpfnEnum As Long, ByVal dwData As Long) As Long
    2.  
    3. Declare Function GetMonitorInfo Lib "user32.dll" Alias "GetMonitorInfoA" (ByVal hMonitor As Long, ByRef lpmi As MONITORINFO) As Long
    4.  
    5. Declare Function MonitorFromPoint Lib "user32.dll" (ByVal x As Long, ByVal y As Long, ByVal dwFlags As Long) As Long
    6.  
    7. Declare Function MonitorFromRect Lib "user32.dll" (ByRef lprc As RECT, ByVal dwFlags As Long) As Long
    8.  
    9. Declare Function MonitorFromWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal dwFlags As Long) As Long
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: monitor question

    Quote Originally Posted by Myself
    Don't know what happned ! The EE page now reqires registration.
    Just a few minutes ago I saw the full thread without any registration !!!

    Quote Originally Posted by RobDog888
    Edit: At least I had a VBF link.
    I found that link long before I became VBF member.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  17. #17
    Frenzied Member thegreatone's Avatar
    Join Date
    Aug 2003
    Location
    Oslo, Norway. Mhz:4800 x12
    Posts
    1,333

    Re: monitor question

    Quote Originally Posted by iPrank
    Don't know what happned ! The EE page now reqires registration.
    Just a few minutes ago I saw the full thread without any registration !!!


    I found that link long before I became VBF member.
    Same here, clear your cookies and se what happens...
    Zeegnahtuer?

  18. #18
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] monitor question

    Last edited by iPrank; Jan 7th, 2006 at 04:36 PM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  19. #19
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] monitor question

    Looks like its all C++ code though. No VB examples?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  20. #20
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] monitor question

    See the second link (edited). Has code in VB and C#.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  21. #21
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] monitor question

    Just seen the second link and seems the same code as I posted a link to with the exception of the first parameter being any window handle vs the const HWND_BROADCAST.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  22. #22
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] monitor question

    Doesnt work for me using either the Me.hWnd or HWND_BROADCAST.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  23. #23
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] monitor question

    Sorry. I don't know what difference it makes to the OS if we broadcast the message or send it to our own hwnd.

    I found the code almost 6 months ago and after single testing saved under my 'cool codes' folder. Never used it since then.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  24. #24
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: [RESOLVED] monitor question

    Quote Originally Posted by RobDog888
    Doesnt work for me using either the Me.hWnd or HWND_BROADCAST.
    Both hWnd and HWND_BROADCAST works for me.

    By googling for some time, I found that :

    The code will turn off/on the monitor on which the form (hWnd) is displayed. Your motherboard must support advanced power management.

    6 months ago I had no problem with this code in Win2K. But now, on WinXP-SP2 it treates MONITOR_OFF as MONITOR_STANDBY. i.e., it turns the monitor on if we move mouse/hit keyboard.

    Then I found this page where a member (agent007bond - last post) pointed to this tool (haven't tested it yet), which turns monitor off. From that page:
    03/11/2004 1.53 Fixed 'monitor off' problem in XP SP2.
    So, may be this is XP-SP2 specific problem ?
    VB Code:
    1. Const MONITOR_ON = -1&
    2. Const MONITOR_OFF = 2&
    3. Const MONITOR_STANDBY = 1&
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  25. #25
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: [RESOLVED] monitor question

    Thanks. I am running SP-1 so maybe its just a XP thing. There must be a proper way as that command line utility can do it so must we. I'll have to break out my mobo manual and check it out.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

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



Click Here to Expand Forum to Full Width