Placing a 3D Logo Text In the PropertySheet Button Area

I read Jeremy Davis's article named "Placing a bitmap in the PropertySheet button area" and liked the idea a lot, but when I tried to implement it I found one small thing, bitmap can not change color if background color is not (for example) gray.

So I made my own program which displays 3d text in PropertySheet button area.

sample1.jpg (5019 bytes)

sample2.jpg (4809 bytes)

Note that when the property sheet is in wizard mode, the OK button and Tab Control are not present and so special care has to be taken to avoid crashes in OnPaint while trying to get the dimensions of that two objects.

Here how it's done.


void CPropertySheetWithLogoDlg::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	if (m_LogoText.IsEmpty())
	return;

	BOOL bWizMode; 
        
	// Get the current style from PROPSHEETHEADER structure 
	if( m_psh.dwFlags & PSH_WIZARD ) 
		bWizMode = TRUE;                // It's in wizard mode
	else 
		bWizMode = FALSE;               // It's in property sheet mode


	// If this is a Wizard, cannot retrieve the tab control dimension. 
	// So Get the Dialog's Window Rect  

	CRect rectTabCtrl;
	if( bWizMode ) 
	{ 
		GetWindowRect(rectTabCtrl); 
		rectTabCtrl.OffsetRect(14,0);	// A little correction
	} 
	else 
	{ 
		GetTabControl()->GetWindowRect(rectTabCtrl);
	} 
	ScreenToClient(rectTabCtrl);


	CRect rectOk;
	GetDlgItem(IDOK)->GetWindowRect(rectOk);
	ScreenToClient(rectOk);

	dc.SetBkMode(TRANSPARENT);

	CRect rectText;
	rectText.left = rectTabCtrl.left;
	rectText.top = rectOk.top;
	rectText.bottom = rectOk.bottom;
	rectText.right = rectOk.left;

	CFont * OldFont = dc.SelectObject(&m_fontLogo);

	// draw text in DC
	COLORREF OldColor = dc.SetTextColor( ::GetSysColor( COLOR_3DHILIGHT));

	dc.DrawText(m_LogoText, rectText + CPoint(1,1), 
	            DT_SINGLELINE | DT_LEFT | DT_VCENTER);
	dc.SetTextColor( ::GetSysColor( COLOR_3DSHADOW));
	dc.DrawText( m_LogoText, rectText, DT_SINGLELINE | DT_LEFT | DT_VCENTER);

	// restore old text color
	dc.SetTextColor( OldColor);

	// restore old font
	dc.SelectObject(OldFont);

	// Do not call CPropertySheet::OnPaint() for painting messages
}

You can play with different combination of DrawText functions and make any appearance of the Text

Download Source Code and Example

Last Updated: 20 July 1998