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 ?
DCTABPAGE caption
Re: DCTABPAGE caption
hi,
this Demo is NOT exact what you want, but it show the Way
i change Color of Tab when it is XBP_DRAWSTATE_SELECTED
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
Jimmy
Re: DCTABPAGE caption
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
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
Re: DCTABPAGE caption
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.
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."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."