|
-
Feb 5th, 2000, 03:03 PM
#1
Thread Starter
Addicted Member
Does a window's handle change everytime the parent window is closed and opened?
I have a "hWnd spy" program, that informs me of a specific window's hWnd. However when a program is closed and then lauched again it's hWnd and all child hWnd's are different.
Now either the "hWnd Spy" program is either providing me false information or my suspicions concerning hWnd's changing, is true. Can anyone end my madness and kindly tell me the answer, please and thanks?
p.s. If hWnd's do periodically change, How can I make my program get the handle of a specific window? (I know this is asking a lot )
Daniel Christie
-
Feb 5th, 2000, 04:16 PM
#2
Window Handles do change every time a Window is Created, you can find the Window Handle using the API FindWindowEx().
You can Pass a Window Caption or Class, you can also search within other Windows, in the case of searching for a Textbox for example, ie.
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_SETTEXT = &HC
Private Sub Command1_Click()
Dim sText As String
Dim lHwnd As Long
lHwnd = FindWindowEx(0, 0, "3rdPartyAppClass", vbNullString)
lHwnd = FindWindowEx(lHwnd, 0, "Edit", vbNullString)
sText = Text1
Call SendMessage(lHwnd, WM_SETTEXT, Len(sText), ByVal sText)
End Sub
Where 3rdPartyAppClass is the Classname of the 3rd Party App and Edit is the Classname for a Standard Windows Textbox.
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
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
|