Click here to Skip to main content
15,881,812 members
Articles / Desktop Programming / MFC

High color icons for CPropertySheet

Rate me:
Please Sign up or sign in to vote.
4.81/5 (21 votes)
26 Feb 2004CPOL2 min read 129.3K   6K   70  
Upgrading CPropertySheet tab control to display high color icons.
// PageIcon.cpp : implementation file
//
///////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "HighColorTab.h"
#include "PageIcon.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPageIcon property page

IMPLEMENT_DYNAMIC(CPageIcon, CPropertyPage)

CPageIcon::CPageIcon(const char* lpszTitle, UINT nIconID)
 : CPropertyPage(CPageIcon::IDD),
   m_nIconID(nIconID),
   m_hIcon(NULL)
{
	//{{AFX_DATA_INIT(CPageIcon)
	//}}AFX_DATA_INIT

  // Set the title and icon.
  if( NULL != m_nIconID )
  {
    m_psp.dwFlags |= PSP_USEHICON;
    HICON hIconTab = AfxGetApp()->LoadIcon( m_nIconID );
    m_psp.hIcon = hIconTab;
  }
}

CPageIcon::~CPageIcon()
{
}

void CPageIcon::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPageIcon)
	DDX_Control(pDX, IDC_PAGE_ICON, m_staticIcon);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPageIcon, CPropertyPage)
	//{{AFX_MSG_MAP(CPageIcon)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPageIcon message handlers

BOOL CPageIcon::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
  // Set icon
  if( NULL != m_nIconID )
  {
    m_hIcon = ::LoadIcon( ::AfxGetInstanceHandle(), MAKEINTRESOURCE(m_nIconID) );
    ASSERT (m_hIcon );
    m_staticIcon.ModifyStyle( 0, SS_ICON );
    m_staticIcon.SetIcon( m_hIcon );
  }
  else
  {
    m_staticIcon.SetWindowText("No icon");
  }

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
President ClearSquare Associates
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions