Solved

Turning off the monitor

Posted on 2002-03-05
3
232 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 50

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel object stays open 19 73
using Access 8 68
Access Object Property from VBA Module in Excel 2010 2 31
Error with a code discussed on this page 5 12
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

774 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