Author Topic: Can't change RichEdit Color  (Read 3406 times)

peaslee

  • Guest
Can't change RichEdit Color
« on: May 30, 2012, 01:05:44 PM »
I can't get the background color of my RichEdit controls to turn red. The controls are created (in a nice, pretty gray).

Code: [Select]
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

  • Member
  • **
  • Posts: 93
Re: Can't change RichEdit Color
« Reply #1 on: May 30, 2012, 09:16:01 PM »
Hi,

you must set a COLORREF value in lParam.

Code: [Select]
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
Code: [Select]
Invoke SendDlgItemMessage, hDlg, eax, EM_SETBKGNDCOLOR, 0, 000000FFh

Regards
Greenhorn

xandaz

  • Member
  • **
  • Posts: 91
  • I luv you babe
Re: Can't change RichEdit Color
« Reply #2 on: May 30, 2012, 09:47:13 PM »
    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

  • Member
  • **
  • Posts: 91
  • I luv you babe
Re: Can't change RichEdit Color
« Reply #3 on: May 30, 2012, 10:17:48 PM »
   well here's a working code.... thanks for letting me help you. Like i said ...SendMessage....

xandaz

  • Member
  • **
  • Posts: 91
  • I luv you babe
Re: Can't change RichEdit Color
« Reply #4 on: May 30, 2012, 11:11:37 PM »
    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

  • Guest
Re: Can't change RichEdit Color
« Reply #5 on: May 31, 2012, 01:44:37 AM »
   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

  • Member
  • **
  • Posts: 91
  • I luv you babe
Re: Can't change RichEdit Color
« Reply #6 on: May 31, 2012, 02:28:23 AM »
   so...it was none of thethings i mentioned. felt goodto help... anytime.