News:

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

WM_CTLCOLOREDIT problem

Started by jj2007, May 05, 2010, 03:07:19 PM

Previous topic - Next topic

jj2007

I am stuck with a misbehaving WM_CTLCOLOREDIT handler for a matrix of edit boxes. It should set an edit control's text colour and background, and it does so if I select the editbox by hand.
However, when the whole matrix is being created/updated, the boxes all have the same colours.
All boxes are subclassed and share the same subclassing procedure; the handler is in the main WndProc.

For testing, cells A0, B0, C0 and A1 have colour attributes set. Tab moves to the next cell, Shift Tab to the previous one.


SWITCH uMsg
CASE WM_CTLCOLOREDIT
mov eax, lParam ; the handle to the edit control
.if eax!=hCellShow ; all controls except hCellShow
call seFindHandle ; will always find the correct offset
.if signed ecx>=0
mov ebx, [EditAtts+4*ecx] ; attribute flags
and ebx, 3
.if Zero?
invoke SetTextColor, wParam, 0FF0000h
.else
invoke SetTextColor, wParam, 000FF00h
.endif
invoke SetBkColor, wParam, EditBgrd[4*ebx]
invoke SetBkMode, wParam, TRANSPARENT
inc ccEd
return hBrushes[4*ebx]
.endif
.endif

Ficko

What about doing something like that?:


.const
FGRND db 'FGRND',0
BGRND db 'BGRND',0
BBRUSH db 'BBRUSH',0
....
...
..
.code
...
..
.
mov ecx, [esi].WINDOW.hWnd
invoke GetDlgItem, ecx,id
.if (eax != 0)
xchg eax, edi
invoke SetPropA, edi,offset FGRND,fg
invoke SetPropA, edi,offset BGRND,bg
invoke GetPropA, edi,offset BBRUSH
xchg eax, esi
invoke CreateSolidBrush,bg
invoke SetPropA, edi,offset BBRUSH,eax
.if (esi != 0)
invoke DeleteObject, esi
.endif
invoke InvalidateRect, edi,0,1
.endif

jj2007

#2
Thanks, Ficko. However, I would like to know why the official method doesn't work. Besides, I have to draw 400+ edit controls on the fly...

EDIT: Bug chasing half way successful. Will keep you posted...

qWord

hi jj,
Olly shows me, that you proc past the color red only at start up to SetBkColor. When clicking to on an edit you are passing 0fffffh (white!) to SetBkColor.
FPU in a trice: SmplMath
It's that simple!

jj2007

Thanks qWord. In the meantime, I found the culprit:

Quotecall seFindHandle ; will not always find the correct offset

A bloody stupid bug - seFindHandle called GetFocus instead of using the passed eax...

Now it works. Click into one of the grey row buttons on the left, and the whole row will be displayed yellowish.