Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / January 2005

Tip: Looking for answers? Try searching our database.

programming problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tenquillico - 01 Jan 2005 15:43 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.