Re: [WIN] change bkgnd color of combo box
- Posted by Matt Lewis <matthewwalkerlewis at YAHOO.COM> Oct 24, 2000
- 465 views
--- Dan B Moyer <DANMOYER at PRODIGY.NET> wrote: > but I don't know how to "trap" the WM_CTLCOLOR message. Can you give me a > small example? OK, this should get you started. You need to create an onEvent procedure for the parent of the combo (I think--the parent of the list box gets the message, and I'm not certain if the combo or the combo's parent gets it). Once you've done that, you need to return the handle to a brush. So (untested): -- begin code include win32lib.ew constant Win = create(Window,"Custom Combo", 0, 20, 20, 300, 300, 0), CB = create( Combo,"", Win, 20, 20, 90, 180, 0 ) addItem(CB, "One" ) addItem(CB, "Two" ) addItem(CB, "Etc..." ) constant myColor = #0, -- an rgb value here myBrush = c_func( xCreateSolidBrush, { myColor } ) -- This might not be such a great idea. You might -- be better off creating and destroying the pen -- each time you draw the list box, although -- if this works, it's probably faster. -- If you move this to within the event code, -- you'll need to change ForProgram to ForPaint trackObject( getSelf(), CB, ForProgram ) procedure CB_onEvent( integer iMsg, atom wParam, atom lParam ) -- Win9x uses specific msgs now instead of WM_CTLCOLOR -- with a notification if iMsg = WM_CTLCOLORLISTBOX then return brush end if end procedure -- you may have to change this to Win's event handler... onEvent[CB] = routine_id("CB_onEvent") -- end code Other messages you might be interested in (which should work the same as WM_CTLCOLORLISTBOX): WM_CTLCOLOREDIT WM_CTLCOLORSCROLLBAR WM_CTLCOLORBTN WM_CTLCOLORSTATIC These should all be defined for you in winconst.ew (in the archives--by Jaques D). Now that I've looked at these, I think they should probably be incorporated into Win32Lib, to enable more flexible color schemes. ===== Matt Lewis http://www.realftp.com/matthewlewis __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/