Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / November 2005

Tip: Looking for answers? Try searching our database.

CTabCtrl FONT

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mike east - 26 Nov 2005 06:47 GMT
Greetings,

Am trying to change the font of a CTabCtrl I have in my Main Frame Window
(not a Dialog Box).

Since CTabCtrl is based in CWnd, I figured that SetFont() should work.  

No luck. And there are no CTabCtrl member functions specifically for
changing the font.  

My code looks like this.  The Tabs work fine. I just can't change the size.

Any idea what I am doing wrong???

Thanks,

Mike
************************************************
class CMainFrame : public CFrameWnd
{
public:
    CTabCtrl  myTab;
************************************************
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
        return -1;
   CRect r;
   GetClientRect(&r);

   myTab.Create(TCS_TABS |TCS_BOTTOM|TCS_MULTILINE ,r, this, 2345);

   CFont font;
   font.CreateFont( 10, 0, 0, 0,FW_NORMAL,0,0,0,0,0,0,0,0, "Arial"));
   myTab.SetFont(&font,TRUE);

    TC_ITEM T;
    T.mask = TCIF_TEXT;   
    T.pszText = "PLOT 1";   myTab.InsertItem(0, &T );
    T.pszText = "PLOT 2";   myTab.InsertItem(1, &T );
    T.pszText = "PLOT 3";   myTab.InsertItem(2, &T );
    T.pszText = "PLOT 4";   myTab.InsertItem(3, &T );

   myTab.ShowWindow(SW_SHOWNORMAL);

    return 0;
}
David Lowndes - 26 Nov 2005 09:48 GMT
>    CFont font;
>    font.CreateFont( 10, 0, 0, 0,FW_NORMAL,0,0,0,0,0,0,0,0, "Arial"));
>    myTab.SetFont(&font,TRUE);

The problem will undoubtedly be because your CFont object gets
destroyed. Make it a member variable of the container of the tab
control so that it exists for the lifetime of the tab control.

Dave
mike east - 26 Nov 2005 17:58 GMT
Greetings,

Thanks so much for the help Dave.  I'm learning as I am going, and there is
so much to learn about C++ programming that it's like trying to find a needle
in a hackstack sometimes.  The most obvious things, are the ones that aren't
discussed in articles and Help files, and cause me the most difficulties.

I read all about CTabCtrl, and was frustrated for several days trying to get
it to work until I tried using.... "myTab.ShowWindow(SW_SHOWNORMAL) "

Obviously the authors of the CtabCtrl Help assumed that I would know to do
that.

Same with the Font thing. I assumed that once I told a control what to do,
it kept an copy of that instruction. Didn't know that the instruction info
had to stay alive all the time the control did.   Sure enough now it works.

Thanks againt for your timely help and patience with these novice questions.

Mike

> >    CFont font;
> >    font.CreateFont( 10, 0, 0, 0,FW_NORMAL,0,0,0,0,0,0,0,0, "Arial"));
[quoted text clipped - 5 lines]
>
> Dave

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.