I have two questions about the rich edit control:
  • I use the EM_STREAMIN message to add RTF content to the control and this works fine, but the problem is that the whole text is selected when finished and that the cursor is at the end of the text. Of course I can change the current position but this didn't work. This is what I have:
    
    ..in WM_CREATE handler....
       invoke	SendMessage, hAboutRichEdit, EM_STREAMIN, SF_RTF, ADDR RichEditStream
       invoke	SendMessage, hAboutRichEdit, EM_SETSEL, 0, 0
    ....
    
    But the second message has no effect. It seems like the first SendMessage returns before it has finished streaming the data, but how can it return the number of bytes added then (according to the docs)? When I place the second message in a button handler or something it works fine, so I think it's executed too soon. How do I fix this?
  • Is it possible to create a rich edit that allows no selection, with a hidden cursor, but with scrollbars? Disabling the window grays the background and I don't want that, besides it blocks the scroll bars. So it should look like a static text control, with scrollable text but no selections allowed. Thanks, Thomas
  • Posted on 2001-05-09 12:05:00 by Thomas
    try using a -1 in the wParam of EM_SETSEL. ie:
    
    invoke   SendMessage, hAboutRichEdit, EM_SETSEL, -1, 0
    
    that should deselect any text. for your other question, you could set it as read-only, but you'd probably have to subclass it to get it to stop selecting and to hide the caret.
    Posted on 2001-05-09 16:00:00 by Sloat
    It doesn't work either with -1, it does work if the sendmessage is called later, but not immediately after the streaming.
    Posted on 2001-05-09 16:14:00 by Thomas
    hmm... add a nop instruction (or maybe a couple) after the EM_STREAMIN message. if that doesn't work, try using EM_SETTEXTEX instead. other than that, i have no idea.
    Posted on 2001-05-09 17:25:00 by Sloat
    This works for me in a much simpler application: EditClassName db "EDIT", 0 EditID equ 2 invoke CreateWindowEx,WS_EX_CLIENTEDGE, ADDR EditClassName,NULL,\ WS_CHILD or WS_VISIBLE or WS_VSCROLL or WS_MAXIMIZE or\ ES_LEFT or ES_AUTOVSCROLL or ES_MULTILINE \ or ES_READONLY, \ 0, 0, cWidth, cHeight,\ hWnd,EditID,hInst,NULL invoke SendMessage, hwndEdit, EM_SETSEL, -1, -1 ;position to end of text invoke SendMessage, hwndEdit, EM_REPLACESEL, TRUE, ADDR bunotice ;insert new text Good Luck, Farrier
    Posted on 2001-05-10 00:58:00 by farrier