News:

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

How to underline words in EditBox

Started by MFTM, July 27, 2009, 08:50:44 PM

Previous topic - Next topic

MFTM

I have no ideas how to underline words in Edit (or RichEdit) & to make menu, like SpellCheck, well, i need somthing like:



DrawError PROC lpszWord:DWORD,iChar:DWORD,CURDC:DWORD
LOCAL iY:DWORD
LOCAL strLen:DWORD
LOCAL rect:RECT
LOCAL rc:RECT
LOCAL OldPen:HPEN
LOCAL OldBrush:HBRUSH
mov iY, 0
invoke GetWindowDC,hEdit
mov hEditDC, eax
INVOKE SendMessage, hEdit, WM_GETFONT, 0, 0

mov hFont, eax
    INVOKE GetObject, eax, SIZEOF LOGFONT, ADDR OldFont
    invoke SelectObject,hEditDC,hFont
   


invoke StrLen, lpszWord
mov strLen, eax
invoke GetTextExtentPoint,hEditDC,lpszWord,strLen,addr szWord

mov eax, szWord.cyy
mov iY, eax

invoke SendMessage,hEdit,EM_POSFROMCHAR,iChar,0
mov ecx, eax
and ecx,0FFFFh
mov rect.left, ecx
shr eax, 16
mov rect.top, eax

add iY, eax
invoke GetClientRect,hEdit,addr rc
mov eax, iY
.if eax<rc.bottom
invoke DrawSquiggly,hEditDC,rect.right,szWord.cxx,iY
.endif

ret
DrawError endp

DrawSquiggly PROC CDC:HDC,iLeftX:DWORD,iWidth:DWORD,iYY:DWORD
LOCAL iCurrentY:DWORD
LOCAL iCurrentX:DWORD
LOCAL BRUSH1:HBRUSH
LOCAL OldPen:HPEN

mov eax, iYY
mov iCurrentY, eax

mov eax, iLeftX
mov iCurrentX, eax

; invoke CreateSolidBrush,000000FFh;;
; mov BRUSH1, eax

invoke CreatePen,PS_DOT ,1,0000FFh
mov OldPen, eax

invoke SelectObject,hEditDC,OldPen

mov eax, iCurrentX
sub eax, 20
inc iYY
invoke MoveToEx,hEditDC,eax,iYY,NULL
mov eax, iCurrentX
add eax, iWidth
invoke LineTo,hEditDC,eax,iYY

invoke SelectObject,hEditDC,oldPen

ret

DrawSquiggly endp


Maybe someone has an example?  ::)

jj2007

A normal edit control cannot do that - you need RichEdit. Here are some elements for googling MSDN.

  LOCAL charfmt:CHARFORMAT2
invoke SendMessage, hRichEdit, EM_GETCHARFORMAT, SCF_SELECTION, ADDR charfmt
...
invoke SendMessage, hRichEdit, EM_SETCHARFORMAT, SCF_SELECTION, ADDR charfmt
  ret