1. Setting the bkgrnd color of a control

Can someone please give me an example of setting the background color of 
controls, using low level win32?

I want to change the color of my mle's and various other controls.

I've looked at win32lib, and it uses SetClassLong(hwnd, 
GCL_HBRBACKGROUND, hbrush) and repaints the window, but I guess I'm 
missing some details, because I can't get it to work.

I've looked into the win32 SDK, and WM_CTLCOLOREDIT supposedly does what 
I want, by returning the new bk brush from the event handler.
But I haven't been successful.

Chris

new topic     » topic index » view message » categorize

2. Re: Setting the bkgrnd color of a control

Hi Chris,

if iMsg = WM_CREATE then
  Editbrush = CreateSolidBrush(16777215) 


    elsif iMsg = WM_CTLCOLOREDIT then
          if lParam = EditContol then
              SetBkColor(wParam, 16777215) 
             return Editbrush
          end if
    elsif iMsg = WM_CTLCOLORSTATIC then
          if lParam = EditControl then
             SetBkColor(wParam, 16777215)
             return Editbrush
          else
             return 0
          end if    
    elsif iMsg = WM_CTLCOLORLISTBOX then
          SetBkColor(wParam, rgb(5, 5, 192))
          return Editbrush

remember this Chris, you have to return the brush itself.......
16777215 is white I think so you'll need to change this to the 
color you want.

WM_CTLCOLORSTATIC is for readonly MLE's
WM_CTLCOLOREDIT  is for non readonly MLE's
WM_CTLCOLORLISTBOX is for the listbox's

actually, SetBkColor(wParam, 16777215) in each of these
is for your next question you might have on the colors of Edit
controls..... just jokin'

Hope it helps,
Euman


----- Original Message ----- 
From: "Chris Bensler" <bensler at mail.com>
To: "EUforum" <EUforum at topica.com>
Sent: Thursday, April 25, 2002 4:23 PM
Subject: Setting the bkgrnd color of a control


> 
> Can someone please give me an example of setting the background color of 
> controls, using low level win32?
> 
> I want to change the color of my mle's and various other controls.
> 
> I've looked at win32lib, and it uses SetClassLong(hwnd, 
> GCL_HBRBACKGROUND, hbrush) and repaints the window, but I guess I'm 
> missing some details, because I can't get it to work.
> 
> I've looked into the win32 SDK, and WM_CTLCOLOREDIT supposedly does what 
> I want, by returning the new bk brush from the event handler.
> But I haven't been successful.
> 
> Chris
> 
> 
> 
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu