Re: [WIN] change bkgnd color of combo box
Matt,
Well, I don't really have much idea what it is you're doing in your example,
but I'm game to try & understand it. To get it to run I had to change some
things, not sure if that defeated any chance of it doing what I wanted or
not.
In "trackObject", I changed "getSelf()" to "Win" because it brought up an
error the original way, not sure what, it's over 300 lines :( with Win32Lib
50.
Had to comment out "return brush" in the event trap(?), because brush not
declared; was that supposed to relate somehow to "myBrush" (didn't work when
I put that there), or get something from iMsg, or what??
And I added "WinMain".
Can you give me an idea what is supposed to be going on in your example?
Dan
P.S.:
Here's what it looks like after I made those changes:
-- begin code
include win32lib.ew
global 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(Win, CB, ForProgram )--CHANGED getSelf()TO Win BECAUSE ERROR'D
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 -- HAD TO COMMMENT THIS OUT TO GET PROGRAM TO RUN
end if
end procedure
-- you may have to change this to Win's event handler...
onEvent[CB] = routine_id("CB_onEvent")
WinMain( Win, Normal )-- ADDED THIS
-- end code
----- Original Message -----
From: "Matt Lewis" <matthewwalkerlewis at YAHOO.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Tuesday, October 24, 2000 8:55 PM
Subject: Re: [WIN] change bkgnd color of combo box
> --- 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/
|
Not Categorized, Please Help
|
|