Library tutorials & articles
Sending Messages
- Introduction
- Simple Commands
- More Commands
- Getting Values
- Setting Properties
Getting Values
There are a number of constants that return values from the SendMessage function. You can also use the SendMessage function to get information from a control because, as it is a function it can return a value. These expose a number of useful properties which are not available with the standard VB control properties. These all begin with EM_ . A few are listed below
Const EM_CANUNDO = &HC6 ' Can we undo the last action?
Const EM_GETFIRSTVISIBLELINE = &HCE ' Get the first visible line in the
rich text box
Const EM_GETLINE = &HC4 ' Get the current line number
Const EM_GETLINECOUNT = &HBA ' Get the total number of lines
To send a command to the text box to do any of these things and get a return value, use the following syntax:
Variable = SendMessage(TextBoxName.hWnd, Constant, 0, 0& )
Where Variable is a variable with the correct data type (in the case of using the above constants - Boolean), TextBoxName is the name of your text box, and Constant is one of the constants listed above. The other two properties are set to 0 and 0& (Null) as they are not needed.
The following example also uses a text box, but finds out if you can Undo in Text1, and if so enables the Undo menu item.
mnuUndo.Enabled = SendMessage(Text1.hWnd,
EM_CANUNDO, 0, 0&) ' This will return either True or False
The following example uses a text box, finds out the number of lines, and displays it in a message box.
Dim nLines As Long
nLines = SendMessage(Text1.hWnd, EM_GETLINECOUNT, 0, 0&) ' This will return
either True or False
Msgbox "This document has " & nLines & " lines"
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.