Placing a 3D Logo Text In the PropertySheet Button Area | CodeGuru

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 […]

Written By
CodeGuru Staff
CodeGuru Staff
Aug 6, 1998
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

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

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.