Print Page | Close Window

How to change the Font of CXTPControl ?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=13512
Printed Date: 28 March 2024 at 8:19am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to change the Font of CXTPControl ?
Posted By: kanitamildasan
Subject: How to change the Font of CXTPControl ?
Date Posted: 27 February 2009 at 1:16am
Hi,

    CXTPCommandBar* pMenuBar = pCommandBars->SetMenu(_T("Menu Bar"), IDR_SAMPLETYPE);

    if(pMenuBar == NULL)
    {
        TRACE0("Failed to create menu bar.\n");
        return -1;      // fail to create
    }

    pMenuBar->SetFlags(xtpFlagAddMDISysPopup);   

    int NoOfCtrls = -1;
    NoOfCtrls = pMenuBar->GetControlCount();
    CXTPControl *pControl = NULL;
    pControl = pMenuBar->GetControl(NoOfCtrls - 1);

Is it possible to change the Font of pControl here ? (only pControl not entire CommandBars through XTPPaintManager)

Thanks in advance.




Replies:
Posted By: Oleg
Date Posted: 27 February 2009 at 2:59am
Hi,
No :( You can only make font bold (SetItemDefault(TRUE))  or use Markup feature.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kanitamildasan
Date Posted: 27 February 2009 at 7:48am
Hi Oleg,

I am kind of new to Markups. An example for this Scenario will be more helpful.

Thanks



Posted By: Oleg
Date Posted: 02 March 2009 at 12:41am
Hi,
 
Here sample:
 
CXTPControlMarkupLabel* pLabel = new CXTPControlMarkupLabel();
 pLabel->SetCaption(_T("<TextBlock TextAlignment='Center'><Underline>This is</Underline><LineBreak/><Bold>Markup</Bold> <Run Foreground='Red'>Label</Run><LineBreak/><Italic>Control</Italic></TextBlock>"));
pMenuBar->GetControls()->Add(pLabel);

-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kanitamildasan
Date Posted: 03 March 2009 at 4:47am
Thanks oleg,

It changes the font correctly. Being a Label it does not work like a button(which i need like handle Click event,mouse over highlight etc).
And when i dock the menu bar to right or left of the Mainframe the label didnt render the vertical text.




Posted By: Oleg
Date Posted: 03 March 2009 at 5:18am
Hi,
 
Yes, both true.
 
 
Another option is to create class derived from some CXTPOfficeTheme, override GetControlFont and return font you need.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: kanitamildasan
Date Posted: 05 March 2009 at 11:37pm
Thanks Oleg,

Deriving from CXTPOfficeTheme works only for it. so i found some workaround to make it work for all the themes using some macros :)






Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net