Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Turning off the monitor

Posted on 2002-03-05
3
234 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 28

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 51

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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