473,397 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

CTabCtrl FONT

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;
}
Nov 26 '05 #1
2 1687
> 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
Nov 26 '05 #2
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

"David Lowndes" wrote:
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

Nov 26 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shmuel (Seymour J.) Metz | last post by:
I've got a document that StarOffice converted into HTML, and I'm trying to clean up the cuft that it generated. I put together some basic styles, and tied using them: the results are puzzling. The...
7
by: Fabian Neumann | last post by:
Hi! I got a problem with font-family inheritance. Let's say I have CSS definitions like: p { font:normal 10pt Verdana; } strong { font:normal 14pt inherit;
115
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." ...
9
by: Dr John Stockton | last post by:
Assuming default set-ups and considering all reasonable browsers, whatever that may mean, what should an author expect that his readers in general will see (with visual browsers) for a page with...
4
by: tshad | last post by:
I am having trouble with links in my DataGrid. I have Links all over my page set to smaller and they are consistant all over the page in both Mozilla and IE, except for the DataGrid. Here is a...
7
by: Sakharam Phapale | last post by:
Hi All, How to preserve the old font properties while changing new one? I posted same question 2 months back, but I had very small time then. eg. "Shopping for" is a text in RichTextBox and...
7
by: Daniel Kaplan | last post by:
I have the item below at the top of my style sheet. And it seems that the font-szie is ignored. I know that my linked style sheet is being read, and used because if I remove the font-family line,...
1
by: MadScientist | last post by:
I have a CTabCtrl object with embedded CHtmlCtrl objects. If the user clicks from one tab to the next and a CButton has the focus then the code gets stuck in a infinite loop in the do {} while...
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.