DCTABPAGE caption

This forum is for eXpress++ general support.
Post Reply
Message
Author
Koverhage
Posts: 155
Joined: Mon Feb 01, 2010 8:45 am

DCTABPAGE caption

#1 Post 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 ?
Klaus

User avatar
Auge_Ohr
Posts: 1452
Joined: Wed Feb 24, 2010 3:44 pm

Re: DCTABPAGE caption

#2 Post 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
greetings by OHR
Jimmy

Koverhage
Posts: 155
Joined: Mon Feb 01, 2010 8:45 am

Re: DCTABPAGE caption

#3 Post 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
Klaus

User avatar
Tom
Posts: 1313
Joined: Thu Jan 28, 2010 12:59 am
Location: Berlin, Germany

Re: DCTABPAGE caption

#4 Post 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.
Best regards,
Tom

"Did I offend you?"
"No."
"Okay, give me a second chance."

Koverhage
Posts: 155
Joined: Mon Feb 01, 2010 8:45 am

Re: DCTABPAGE caption

#5 Post by Koverhage »

ok. Thank you andJimmy
Klaus

Post Reply