|
-
August 23rd, 2001, 09:12 AM
#1
The PostMessage function... Sending Text to a Box
Hello,
This is probably a very simple solution... but of course it isn't simple if you don't know it. 
I'm currently using the API Declare function PostMessage() to click existing Buttons on another application. I'm doing this by getting their Parent Window Handle and then the Button Handle with that by using FindWindowEx()
Here's a sample of how I'm doing this... maybe it will help someone out.
' Excerpt from function
MyWind3 = FindWindowEx(MyWind2, 0, vbNullString, "MyWindow") '
If MyWind3 <> 0 then 'Could be...
'looking for the Ok button
MYWind4 = FindWindowEx(MyWind3, 0, vbNullString, "OK")
If MyWind4 <> 0 then 'Found it
ClickButtonWithHwnd (MyWind4)
End If
End If
' End Excerpt
public Sub ClickButtonWithHwnd(byval Hwnd as Long)
' Quite a few API declarations are here... sorry for not including them.
Dim Button as Long
Dim ParentHwnd as Long
Dim tmpHwnd as Long
Dim X as Integer
Button = GetDlgCtrlID(Hwnd)
ParentHwnd = GetParent(Hwnd)
tmpHwnd = GetActiveWindow
X = SetForegroundWindow(ParentHwnd)
'This Type of command I know works...
X = PostMessage(ParentHwnd, WM_COMMAND, Button, BN_CLICKED * &H10000 + Hwnd)
X = SetForegroundWindow(tmpHwnd)
End Sub
Anyways, I now want to put some text into a textbox on another application's window by using the same method and PostMessage. I don't know the Message type for Textboxes and MSDN seems to have a type for all controls except for that one.
Does anyone have a complete list of these Message Types and better yet can anyone provide me with an example of how to do a text writing using the PostMessage function?
Thanks everyone!
Ron D.
This request or reply is sponsered by:
Coffee -- the breakfast of champions!
-
August 23rd, 2001, 11:12 AM
#2
Re: The PostMessage function... Sending Text to a Box
Try to use SendMessage API instead of PostMessage
Call SendMessage(HWnd, WM_SETTEXT, 0, ByVal "YourText")
where HWnd is a handle of the window(text box) where you send the message
Iouri Boutchkine
[email protected]
-
August 27th, 2001, 01:53 PM
#3
Re: The PostMessage function... Sending Text to a Box
Thank you.. thank you. This does work. However, I ran into a problem where it is impossible to do what I said I was going to do. It turns out the application's textbox I was going to send all this wonderful text to doesn't have a handle! :P What a bummer. Thanks for the help though.
Ron D.
This request or reply is sponsered by:
Coffee -- the breakfast of champions!
-
August 27th, 2001, 02:05 PM
#4
Re: The PostMessage function... Sending Text to a Box
Not sure of your entire situation, but if you're also doing the coding on the "reciever" application you could put a hidden textbox that does have a hWnd on the form and send it the text. Then add the appropriate code to send it to the real textbox... Just a though....
-
August 27th, 2001, 02:18 PM
#5
Re: The PostMessage function... Sending Text to a Box
Don't I wish I had control of the code for the other app... this would put to rest a mile long list of control issues I have with it. Unfortunately, I do not. Thanks for the tip though.
Ron D.
This request or reply is sponsered by:
Coffee -- the breakfast of champions!
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
|