How can I ensure the cursor is positioned at the end of the text in a RTF-Control? In an Text-Box I tried the code below and it works fine. But these FF-functions aren't available for the RTF-control. Thanks a lot for any help.
Christoph Embacher
'--------------------------------------------------------------------------------
Function FRMMAIN_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
Local sTemp As String
Local lCount As Long
Local i As Long
sTemp = FF_ClipboardGetText
FF_TextBox_SetText (HWND_FRMMAIN_TEXT1, stemp)
lcount = FF_TextBox_GetLineCount (HWND_FRMMAIN_TEXT1)
For i =1 To lcount
FF_TextBox_Scroll (HWND_FRMMAIN_TEXT1, %SB_LINEDOWN)
Next
FF_TextBox_SetSel (HWND_FRMMAIN_TEXT1, Len(sTemp), Len(sTemp))
End Function
'--------------------------------------------------------------------------------
I tried your code on a rtf sample test project and it positioned the cursor correctly at the end of the text. Actually, there should be no need to use the FF_TextBox_Scroll for/next loop because the richedit control should automatically scroll the cursor into view when you set the position via FF_TextBox_SetSel (I think).
The FF_TextBox_SetSel function uses an internal SendMessage call to the control using the %EM_SETSEL winapi message. The winapi help for that message states:
"The EM_SETSEL message selects a range of characters in an edit control. You can send this message to either an edit control or a rich edit control.
Thank you, Paul, you are right. I didn't know, that I could use thr FF-TextBox-functions in the same way for the rtf-control.