Option Explicit
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
Const WM_SYSCOMMAND = &H112
Const SC_MONITORPOWER = &HF170
Private Sub Command1_Click()
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal -1&
End Sub
Private Sub Command2_Click()
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, ByVal 0&
End Sub
this code is from vb6, however, my programming knowledge is limited - i dont
understand how to get this to work in vb.net
i realise the changes that are needed are the "As Any" and the Me.hWnd to
Me.Handles
please help me
Carlos J. Quintero [.NET MVP] - 03 Jan 2005 11:42 GMT
(Not tested):
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As System.IntPtr, ByVal wMsg As Integer, ByVal wParam As
Integer, ByVal lParam As Integer) As Integer
Const WM_SYSCOMMAND As Integer= &H112
Const SC_MONITORPOWER As Integer= &HF170
Private Sub Command1_Click() Handles Command1.Click
SendMessage Me.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1
End Sub
Private Sub Command2_Click() Handles Command2.Click
SendMessage Me.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 0
End Sub
Basically, "Long" -> "Integer", hwnd-> Handle and handles are declared as
IntPtr. As for "As Any", you can declare as many overloaded SendMessage
functions as needed varying the last parameter to meet your needs, "As Any"
is no longer needed.

Signature
Carlos J. Quintero
MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code and design much faster.
http://www.mztools.com
> Option Explicit
> Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
[quoted text clipped - 21 lines]
>
> please help me