Library tutorials & articles
Sending Messages
Introduction
Visual C++ revolves around messages. Messages are sent to controls from windows giving them information and instructing them to do things. Messages are also sent from controls to windows, and to other controls. Being able to send messages to controls allows you to do much more than using Visual Basic procedures. Messages can be sent using the SendMessage function in the user32.dll. To use it, simply enter the following declaration into a form. If you want to enter it into a module, and use it throughout the project, change the Private to Public.
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
All you need to know to send a message to a control is its hWnd property and the command you want to send to it. To find the command you want to use, load up the API Text Viewer, and select Constants from the API Type list box. Constants that begin with WM_ tell the control to do something, EM_ to return a value.
The advantage of being able to send these commands is that you are using the controls code, which you presume is bug free, rather than your own. This will save space as well as time. Of course if you want to do something the control can't do you have to write your own code still.
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
Dude i have got a software which does all the thing u told but its for sale just 1.2$ or 50Rs
if u wish u can mail me humanprocessor@yahoo.co.in
I wanted to use sendmessage in VB.net
As Integer
with following declaration
<DllImport("user32.dll", CharSet:=CharSet.Auto)> _
Public Shared Function SendMessage( _
ByVal handle As IntPtr, _
ByVal message As Integer, _
ByVal wParam As IntPtr, _
ByVal lParam As String _
 
end function
But I am not getting the required text but I am getting windows text.
Actually I am trying to get user typed URL from the address bar of IE.
But the functions returns IE windows text
Could any one suggest me how to solve this problem
I want to store all the keystrokes from diiferent windows programs. Like i am typing in word, writing code in VB, editing a Txt file or filling information on web as i am doiing now.....I want to get all the keystrokes....stored in a file.
Please reply me....
This thread is for discussions of Sending Messages.