Results 1 to 4 of 4

Thread: Easy, But Till Today None Has Been Able To Solve

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2001
    Posts
    32

    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]

  2. #2
    Lively Member
    Join Date
    Aug 2001
    Posts
    109
    use one of the SendMessage API's... using the WM_SETTEXT constant...

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    Theoritically what you posted should work. Post the code you are using.

  4. #4
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. 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
    3. 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
    4. Private Const WM_SETTEXT = &HC
    5. Private Sub Form_Load()
    6. Dim myProjHandle As Long 'Handle to the project
    7. Dim myTextHandle As Long 'Handle to the textbox
    8. Dim wintext As String  ' sets the new text
    9. Dim retval As Long  ' return value of mess
    10. myProjHandle = FindWindow("ThunderRT6FormDC", "Form1")
    11. myTextHandle = FindWindowEx(myProjHandle, 0, "ThunderRT6TextBox", "Text1")
    12. wintext = "My New Text"
    13. retval = SendMessage(myTextHandle, WM_SETTEXT, ByVal CLng(0), ByVal wintext)
    14. End Sub
    15.  
    16. 'A vb's compiled form class:
    17. 'ThunderRT6FormDC
    18.  
    19. 'A vb's compiled textbox class:
    20. '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
  •  



Click Here to Expand Forum to Full Width