Page 1 of 1

DCTABPAGE caption

Posted: Fri Feb 06, 2026 8:05 am
by Koverhage
Hello,

I would like to set the caption (text) of a DCTABPAGE
to bold or italic if the tabpage activ or to normal if inactiv.
How i can do that ?

Re: DCTABPAGE caption

Posted: Fri Feb 06, 2026 9:58 am
by Auge_Ohr
hi,
Koverhage wrote: Fri Feb 06, 2026 8:05 am I would like to set the caption (text) of a DCTABPAGE
to bold or italic if the tabpage activ or to normal if inactiv.
as i can say you need "owner draw"

this Demo is NOT exact what you want, but it show the Way
i change Color of Tab when it is XBP_DRAWSTATE_SELECTED

Code: Select all

oMyTab1 := XBPTABPAGE() :new(...)
...
oMyTab1:DrawMode := XBP_DRAW_OWNER 
oMyTab1:create()
oMyTab1:Draw := { | o, a, s | DrawTab( o, a, s, self ) }

FUNCTION DrawTab( oPS, aInfo, oSelf, oParent )
LOCAL lHeader
LOCAL cCaption
LOCAL AreaAttrs := ARRAY( GRA_AA_COUNT )
LOCAL TextAttrs := ARRAY( GRA_AS_COUNT )
LOCAL lReturn   := .F.
LOCAL nItem     := aInfo[ XBP_DRAWINFO_ITEM ]               
LOCAL nAction   := aInfo[ XBP_DRAWINFO_ACTION ]             // Aktion, die die Nachricht xbeP_Draw auslöste
LOCAL nState    := aInfo[ XBP_DRAWINFO_STATE ]              // Aktueller Anzeigestatus des TabPage-Objekts
LOCAL aRect     := aInfo[ XBP_DRAWINFO_RECT ]               // Ausgaberechteck für die Zeichenoperation
LOCAL oFont     := oParent:GetActiveFont()

   cCaption := oSelf:Caption

   lHeader := BAnd( aInfo[ XBP_DRAWINFO_STATE ], XBP_DRAWSTATE_HEADER ) == XBP_DRAWSTATE_HEADER

   IF lHeader == .T.

      IF BAnd( aInfo[ XBP_DRAWINFO_ACTION ], XBP_DRAWACTION_DRAWFG ) == XBP_DRAWACTION_DRAWFG

         IF BAnd( aInfo[ XBP_DRAWINFO_STATE ], XBP_DRAWSTATE_SELECTED ) == XBP_DRAWSTATE_SELECTED
            AreaAttrs[ GRA_AA_COLOR ] := GRA_CLR_BLACK
            TextAttrs[ GRA_AS_COLOR ] := GRA_CLR_CYAN
         ELSE
            AreaAttrs[ GRA_AA_COLOR ] := GRA_CLR_BLACK
            TextAttrs[ GRA_AS_COLOR ] := GRA_CLR_PALEGRAY
         ENDIF
         GraSetAttrArea( oPS, AreaAttrs )

         GraBox( oPS, { aInfo[ XBP_DRAWINFO_RECT ] [ 1 ], aInfo[ XBP_DRAWINFO_RECT ] [ 2 ] }, ;
                      { aInfo[ XBP_DRAWINFO_RECT ] [ 3 ], aInfo[ XBP_DRAWINFO_RECT ] [ 4 ] }, ;
                        GRA_OUTLINEFILL )
        
        // Hier den Font auswählen
         GraSetFont( oPS, oFont )

         GRASETATTRSTRING( oPS, TextAttrs )
         IF VALTYPE( cCaption ) = "C"
            GraCaptionStr( oPS, aInfo[ XBP_DRAWINFO_RECT ], { aInfo[ XBP_DRAWINFO_RECT, 3 ], aInfo[ XBP_DRAWINFO_RECT, 4 ] }, ;
                    cCaption, XBPALIGN_VCENTER + XBPALIGN_HCENTER )
         ENDIF

         IF BAnd( aInfo[ XBP_DRAWINFO_STATE ], XBP_DRAWSTATE_FOCUS ) == XBP_DRAWSTATE_FOCUS
            GraFocusRect( oPS )
         ENDIF
      ENDIF
   ENDIF

RETURN lReturn

Re: DCTABPAGE caption

Posted: Sun Feb 08, 2026 3:41 am
by Koverhage
Jimmy,

there a so many samples in Xsample, how i set the color
dc_tabpagecolor or dctabpage COLOR, and more.
For this i doesn't need ownerdraw.

I want only set attribrutes for the caption of the tabpage or a different font

Re: DCTABPAGE caption

Posted: Sun Feb 08, 2026 5:38 am
by Tom
You need to use ownerdrawing. You can't set any font attributes without that.

But it's simple. Build a subclass (maybe based on Jimmy's suggestion) and use the SUBCLASS clause of DCTABPAGE. Just paint the caption there.

Re: DCTABPAGE caption

Posted: Sun Feb 08, 2026 11:23 pm
by Koverhage
ok. Thank you andJimmy