|
-
Aug 15th, 2000, 08:44 AM
#1
Thread Starter
Fanatic Member
I thought I got it but I don't
I have an app with the form caption "Clock Data" and a text box in that app called txtClock.
how can I send a message from one app to that text box
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 15th, 2000, 08:54 AM
#2
Use FindWindowEx to get the hWnd of a child window.
Code:
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 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 Sub Command1_Click()
Dim hParent As Long
Dim hChild As Long
'Get the hWnd of the parent window
hParent = FindWindow(vbNullString, "Clock Data")
'Get the hWnd of the child window. If Clock Data is a Visual C++ app, then
'change ThunderTextBox to Edit
hChild = FindWindowEx(hParent, 0&, "ThunderTextBox", vbNullString)
'Send a message to the TextBox
SendMessage hChild, MyMessage, 0, 0
End Sub
-
Aug 15th, 2000, 09:28 AM
#3
Thread Starter
Fanatic Member
so in the place of thundertext box I type
"txtClock"
- i would just try it but i'm not at work
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 15th, 2000, 09:38 AM
#4
No, ThunderTextBox is the ClassName for the TextBox. Likewise, Visual C++ uses a TextBox with the ClassName of Edit. If this program (Clock Data) was made in Visual Basic, then leave it at ThunderTextBox.
PS: is txtClock the only TextBox on the Form?
-
Aug 15th, 2000, 11:07 AM
#5
Thread Starter
Fanatic Member
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 15th, 2000, 11:13 AM
#6
No problem, Just make the search more specific. Enter the text of the TextBox for the last argument in FindWindowEx,
-
Aug 15th, 2000, 11:19 AM
#7
Thread Starter
Fanatic Member
Can I use a label as well as a text box?
------------------
this is what it looks like then...
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 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 Sub Command1_Click()
Dim hParent As Long
Dim hChild As Long
'Get the hWnd of the parent window
hParent = FindWindow(vbNullString, "Clock Data")
'Get the hWnd of the child window. If Clock Data is a Visual C++ app, then
'change ThunderTextBox to Edit
hChild = FindWindowEx(hParent, 0&, "ThunderTextBox", "txtClock")
'Send a message to the TextBox
SendMessage hChild, MyMessage, 0, 0
End Sub
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 15th, 2000, 11:33 AM
#8
Is txtClock the actual name of the clock? You must enter the Text that's in txtClock. for example, it could be 12:00, so you would change it to
Code:
hChild = FindWindowEx(hParent, 0&, "ThunderTextBox", "12:00")
-
Aug 15th, 2000, 12:32 PM
#9
Thread Starter
Fanatic Member
OH,
so it looks for the text in all the text boxes and inserts into the one that matches
Kurt Simons
[I know I'm a hack but my clients don't!]
-
Aug 15th, 2000, 12:55 PM
#10
Yes. It will look through each instance of the ThunderTextBox class (in their ZOrder) and see if text matches. If so, it will return the hWnd of that window.
-
Aug 16th, 2000, 08:33 AM
#11
Thread Starter
Fanatic Member
Thanks a bundle...
I have a program that has a running clock and its going to update another program, It will change the text boxes text which will call the change event. I guess I'll set the text boxes property back to "<CLOCK>" or something so it always finds it.
QUESTIONS
what happens is the program is busy doing a query or something will it respond to the change event.
Does the sending programs freeze until it has been updated (this is what i am trying to avoid)
Kurt Simons
[I know I'm a hack but my clients don't!]
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
|