|
-
Nov 15th, 2001, 03:45 PM
#1
Thread Starter
Member
Easy, But Till Today None Has Been Able To Solve
i have a real problem...
what i want to do sounds pretty simple but just never happens... it has to do with the SetWindowText(api)
i have an .exe running which contains a textbox which has "Text1" as the text inside it.(you can make a simple form with a textbox and save it as an .exe)
NOW i have a VB form running who on loading finds this .exe's handle and uses it to change its titlebar text through the help of the SetWindowText(api).
Next i find out the handle of the textbox inside that .exe and try to change its text i.e "Text1" .... but.... BANG!!!...
NOTHING HAPPENS?????
the textbox's text ("Text1") never changes no matter what????
the return value of the API is also a non 0 ... which says operation successful...
please help me i just cant get what i am missing over here...
how do i change the Text of a text box from another seperately running program which is independent of the first?????????
[email protected]
-
Nov 15th, 2001, 04:37 PM
#2
Lively Member
use one of the SendMessage API's... using the WM_SETTEXT constant...
-
Nov 15th, 2001, 08:53 PM
#3
Theoritically what you posted should work. Post the code you are using.
-
Nov 16th, 2001, 01:33 AM
#4
Conquistador
VB Code:
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 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 Form_Load()
Dim myProjHandle As Long 'Handle to the project
Dim myTextHandle As Long 'Handle to the textbox
Dim wintext As String ' sets the new text
Dim retval As Long ' return value of mess
myProjHandle = FindWindow("ThunderRT6FormDC", "Form1")
myTextHandle = FindWindowEx(myProjHandle, 0, "ThunderRT6TextBox", "Text1")
wintext = "My New Text"
retval = SendMessage(myTextHandle, WM_SETTEXT, ByVal CLng(0), ByVal wintext)
End Sub
'A vb's compiled form class:
'ThunderRT6FormDC
'A vb's compiled textbox class:
'ThunderRT6TextBox
Try that
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
|