Announcement

Collapse
No announcement yet.

Colorized background of a Tab Control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Colorized background of a Tab Control

    I'm trying to colorize the background of a tab control (NOT using DDT). I tried using a DDT example but it doesn't work when creating a window with createwindow...
    I have no problem changing the color of the actual tab (on top), but the window underneath it is the problem!

    This is how I'm trying to do it:

    Code:
           case %wm_erasebkgnd
             ''draw tabs with a differnt gradient background color
             hdc&=wparam&
             pg&=getcurseltab(htab&)
             drawtabbackground hdc&,hwnd&,pg&
             function=1
             exit function
    This part works great (the actuual tab):

    Code:
           case %wm_drawitem
    
             if wparam&=1000 then  ''tab control
               disptr=lparam&
               pgnum&[email protected]
    
               bcolor&=rgb(128,128,255)
    
               if @disptr.itemstate=%ods_selected then
                 @[email protected]+2
                 fcolor&=rgb(255,255,255)
               else
                 fcolor&=rgb(0,0,0)
               end if
    
               hbrush&=createsolidbrush(bcolor&)
               selectobject @disptr.hdc,hbrush&
               settextcolor @disptr.hdc,fcolor&
               setbkcolor @disptr.hdc,bcolor&
               fillrect @disptr.hdc,@disptr.rcitem,hbrush&
    
               ti.mask=%tcif_text
               ti.psztext=varptr(ztext)
               ti.cchtextmax=sizeof(ztext)
    
               call tabctrl_getitem(getdlgitem(hwnd&,wparam&),@disptr.itemid,ti)
    
               style&=%dt_singleline or %dt_center or %dt_top
               drawtext @disptr.hdc,ztext,len(ztext),@disptr.rcitem,style&
               deleteobject hbrush&
    
               function=1
               exit function
             end if
    The drawtabbackground:

    Code:
    sub drawgradient(byval hdc&,byval hwnd&,byval pgnum&)
         dim rc as rect
         getclientrect hwnd&,rc
         bcolor&=rgb(128,128,255)
         hbrush&=createsolidbrush(bcolor&)
         fillrect hdc&,rc,hbrush&
         deleteobject hbrush&
    end sub
    Any ideas???

    [/CODE]
    Jim Seekamp

  • #2
    Take a look at
    http://www.powerbasic.com/support/pb...ng+Payments+++)
    Francisco J Castanedo
    Software Developer
    Distribuidora 3HP, C.A.
    [URL]http://www.distribuidora3hp.com[/URL]

    Comment


    • #3
      Ownerdraw only draw the Tabs of the tab control, not the background of the complete control.

      To draw that, subclass the control and then process the WM_ERASEBKGND message.
      Chris Boss
      Computer Workshop
      Developer of "EZGUI"
      http://cwsof.com
      http://twitter.com/EZGUIProGuy

      Comment


      • #4
        Thanks Chris
        That explains it.
        Jim Seekamp

        Comment

        Working...
        X