?
Solved

Turning off the monitor

Posted on 2002-03-05
3
Medium Priority
?
237 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
[X]
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
3 Comments
 
LVL 28

Accepted Solution

by:
Ark earned 150 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 53

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…
Suggested Courses

771 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