How to - Find Handle of each Rich Text Box on a form
Hello All,
Hope you can help?
I am trying to pass text from one form to another. On the target form I have two RichTextBoxes ( named RichTextBox1 and RichTextBox2 ). Now I can pass text ok to one of them ( I guess the first in the handle list ) but don't know how to specify each one individually. Do you know what I need to do?
Code below, thanks,
Public Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long
Public Const WM_SETTEXT = &HC
Public 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
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Re: How to - Find Handle of each Rich Text Box on a form
Before you start sending text to app2, set the focus of the proper RTB. Using RTB.SetFocus
You could send a window message to WM_SETFOCUS or use API SetFocus.
Re: How to - Find Handle of each Rich Text Box on a form
The problem sounds more like he doesn't have the handle of richtextbox2. Setting focus is really not an issue as I can send messages to any textbox (regular or rich) on another app without setting the focus.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
Re: How to - Find Handle of each Rich Text Box on a form
Download zip file. Compile and run App1 and App2. Make sure App2 is running. Click on Get Objects From App2 button then click on the other two buttons.
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.