|
-
Jan 7th, 2006, 03:40 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] monitor question
anyone know how i can turn my montior screen off on the click of a vb button?
-
Jan 7th, 2006, 03:43 PM
#2
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
-
Jan 7th, 2006, 03:55 PM
#3
Thread Starter
Frenzied Member
Re: monitor question
i found this somewhere, but now sure if it poweroff.exe even exists
poweroff.exe -scheduled -seconds 2 -notray monitor_off
-
Jan 7th, 2006, 03:58 PM
#4
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 03:59 PM
#5
Re: monitor question
Not tested this, but apparantly it works...
VB Code:
Option Explicit
Private Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" (ByVal hWnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Any) As Long
Const SC_MONITORPOWER = &HF170&
Public Const MONITOR_ON = -1&
Public Const MONITOR_OFF = 2&
Const WM_SYSCOMMAND = &H112
'Turn Monitor on:
'SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_ON
'
'Turn Monitor off:
'SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF
-
Jan 7th, 2006, 04:00 PM
#6
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 04:01 PM
#7
-
Jan 7th, 2006, 04:03 PM
#8
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 04:03 PM
#9
Thread Starter
Frenzied Member
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)
-
Jan 7th, 2006, 04:04 PM
#10
Re: monitor question
 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.
-
Jan 7th, 2006, 04:04 PM
#11
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 04:06 PM
#12
-
Jan 7th, 2006, 04:06 PM
#13
Thread Starter
Frenzied Member
Re: monitor question
hm i tested the one robdog found too, doesnt work for me at all
i guess ill stick with thegreastones
-
Jan 7th, 2006, 04:08 PM
#14
-
Jan 7th, 2006, 04:09 PM
#15
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:
Declare Function EnumDisplayMonitors Lib "user32.dll" (ByVal hdc As Long, ByRef lprcClip As Any, ByVal lpfnEnum As Long, ByVal dwData As Long) As Long
Declare Function GetMonitorInfo Lib "user32.dll" Alias "GetMonitorInfoA" (ByVal hMonitor As Long, ByRef lpmi As MONITORINFO) As Long
Declare Function MonitorFromPoint Lib "user32.dll" (ByVal x As Long, ByVal y As Long, ByVal dwFlags As Long) As Long
Declare Function MonitorFromRect Lib "user32.dll" (ByRef lprc As RECT, ByVal dwFlags As Long) As Long
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 04:17 PM
#16
Re: monitor question
 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 !!!
 Originally Posted by RobDog888
Edit: At least I had a VBF link.
I found that link long before I became VBF member.
-
Jan 7th, 2006, 04:21 PM
#17
Re: monitor question
 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...
-
Jan 7th, 2006, 04:31 PM
#18
Re: [RESOLVED] monitor question
Last edited by iPrank; Jan 7th, 2006 at 04:36 PM.
-
Jan 7th, 2006, 04:37 PM
#19
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 04:39 PM
#20
Re: [RESOLVED] monitor question
See the second link (edited). Has code in VB and C#.
-
Jan 7th, 2006, 04:40 PM
#21
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 04:48 PM
#22
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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 
-
Jan 7th, 2006, 04:53 PM
#23
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.
-
Jan 7th, 2006, 05:38 PM
#24
Re: [RESOLVED] monitor question
 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:
Const MONITOR_ON = -1&
Const MONITOR_OFF = 2&
Const MONITOR_STANDBY = 1&
-
Jan 7th, 2006, 05:52 PM
#25
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 Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|