# How do I use Sendmessage API in VB6?



## bradle95 (Jul 27, 2003)

I would like to be able to click a command button and have data in a text box be sent to a text field in another application (non-vb, I have the handle of the application from another example). It appears that the sendmessage api is the way to go, but I've been chasing my tail on how to use it and would appreciate an example. Thanks.


----------



## coderitr (Oct 12, 2003)

First you have to get the handle to the text box on the other application. To do that you'll need to know the resource id of that text box. Once you have the resource id you can use the GetDlgItem( ) function to get the handle. Once you have that use SendMessage( ) to send a WM_SETTEXT message to that window.

http://msdn.microsoft.com/library/?...oxreference/dialogboxfunctions/getdlgitem.asp
http://msdn.microsoft.com/library/?...windowreference/windowmessages/wm_settext.asp


----------

