• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

Turning off the monitor

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
AdrianAisemberg
Asked:
AdrianAisemberg
1 Solution
 
ArkCommented:
Private Sub Command1_Click()
   Dim oShell As Object
   Set oShell = CreateObject("Shell.Application")
   oShell.Suspend
   Set oShell = Nothing
End Sub

Cheers
0
 
Ryan ChongCommented:
ping..
0
 
AdrianAisembergAuthor Commented:
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now