Results 1 to 23 of 23

Thread: send message problem

Threaded View

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Resolved send message problem

    i am doing a small project that i would like to send a string from a list box and an option "enter" to the next top window, similar to the program in http://www.vbforums.com/showthread.php?t=316373.

    my problems are, when i try to get the hwnd for the target program several have a zreo value, ones that i get a value for do not get the value for the textbox or other control where i want the message to go (i have been using apispy to check the correct value).

    if i hard code the hwnd for the control i can send message, but it is not correct

    i have an array of list boxes wish to send the listbox text to the control that has focus on the applicaton then return to select another item.


    VB Code:
    1. Private Const WM_COPY = &H301
    2. Private Const WM_PASTE = &H302
    3. Private Const WM_SETTEXT As Long = &HC
    4.  
    5.  
    6. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"_
    7.  (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long,_
    8.  lparam As Any) As Long
    9. Private Declare Function GetActiveWindow Lib "user32" () As Long
    10.  
    11.  
    12.  
    13. Private Sub List1_Click(index As Integer)
    14. Dim newtext As String
    15. newtext = List1(index).Text
    16. Debug.Print Me.hwnd
    17.  
    18. Me.Hide
    19. wind = GetActiveWindow
    20. Debug.Print wind
    21. Me.Show
    22.  
    23.  ' hwind for text box on program i was trying to paste to, detected by apispy
    24. 'wind = 329952
    25.  SendMessage wind, WM_SETTEXT, 0&, List1(index).Text
    26.  
    27. List1(index).SetFocus
    28. End Sub
    Last edited by westconn1; Jan 23rd, 2005 at 05:27 AM.

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