• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 469
  • Last Modified:

Need to bold the tab title of the active property page

Hi

I have a property sheet that consists of three property pages.  I would like the tab of the active page to be bolded.

For example.  Suppose that the titles of my 3 property pages are {"one", "two", "three"}.  Then when the user clicks on the text "two" (to select this page) then

(a) the text "two" should become bolded and

(b) the previous bolded text (if it wasn't "two") should have the bolding removed
0
mgw
Asked:
mgw
  • 2
  • 2
1 Solution
 
alb66Commented:
You need an owner draw tab control.
You can start from here:
http://www.codeproject.com/KB/tabs/customtab.aspx
0
 
mgwAuthor Commented:
Hi alb66

Many thanks for your quick response.  I took a look at the code that I downloaded from the link that you recommended.

Unfortunately I do not have much experience with font setting and I was unable to determine how to set the font within the downloaded code.

Would you have any other advice?

Thanks in advance.
0
 
alb66Commented:
You must modify the item drawing code.
In the sample, change the end part of CEnTabCtrl::DrawItem() as in the code snippet:
void CEnTabCtrl::DrawItem(LPDRAWITEMSTRUCT lpdis)
{
	...
 
	// text
	rItem.right -= PADDING;
	FormatText(sTemp, pDC, rItem.Width());
 
	CFont boldFont;
	CFont* pOldFont = NULL;
 
	if ( bSelected )	// only for the selected item
	{
		LOGFONT logFont;
		CFont* pFont = pDC->GetCurrentFont();		// get current font
		pFont->GetLogFont( &logFont );			// get font's parameters
		logFont.lfWeight = FW_BOLD;			// change it to bold
		boldFont.CreateFontIndirect( &logFont );	// create the new font
		pOldFont = pDC->SelectObject( &boldFont );	// select it
	}
 
	pDC->SetTextColor(GetTabTextColor(bSelected));
	pDC->DrawText(sTemp, rItem, DT_NOPREFIX | DT_CENTER);
 
	if ( bSelected )
		pDC->SelectObject( pOldFont );			// restore original font
}

Open in new window

0
 
mgwAuthor Commented:
Good job alb66 - that worked a treat.  Thank you.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now