Skip to content

Sending text to pal without clearing current text by Chike

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #187848
    autopilot
    Member

    This is thanks to Chike:

    To get the current typed text use the following:

    'disable editing, may not be needed
    Call EnableWindow(RichEdit20AHnd, 0)
    'Copy Text that has been typed in if any
    txt_len& = SendMessage(RichEdit20AHnd, WM_GETTEXTLENGTH, 0, 0)
    If txt_len& > 0 Then ' don't need all this if user not typing
    ' save user selection / cursor position
    Call SendMessage(RichEdit20AHnd, EM_GETSEL, ByVal VarPtr(start_pos&), ByVal VarPtr(end_pos&))
    ' select all text and cut
    res = SendMessage(RichEdit20AHnd, EM_SETSEL, 0, ByVal txt_len&)
    res = SendMessage(RichEdit20AHnd, WM_CUT, 0, 0)
    End If`
    Insert your code to send text to pal room... May look like the following:` 'Send Text to room
    Call SendMessageByString(RichEdit20AHnd, WM_SETTEXT, 0&, Text1.Text)
    Call SendMessage(RichEdit20AHnd, WM_KEYDOWN, 13, 0)`
    Then restore the user text with the following:` 'Send any typing back to box
    If txt_len& > 0 Then
    ' text box is empty, paste saved text
    res& = SendMessage(RichEdit20AHnd, WM_PASTE, 0, 0)
    ' restore selection / cursor position
    res& = SendMessage(RichEdit20AHnd, EM_SETSEL, start_pos&, ByVal end_pos&)
    End If
    'enable editing
    Call EnableWindow(RichEdit20AHnd, 1)

    Again Thank you Chike

    #187852
    Departure
    Member

    yes very good, After a few little modifycations to the code it works perfect, thank you and i’ll proberly use this in any new programs I do..

    #187851
    jimmyng
    Member

    cannot get it wok

    child = FindWindowEx(parent, 0, "WTL_SplitterWindow", vbNullString)
    child = FindWindowEx(child, 0, "WTL_SplitterWindow", vbNullString)
    child = FindWindowEx(child, 0, "WTL_SplitterWindow", vbNullString)
    child = FindWindowEx(child, 0, "WTL_SplitterWindow", vbNullString)
    
    alt = GetWindow(child, GW_Child)
    
    alt = GetWindow(alt, GW_HWNDNEXT)
    
    alt = FindWindowEx(alt, 0, "AtlAxWin71", vbNullString)
    alt = FindWindowEx(alt, 0, "#32770", vbNullString)
    
    rich20 = FindWindowEx(alt, 0, "RichEdit20A", vbNullString)
    rich20 = FindWindowEx(alt, rich20, "RichEdit20A", vbNullString)
    
    Call SendMessageSTRING(rich20, WM_SETTEXT, 0&, Text$)
    Call SendMessageLong(rich20, WM_KEYDOWN, 13, 0&)

     

    please help

    #187850
    Chike
    Member

    Sould be simple. However depending on how SendMessage is defined it may require some changes, and of course you need to define EnableWindow and maybe some other constants.

    #187849
    AhFox
    Member

    Very nice … thanks … works like charm !

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.