How can we get the color of a selected text in a rich edit control?
After EM_GETCHARFORMAT I have zero in the field crTextColor
of the CHARFORMAT struc.
The CFE_AUTOCOLOR character effect is NOT specified and the color
of selected text (just one symbol) is different from the color used by
the rich edit control... :wink
This works fine for me.
GetSelCol MACRO ctype:=<0>
ifidn <ctype>, <1>
mov eax, CFM_BACKCOLOR
else
mov eax, CFM_COLOR
endif
call GetTxtCol
EXITM <eax>
ENDM
MsgBox hex$(GetSelCol(0)), hex$(GetSelCol(1)), MB_OK
GetTxtCol proc
LOCAL charfmt:CHARFORMAT2
m2m charfmt.cbSize, sizeof CHARFORMAT2
mov charfmt.dwMask, eax
push eax
invoke SendMessage, hRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, ADDR charfmt
pop eax
.if eax==CFM_COLOR
mov eax, charfmt.crTextColor
.else
mov eax, charfmt.crBackColor
.endif
ret
GetTxtCol endp
Thanks,the problem is solved :wink