|
-
Jun 19th, 2001, 09:52 AM
#1
Thread Starter
Junior Member
Obtaining the handle of a Text Box Control.
i have tried to browse thorugh the MSDN library and the message boards to figure out how to do this, but im not having any luck. I want to be able to paste text into a text box of another window. How can I reference the handle of that box? Thanks in advance.
-
Jun 19th, 2001, 10:26 AM
#2
Fanatic Member
Look at the code in the General forum under Net send
http://161.58.186.97/showthread.php?s=&threadid=83852
This tells you how to find a window, then a child window and extract the text from it,
use these principles (and just set the text instead of extracting it)if you dont own the app, (if you do own the app then its TextBoxName.hWnd) and the message is WM_SETTEXT, and the classname for textbox is "Textbox" unless the app was written in vb then (CUE GURU) i'm sure someone knows what the classname is (try doing a forum search on "Thunder")
hope this helps (sorry it's a bit muddled but I have to run to a meeting)
Crispin
VB6 ENT SP5
VB.NET
W2K ADV SVR SP3
WWW.BLOCKSOFT.CO.UK
[Microsoft Basic: 1976-2001, RIP]
-
Jun 19th, 2001, 10:36 AM
#3
Thread Starter
Junior Member
....
much appreciated.. soulds like what i was looking for. thanks!
-
Jun 19th, 2001, 01:18 PM
#4
Thread Starter
Junior Member
hmmmm...
ok.. im trying to wite a stub now that will enumerate the child windows of a parent window I have come up with the code shown below. I'm running it on a Window I created myself and searching for a value I know should exist( i have a text box on the form called ProbDisc). It only loops once and comes up with a value of "On Top", which i assume is my always on top check box, but goes no further. Did i screw up somewhere?
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
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function SendMessageByStr& Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal _
lParam As String)
Dim lhWnd&
Dim ltxthWnd
Dim ltChars&
Dim sBuff$
Private Sub Form_Load()
sBuff = String(256, " ")
lhWnd = FindWindowEx(0&, 0&, vbNullString, "TaskHelper - ddddd") 'Request Detail")
If lhWnd Then EnumChildWindows lhWnd, AddressOf EnumChildProc, 0
End Sub
---------------------------------------------------------
In a Module, we have:
----------------------------------------------------------
Private Declare Function EnumChildWindows Lib "user32.dll" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Const WM_GETTEXT = &HD
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim Length As Long
Dim sName As String
Dim Temp As String
Static iCount As Integer
iCount = iCount + 1
Length = GetWindowTextLength(hwnd) + 1
If Length > 1 Then
sName = Space(Length)
GetWindowText hwnd, sName, Length
sName = Left(sName, Length - 1)
If sName Like "ProbDisc" Then
MsgBox "Window Found!"
EnumWindowsProc = 0
Else
MsgBox sName
EnumWindowsProc = 1
End If
End If
End Function
-
Jun 19th, 2001, 01:25 PM
#5
Thread Starter
Junior Member
dUUUHHH!
thats what i get for cutitng and pasting too much code.. never mind guys, i think i got it.
-
Jun 19th, 2001, 02:37 PM
#6
VB Code:
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
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
Private Const WM_PASTE = &H302
Private Sub Command1_Click()
Dim hParent As Long, hChild As Long
hParent = FindWindowEx(0, 0, "MyWindowClass", "MyWindowTitle")
hChild = FindWindowEx(hParent, 0, "Edit", vbNullString)
SendMessage hChild, WM_PASTE, 0, 0
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|