|
-
Feb 11th, 2000, 11:51 AM
#1
Thread Starter
Addicted Member
I am trying to send text to a specific 3rd party program's textbox. The 3rd party program
has many textboxes all using the same
window Classname "Edit". This is telling me that they are setup as an array. So it
sounds like they can be targeted by Edit(index#). Is this true? If so how do I code this?
In otherwords If I know the parent's hWnd and I know the class name for the textbox is
"Edit", is it possible to target the specific textbox by it's index?
I really need to know. I have been trying to send text to the specific textbox for around a
week now, using differnt suggested methods but to no avail.
Thank you very much,
Daniel Christie
-
Feb 11th, 2000, 12:23 PM
#2
"Edit" is the Classname, which is like the Object Type, the only way to get to the Textbox you're after is to use a Program like Spy++ and see in which order they are listed, then you can use the FindWindowEx API to find the one you're after using the method I showed you in your previous Post.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
Feb 11th, 2000, 03:35 PM
#3
Thread Starter
Addicted Member
Aaron,
I appreciate all your help.
My biggest problem is, I do not have VS6.0 therefore I don't have Spy++. I do have vb5 and a program called WinSpy. Actually it was unfinished source code and I finished it. It lists the parent and child's handles, classnames, WindowIDs, Window Styles, and Window text. But not which order they are listed 
Do you think you could do one more favor and email Spy++ to me or provide me a URL so I may D/L it?
Thanks,
Daniel Christie
[email protected]
-
Feb 11th, 2000, 04:01 PM
#4
Spy++ is Copyrighted and it's Illegal to distribute it without MS's consent, but, I have put together a really basic Spy-Like program for you.
Just trag the Picturebox Image Over the Window and it will List all Child Windows, (i.e Textboxes, etc), with their Class Name and Handles in Order, so Just point to the Control you want and you'll be able to see which position in the collection it is in.
In a Module...
Code:
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type POINTAPI
X As Long
Y As Long
End Type
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function InvertRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long) As Long
Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Const RGN_XOR = 3
Public Const VK_LBUTTON = &H1
Public lItem As Long
Public Function EnumChildProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sCaption As String * 255
Form1.List1.AddItem "&H" & Right$("00000000" & Hex$(hwnd), 8) & " - " & Chr(34) & Left$(sCaption, GetClassName(hwnd, sCaption, 255)) & Chr(34)
If Form1.Caption = Form1.List1.List(Form1.List1.NewIndex) Then lItem = Form1.List1.NewIndex
EnumChildProc = hwnd
End Function
In a Form with a Picturebox and a Listbox and a Timer Control..
Code:
Private lRgn As Long
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 100
Screen.MouseIcon = LoadPicture("..\Common\Graphics\Cursors\Bullseye.cur")
Picture1 = Screen.MouseIcon
Picture1.AutoSize = True
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
lRgn = 0
Screen.MousePointer = vbCustom
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static lLastHwnd As Long
Dim tPOINT As POINTAPI
Dim tRECT As RECT
Dim lHwnd As Long
Dim lDC As Long
Dim lRgn1 As Long
Dim lRgn2 As Long
Dim sClass As String * 255
If GetAsyncKeyState(VK_LBUTTON) = 0 Then
Timer1.Enabled = False
lDC = GetDC(0)
Call InvertRgn(lDC, lRgn)
Screen.MousePointer = vbDefault
Exit Sub
End If
Call GetCursorPos(tPOINT)
lHwnd = WindowFromPoint(tPOINT.X, tPOINT.Y)
If lLastHwnd = lHwnd Then Exit Sub
lLastHwnd = lHwnd
Caption = "&H" & Right("00000000" & Hex(lHwnd), 8) & " - " & Chr(34) & Left$(sClass, GetClassName(lHwnd, sClass, 255)) & Chr(34)
'
List1.Clear
lItem = -1
Call EnumChildWindows(IIf(GetParent(lHwnd), GetParent(lHwnd), lHwnd), AddressOf EnumChildProc, 0&)
If lItem > -1 Then List1.ListIndex = lItem
'
lDC = GetDC(0)
Call InvertRgn(lDC, lRgn)
Call GetWindowRect(lHwnd, tRECT)
lRgn = CreateRectRgn(0, 0, 1, 1)
lRgn1 = CreateRectRgn(tRECT.Left, tRECT.Top, tRECT.Right, tRECT.Bottom)
lRgn2 = CreateRectRgn(tRECT.Left + 3, tRECT.Top + 3, tRECT.Right - 3, tRECT.Bottom - 3)
Call CombineRgn(lRgn, lRgn1, lRgn2, RGN_XOR)
Call InvertRgn(lDC, lRgn)
Call ReleaseDC(0, lDC)
End Sub
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
Feb 11th, 2000, 04:19 PM
#5
Thread Starter
Addicted Member
"Compile error-
Method or Data member not found"
tRECT.Top
.Top was highlighted
?
-
Feb 11th, 2000, 04:23 PM
#6
Everything's there, you shouldn't get any Errors, did you Cut and paste everything and into the Right places?
I tried with a New Project and Pasted the Code I posted and it worked.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
Certified AllExperts Expert
-
Feb 11th, 2000, 05:02 PM
#7
Thread Starter
Addicted Member
Sorry I forgot to tell you that I got it working fine, (re-cut n pasted).
I thank you for your generosity.
Daniel Christie
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
|