News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Easy question about RichEdit control

Started by lingo, October 17, 2008, 02:52:14 PM

Previous topic - Next topic

lingo

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






jj2007

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

lingo