News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Can't change RichEdit Color

Started by peaslee, May 30, 2012, 01:05:44 PM

Previous topic - Next topic

peaslee

I can't get the background color of my RichEdit controls to turn red. The controls are created (in a nice, pretty gray).


DrawMap PROC hDlg:HWND

; create rich edit controls for the lots
push   esi
mov    ebx, 0
mov    esi, offset lot
assume esi:ptr LOT
.while ebx < MAXLOTNUMBER
invoke CreateWindowEx, 0, ADDR RichEditClass, NULL,
WS_VISIBLE or WS_DISABLED or ES_MULTILINE or WS_CHILD or WS_BORDER,
[esi].x, [esi].y, [esi].w, [esi].h,
hDlg,
ebx,
hInstance,
0
mov    [esi].hwnd, eax ;this is the handle?
invoke GetDlgCtrlID, [esi].hwnd
.if eax == NULL
invoke MessageBox, NULL, chr$("Get dlg id failure"), chr$("Test"), 0
ret
.endif
Invoke SendDlgItemMessage, hDlg, eax, EM_SETBKGNDCOLOR, 0, 255 ;eax should be OK if the null test above is skipped
add    esi, type LOT
inc    ebx
.endw
assume esi:nothing
pop esi
Ret
DrawMap EndP


I'm getting null for the control ID.

Greenhorn

Hi,

you must set a COLORREF value in lParam.


RGB macro r:REQ,g:REQ,b:REQ
    exitm <( ( ( ( r )  or  ( ( ( g ) )  shl  8 ) )  or  ( ( ( b ) )  shl  16 ) ) ) >
    endm

Invoke SendDlgItemMessage, hDlg, eax, EM_SETBKGNDCOLOR, 0, RGB(255,0,0)

or
Invoke SendDlgItemMessage, hDlg, eax, EM_SETBKGNDCOLOR, 0, 000000FFh


Regards
Greenhorn
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

xandaz

    Greenhorn.... I see a couple of error in your rountine. Are you getting the Control's Id to use in the EM_SETBKGNDCOLOR. You should use the [esi].hwnd. I think that's the problem. Oh and use SendMessage sharp. Another of the errors should be that the RichEditControl should be in the executable as a resource. I'm looking into it as we speak. I'm not a fan of dialogs and need to try some stuff. bbl

xandaz

   well here's a working code.... thanks for letting me help you. Like i said ...SendMessage....

xandaz

    Like i said i'm not a fan of Dialogs mainly because i haven't gotten much into it. After a quick look into i understood that a dialog can't have a name and also an identifier. When this is so, it fails to create. So if you where trying to get identifier from the richedit control there might have been some sort of error. Try changing the dialog's name to 'NULL' and set only the Identifier. Haven't really tried this. It's just a thought. Later

peaslee

Quote from: xandaz on May 30, 2012, 10:17:48 PM
   well here's a working code.... thanks for letting me help you. Like i said ...SendMessage....

Thank you so much. This was driving me crazy. When I examined your code I noticed that you did not have WS_DISABLED in the style parameter. When I removed that, I get a window full of nice red controls.

I really appreciate your taking the time to throw together an example.

Bruce

xandaz

   so...it was none of thethings i mentioned. felt goodto help... anytime.