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:
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.
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?
..in WM_CREATE handler.... invoke SendMessage, hAboutRichEdit, EM_STREAMIN, SF_RTF, ADDR RichEditStream invoke SendMessage, hAboutRichEdit, EM_SETSEL, 0, 0 ....
try using a -1 in the wParam of EM_SETSEL. ie:
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.
invoke SendMessage, hAboutRichEdit, EM_SETSEL, -1, 0
It doesn't work either with -1, it does work if the sendmessage is called later, but not immediately after the streaming.
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.
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