I have a rich edit control in an about dialog, but when I add text to it the rich selects the text. I want to get rid of that but I couldn't find out how. A WM_SETSEL immediately after the SETTEXT doesn't work. An ugly version of my code is below (parts of the full code). Can anyone fix it?
bug2.asm
.486
.model flat, stdcall
option casemap:none
includelib d:\masm32\lib\kernel32.lib
includelib d:\masm32\lib\user32.lib
include d:\masm32\include\kernel32.inc
include d:\masm32\include\user32.inc
include d:\masm32\include\windows.inc
DlgProc PROTO STDCALL :DWORD, :DWORD, :DWORD, :DWORD
.data?
hInstance dd ?
hAboutRichEdit dd ?
hRichEditDll dd ?
.data
RichEditDLL db "RichEd20.dll",0
AppName db 'rtftest',0
ClassName db 'rtftestclass',0
ClassRichEdit db "RICHEDIT20A",0
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke LoadLibrary, addr RichEditDLL
mov hRichEditDll,eax
invoke DialogBoxParam, hInstance, 200, 0, offset DlgProc, 0
invoke ExitProcess, NULL
DlgProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
LOCAL tempsettext:SETTEXTEX
mov eax, uMsg
.IF eax==WM_INITDIALOG
invoke CreateWindowEx, NULL, ADDR ClassRichEdit, NULL, WS_CHILD or WS_VISIBLE or ES_READONLY or \
WS_VSCROLL or ES_AUTOVSCROLL or ES_MULTILINE,\
0, 0, 200, 300, hWnd,\
100, hInstance, NULL
mov hAboutRichEdit, eax
invoke FindResource, hInstance, 100, RT_RCDATA
invoke LoadResource, hInstance, eax
invoke LockResource, eax
mov tempsettext.flags, ST_DEFAULT
mov tempsettext.codepage, 1200
invoke SendMessage, hAboutRichEdit, EM_SETTEXTEX, ADDR tempsettext, eax
invoke SendMessage, hAboutRichEdit, EM_SETSEL,0,0h ; WHY DOESN'T THIS WORK?
; wParam=-1, lParam=0 doesn't work either
.ELSEIF eax==WM_CLOSE
invoke EndDialog, hWnd, 0
.ELSEIF eax==WM_DESTROY
invoke EndDialog, hWnd, 0
.ENDIF
xor eax, eax
ret
DlgProc ENDP
end start
bug2.rc
#include
100 RCDATA DISCARDABLE "test.rtf"
200 DIALOG DISCARDABLE 0, 0, 183, 153
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Dialog"
FONT 8, "MS Sans Serif"
BEGIN
END
test.rtf
{\rtf1\ansi\ansicpg1252\deff0\deflang1043{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red128\green0\blue128;}
\viewkind4\uc1\pard\f0\fs20 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0 Test\par
\b test\par
\cf1 test\cf0\b0\par
}
make.bat
@echo off
ml /c /Zi /coff bug2.asm
rc bug2.rc
link /subsystem:windows /DEBUG /DEBUGTYPE:CV bug2.obj bug2.res
pause>nul
ThomasAdd ES_SAVESEL to your RichEdit control.
Ewayne
Great, that did the trick. Thanks a lot!
Thomas