How To: Bold the Text on the Property Page Tab when the page is active
-
Hi, I need to Bold the text on the property page tab when the page is active. I have been successful in setting all the tabs to bold with the following Code: BOOL CPropSheet::OnInitDialog() { BOOL bResult = CPropertySheet::OnInitDialog(); // Set the attributes of the font. LOGFONT logFont; memset(&logFont, 0, sizeof(LOGFONT)); logFont.lfWeight = FW_BOLD; // create the new font. CFont font; font.CreateFontIndirect(&logFont); // set the control to use the new font. CTabCtrl* pTabCtrl = GetTabControl(); pTabCtrl->SetFont(&font); return bResult; } I have placed the code in the OnSetActive() event for the Pages but I can't seem to get the handle to the sheet to use the GetTabControl() function. If anyone has any ideas on how to do this or can provide a sample application it would be greatly appreciated. TIA, Lori
-
Hi, I need to Bold the text on the property page tab when the page is active. I have been successful in setting all the tabs to bold with the following Code: BOOL CPropSheet::OnInitDialog() { BOOL bResult = CPropertySheet::OnInitDialog(); // Set the attributes of the font. LOGFONT logFont; memset(&logFont, 0, sizeof(LOGFONT)); logFont.lfWeight = FW_BOLD; // create the new font. CFont font; font.CreateFontIndirect(&logFont); // set the control to use the new font. CTabCtrl* pTabCtrl = GetTabControl(); pTabCtrl->SetFont(&font); return bResult; } I have placed the code in the OnSetActive() event for the Pages but I can't seem to get the handle to the sheet to use the GetTabControl() function. If anyone has any ideas on how to do this or can provide a sample application it would be greatly appreciated. TIA, Lori
From any of the pages, you can get a pointer to the sheet with: CPropSheet* pSheet = (CPropSheet*) GetParent(); However your code has another bug. You have the
font
variable on the stack, so as soon as the function returns,font
gets destroyed, taking the GDI font object with it. Make the CFont variable a member variable of the sheet so it will be available for the lifetime of the sheet.