Changing the Tab Label Font
Posted
by Zafir Anjum
on August 6th, 1998
// m_fontEdit is a member variable
// Create a bold font
m_fontEdit.CreateFont( -8, 0, 0, 0, 700, 0, 0, 0, 1,
0, 0, 0, 0, _T("MS Sans Serif") );
GetTabControl()->SetFont( &m_fontEdit );

Comments
MS Property Sheet example
Posted by Legacy on 06/28/2003 12:00amOriginally posted by: Mick
There is an example on the Microsoft Knowledge base on how to do things with fonts in Property sheet:
Microsoft Knowledge Base Article - 142170
It includes some sample code. From this example it's pretty easy to work out what to do. Personnaly I wanted to get my property sheet to resize itself at run time using the system font size.
ReplyChange Font to Active Page
Posted by Legacy on 03/24/2003 12:00amOriginally posted by: Antonio
Hi
I'de like to distinguish the tab that has focus not using the HighlightItem() function but changing its caption text in bold font.
Please help me to realize it.
Thanks. Antonio
-
-
ReplyHow to change propertysheet font
Posted by emp on 09/01/2004 07:26am// Use this function in Sheet::OnInitDialog; // Inherit the sheet::BuildPropPageArray to get dialog resource template font void ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag) { CRect windowRect; // grab old and new text metrics TEXTMETRIC tmOld, tmNew; CDC * pDC = pWnd->GetDC(); CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont()); pDC->GetTextMetrics(&tmOld); pDC->SelectObject(pFont); pDC->GetTextMetrics(&tmNew); pDC->SelectObject(pSavedFont); pWnd->ReleaseDC(pDC); long oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading; long newHeight = tmNew.tmHeight+tmNew.tmExternalLeading; if (nFlag != CDF_NONE) { // calculate new dialog window rectangle CRect clientRect, newClientRect, newWindowRect; pWnd->GetWindowRect(windowRect); pWnd->GetClientRect(clientRect); long xDiff = windowRect.Width() - clientRect.Width(); long yDiff = windowRect.Height() - clientRect.Height(); newClientRect.left = newClientRect.top = 0; newClientRect.right = clientRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth; newClientRect.bottom = clientRect.bottom * newHeight / oldHeight; if (nFlag == CDF_TOPLEFT) // resize with origin at top/left of window { newWindowRect.left = windowRect.left; newWindowRect.top = windowRect.top; newWindowRect.right = windowRect.left + newClientRect.right + xDiff; newWindowRect.bottom = windowRect.top + newClientRect.bottom + yDiff; } else if (nFlag == CDF_CENTER) // resize with origin at center of window { newWindowRect.left = windowRect.left - (newClientRect.right - clientRect.right)/2; newWindowRect.top = windowRect.top - (newClientRect.bottom - clientRect.bottom)/2; newWindowRect.right = newWindowRect.left + newClientRect.right + xDiff; newWindowRect.bottom = newWindowRect.top + newClientRect.bottom + yDiff; } pWnd->MoveWindow(newWindowRect); } pWnd->SetFont(pFont); // iterate through and move all child windows and change their font. CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD); while (pChildWnd) { pChildWnd->SetFont(pFont); pChildWnd->GetWindowRect(windowRect); CString strClass; ::GetClassName(pChildWnd->m_hWnd, strClass.GetBufferSetLength(32), 31); strClass.MakeUpper(); if(strClass==_T("COMBOBOX")) { CRect rect; pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect); windowRect.right = rect.right; windowRect.bottom = rect.bottom; } pWnd->ScreenToClient(windowRect); windowRect.left = windowRect.left * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth; windowRect.right = windowRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth; windowRect.top = windowRect.top * newHeight / oldHeight; windowRect.bottom = windowRect.bottom * newHeight / oldHeight; pChildWnd->MoveWindow(windowRect); pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT); } }ReplyChange propersheet font
Posted by emp on 09/01/2004 07:19amUse the following function for sheet and its pages; void ChangeDialogFont(CWnd* pWnd, CFont* pFont, int nFlag) { CRect windowRect; // grab old and new text metrics TEXTMETRIC tmOld, tmNew; CDC * pDC = pWnd->GetDC(); CFont * pSavedFont = pDC->SelectObject(pWnd->GetFont()); pDC->GetTextMetrics(&tmOld); pDC->SelectObject(pFont); pDC->GetTextMetrics(&tmNew); pDC->SelectObject(pSavedFont); pWnd->ReleaseDC(pDC); long oldHeight = tmOld.tmHeight+tmOld.tmExternalLeading; long newHeight = tmNew.tmHeight+tmNew.tmExternalLeading; if (nFlag != CDF_NONE) { // calculate new dialog window rectangle CRect clientRect, newClientRect, newWindowRect; pWnd->GetWindowRect(windowRect); pWnd->GetClientRect(clientRect); long xDiff = windowRect.Width() - clientRect.Width(); long yDiff = windowRect.Height() - clientRect.Height(); newClientRect.left = newClientRect.top = 0; newClientRect.right = clientRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth; newClientRect.bottom = clientRect.bottom * newHeight / oldHeight; if (nFlag == CDF_TOPLEFT) // resize with origin at top/left of window { newWindowRect.left = windowRect.left; newWindowRect.top = windowRect.top; newWindowRect.right = windowRect.left + newClientRect.right + xDiff; newWindowRect.bottom = windowRect.top + newClientRect.bottom + yDiff; } else if (nFlag == CDF_CENTER) // resize with origin at center of window { newWindowRect.left = windowRect.left - (newClientRect.right - clientRect.right)/2; newWindowRect.top = windowRect.top - (newClientRect.bottom - clientRect.bottom)/2; newWindowRect.right = newWindowRect.left + newClientRect.right + xDiff; newWindowRect.bottom = newWindowRect.top + newClientRect.bottom + yDiff; } pWnd->MoveWindow(newWindowRect); } pWnd->SetFont(pFont); // iterate through and move all child windows and change their font. CWnd* pChildWnd = pWnd->GetWindow(GW_CHILD); while (pChildWnd) { pChildWnd->SetFont(pFont); pChildWnd->GetWindowRect(windowRect); CString strClass; ::GetClassName(pChildWnd->m_hWnd, strClass.GetBufferSetLength(32), 31); strClass.MakeUpper(); if(strClass==_T("COMBOBOX")) { CRect rect; pChildWnd->SendMessage(CB_GETDROPPEDCONTROLRECT,0,(LPARAM) &rect); windowRect.right = rect.right; windowRect.bottom = rect.bottom; } pWnd->ScreenToClient(windowRect); windowRect.left = windowRect.left * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth; windowRect.right = windowRect.right * tmNew.tmAveCharWidth / tmOld.tmAveCharWidth; windowRect.top = windowRect.top * newHeight / oldHeight; windowRect.bottom = windowRect.bottom * newHeight / oldHeight; pChildWnd->MoveWindow(windowRect); pChildWnd = pChildWnd->GetWindow(GW_HWNDNEXT); } }
ReplyFont size problem in the code
Posted by Legacy on 01/31/2003 12:00amOriginally posted by: Jagadees
Hi,
I added code in the OnInitDialog of CPropertySheet for changing the font. It worked. But there is one problem, my property sheet size and font size shrinked. Please help me to solve this. We used -8 as font height in CreateFont.
TIA,
ReplyJagadees.
How do you change the Font of just the active page
Posted by Legacy on 09/26/2000 12:00amOriginally posted by: Lou
This code is simple and works well if you want all the pages in the PropertySheet to be same Font. How do you change the font of the Tab label on JUST the active page?
Thanks,
Lou
Reply
How can I set the focus rectangle in the tabs of an PropertySheet?
Posted by Legacy on 07/27/2000 12:00amOriginally posted by: Ulf Lohmann
Hi there,
can anybody tell me how I can set the focus rectangle in the tabs of a property sheet programatically?
The MFC seems to show the focus recangle only when no control inside the active page can recieve the input focus.
ReplyHow can I change Tab Label Font in this sample ?
Posted by Legacy on 08/31/1999 12:00amOriginally posted by: Jeffrey
Hi there,
I have a problem when I try to put several property pages inside a SDI view.
I found following sample project in VC Books online, <SAMPLE: Property Sheet as the View Window of a CFrameWnd, Article ID: Q161886 >. What I want to do is changing the font of each tab title, ie. "Name", "Order Entry". Do you have any good idea for this ?
The sample can also be found by searching key word "Psview" in MSDN library.
Thanks a lot
ReplyCPropertySheet Fonts
Posted by Legacy on 08/17/1999 12:00amOriginally posted by: Doug Watts
MFC has changed (since version 4.0) regarding its use of property sheets. Since version 4.0 MFC's CPropertySheet is designed to use the system font and all pages will use the font of the sheet. There is an "undocumented" work-around that, as any undocumented coding, is subject to change in the future.
For details, search MSDN knowledgebase for article #Q142170.
ReplyChange Font for Property Sheet
Posted by Legacy on 03/26/1999 12:00amOriginally posted by: David Zhu
I changed Font size to 12 for each property page, but when
ReplyI addpage to property sheet and pop it up, everything
change back to font size 8. Can anybody help me?