|
-
Aug 17th, 2000, 04:33 AM
#1
Thread Starter
New Member
Hi,
I would like to edit a textbox, but I don't know how to
get its handle.
Should I use SendMessage ?
Thanks for your answers.
-
Aug 17th, 2000, 05:17 AM
#2
Fanatic Member
Code:
dim Handle as long
Handle=Text1.Hwnd
-
Aug 17th, 2000, 06:04 AM
#3
Thread Starter
New Member
Thanks oetje,
But the Window I would edit is not one of my VB program.
It's a Window from another program, and I want to write a
text in one of its textbox.
-
Aug 17th, 2000, 08:00 AM
#4
Use FindWindowEx. This example will send the A key to Notepad. (so make sure Notepad is pre-opened)
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const WM_CHAR = &H102
Private Sub Command1_Click()
Dim hParent As Long
Dim hChild As Long
'Get the hWnd of parent window
hParent = FindWindow("Notepad", vbNullString)
'Get the hWnd of the Edit Control
hChild = FindWindowEx(hParent, 0&, "Edit", vbNullString)
'Send the "A" key to it
Call SendMessage(hChild, WM_CHAR, vbKeyA, 0)
End Sub
-
Aug 17th, 2000, 09:49 AM
#5
Thread Starter
New Member
I didn't exactly know if I had to use the parent window,
now it's ok for me.
Thank for your help.
-
Aug 17th, 2000, 10:50 AM
#6
Specifing the parent window will narrow it down. If you don't specify the parent window, it will just use desktop window.
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
|