Re: buttons...

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hi,

For this you're best off just drawing the button. ie use owner-drawn
buttons, the problem with global classes is that u can never get the perfect
time to paint them. below is an example that shows how to make owner drawn
buttons. u are responsible for drawing the border(use DrawEdge)
---------------------------------------------------------
--File   : Owner Drawn Button
--Version: 0.0.1
--Date   :
--Author : Jordah Ferguson
---------------------------------------------------------

include win32lib.ew

constant
    BS_OWNERDRAW        = #0000000B,
    WM_DRAWITEM         = #002B,
    ODT_BUTTON          = 4

constant
   xPatBlt =
registerw32Function(gdi32,"PatBlt",{C_LONG,C_LONG,C_LONG,C_LONG,C_INT,C_INT}
,C_INT)

-- DRAWITEMSTRUCT Structure
constant
    CtlType      = 00,
    CtlID        = 04,
    itemID       = 08,
    itemAction   = 12,
    itemState    = 16,
    hwndItem     = 20,
    hDC          = 24,
    RECT_top     = 28,
    RECT_left    = 32,
    RECT_right   = 36,
    RECT_bottom  = 40,
    itemData     = 44

constant
    Win = create(Window,"Owner drawn Button
example",0,Default,Default,100,100,0),
    Btn = create(Button,"Renzo",Win, 20,20,120,25,BS_OWNERDRAW )

constant
  clrs = {BrightRed,BrightBlue,BrightGreen,Red,Blue,White,Yellow},
  pushed = Gray


atom HDC,junk,Brush,OldBrush,lParam

-------------------------------------------
procedure w32HEven_Paint(atom id,atom event,sequence params)
-------------------------------------------
   if params[1] = WM_DRAWITEM then
      lParam = params[3]
      if peek4u(lParam + CtlType) = ODT_BUTTON then
         HDC = peek4u(lParam+hDC)
         if HDC then
             Brush = w32Func(xCreateSolidBrush,{clrs[rand(length(clrs))]})
             OldBrush = w32Func(xSelectObject,{HDC,Brush})
             junk = w32Func(xPatBlt,{HDC,peek4u(lParam + RECT_top),
                    peek4u(lParam + RECT_left),   peek4u(lParam +
RECT_right),
                                     peek4u(lParam + RECT_bottom),
                                     PATCOPY})
             junk = w32Func(xDeleteObject,{Brush})
             junk = w32Func(xReleaseDC,{getHandle(Btn),HDC})
         end if
         returnValue(1)
      end if
   end if
end procedure
setHandler(Win,w32HEvent,routine_id("w32HEven_Paint"))


WinMain(Win,Normal)

==========================
Enjoy!
Jordah Ferguson
----- Original Message -----
From: <Patrick.Barnes at transgrid.com.au>
To: "EUforum" <EUforum at topica.com>
Sent: Wednesday, December 11, 2002 1:11 AM
Subject: buttons...


>
> How do I make a button's background a different color?
> =======================
> Patrick Barnes
> Information Systems Group
> 201 Elizabeth St, Sydney
> Patrick.Barnes at tg.nsw.gov.au
> Ext: 91-3583
> Ph:(02) 9284-3583
> Mob: 0410 751 044
>
>
> ***********************************************************************
>
>
> ***********************************************************************
>
>
>
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu