Home All Groups Group Topic Archive Search About

How to switch the monitor off through vb6 code?

Author
13 Feb 2009 12:32 PM
b.vijayabharathi
I need to switch the monitor off through visual basic 6.
I got the following code after surfing but has no effect on my monitor
(IBM ThinkVision LCD).

SendMessage HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2&

Can anyone help me out?

Author
14 Feb 2009 6:58 AM
Vinchenzo vinç
<b.vijayabhara***@gmail.com> escribió en el mensaje de noticias
news:762fc726-e983-496d-bf74-48c959891c83@o6g2000pre.googlegroups.com...
>I need to switch the monitor off through visual basic 6.
> I got the following code after surfing but has no effect on my monitor
> (IBM ThinkVision LCD).
>
> SendMessage HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2&
>
> Can anyone help me out?


    Option 1:
    you must pass 'lParam' ByVal if you have declared it "ByRef As Any".

SendMessage HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 2&


    Option 2 (I suggest you this one):
    use a safe delaration, 'lParam' ByVal and "As Long", and call it as you
are doing now:

Private Declare Function SendMessageLong Lib "user32.dll" _
    Alias "SendMessageA" (ByVal hwnd As Long, _
                          ByVal wMsg As Long, _
                          ByVal wParam As Long, _
                          ByVal lParam As Long) As Long

'...
SendMessageLong HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2&
'...



--
    Regards
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
( ! ) http://groups.google.com/group/microsoft.public.vb.general.discussion
( i ) http://www.microsoft.com/communities/conduct/default.mspx
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Author
16 Feb 2009 2:43 PM
b.vijayabharathi
Show quote Hide quote
On Feb 14, 11:58 am, "Vinchenzo vinç" <Vinç@newsgroup.nospam> wrote:
> <b.vijayabhara***@gmail.com> escribió en el mensaje de noticiasnews:762fc726-e983-496d-bf74-48c959891***@o6g2000pre.googlegroups.com...
>
> >I need to switch the monitor off through visual basic 6.
> > I got the following code after surfing but has no effect on my monitor
> > (IBM ThinkVision LCD).
>
> > SendMessage HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2&
>
> > Can anyone help me out?
>
>     Option 1:
>     you must pass 'lParam' ByVal if you have declared it "ByRef As Any".
>
> SendMessage HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 2&
>
>     Option 2 (I suggest you this one):
>     use a safe delaration, 'lParam' ByVal and "As Long", and call it as you
> are doing now:
>
> Private Declare Function SendMessageLong Lib "user32.dll" _
>     Alias "SendMessageA" (ByVal hwnd As Long, _
>                           ByVal wMsg As Long, _
>                           ByVal wParam As Long, _
>                           ByVal lParam As Long) As Long
>
> '...
> SendMessageLong HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2&
> '...
>
> --
>     Regards
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> ( ! )http://groups.google.com/group/microsoft.public.vb.general.discussion
> ( i )http://www.microsoft.com/communities/conduct/default.mspx
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

I tried everything.
Even tried the exact code you've given.
But still I get no response.
Is there anything I am missing?
Author
19 Feb 2009 6:38 PM
Vinchenzo vinç
<b.vijayabhara***@gmail.com> escribió en el mensaje de noticias
news:57cc524d-2c2d-48d1-a1bc-c81fcb6e2ad4@w39g2000prb.googlegroups.com...
On Feb 14, 11:58 am, "Vinchenzo vinç" <Vinç@newsgroup.nospam> wrote:
> <b.vijayabhara***@gmail.com> escribió en el mensaje de
> noticiasnews:762fc726-e983-496d-bf74-48c959891***@o6g2000pre.googlegroups.com...
>
> >I need to switch the monitor off through visual basic 6.
> > I got the following code after surfing but has no effect on my monitor
> > (IBM ThinkVision LCD).
>

I tried everything.
Even tried the exact code you've given.
But still I get no response.
Is there anything I am missing?
-----------------------------------

    Have you tried to send a LowPower (1&) instead?. Take into account that
two monitors of the same model installed in different computers with
different OS can have different behaviour, for instance, I have one monitor
on a Windows XP with XP's specific drivers that both notifications are
executed as it should be. I have another monitor of the same model in a
Vista system with its Vista specific drivers, the LowPower notification
doesn't work, and the call returns always True and no dll error is
generated. So it doesn't matter the monitor's model, if you are calling the
function correctly and nothing happens, then I am sorry but I have no idea
where the problem is.



--
    Regards
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
( ! ) http://groups.google.com/group/microsoft.public.vb.general.discussion
( i ) http://www.microsoft.com/communities/conduct/default.mspx
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Author
24 Feb 2009 5:30 AM
Ed
On Thu, 19 Feb 2009 19:38:54 +0100, "Vinchenzo vinç"
<Vinç@newsgroup.nospam> wrote:

Have you tried it this way,
http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=56393&lngWId=1

I just use the MonitorPowerDown function under XP, never tried the other
functions or under Vista.

Cheers,
Ed