Solved

Turning off the monitor

Posted on 2002-03-05
3
230 Views
Last Modified: 2010-05-02
How to turn off the monitor in visual basic on windows XP ?
i mean , putting it in stanby , so it will turn on again with a click or key press.

i got this code at www.planetsourcecode.com , but it doesn't seem to work on XP :

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const WM_SYSCOMMAND = &H112
    Private Const SC_MONITORPOWER = &HF170


'Turn Monitor on: ->
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 0&
'Turn Monitor off: ->
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal -1&
         
0
Comment
Question by:AdrianAisemberg
3 Comments
 
LVL 27

Accepted Solution

by:
Ark earned 50 total points
ID: 6841147
Private Sub Command1_Click()
   Dim oShell As Object
   Set oShell = CreateObject("Shell.Application")
   oShell.Suspend
   Set oShell = Nothing
End Sub

Cheers
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6841220
ping..
0
 

Author Comment

by:AdrianAisemberg
ID: 6843608
Thank you for answering so fast , however , I'm sorry, i don't understand the code you wrote me.
plase add some text to it and explain me what it does and what do i have to add to my vb project for it to work (because it can't find the activex it needs).
another thing : if that code makes the pc go to standby mode , so it's no good for me , because after wake-up , i need to click on my user name at the XP logon screen .
i need one that only turns the monitor off (not only blanking the screen - that one i know how to) , so when i wake it up , it stays in windows .
(it's for a infra-red remote control program i use..)

Thanks ...
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now