Update: Creating a full application using the CPropertySheet | CodeGuru

Update: Creating a full application using the CPropertySheet

Download Source Code and Example In reaction about my article ‘Creating a full application using the CPropertySheet’ someone mailed me and asked to add an icon and a minimize button to the PropertySheet window. Adding the icon is the easy task. Adding the minimize button was the difficult part, it needs very litle code, but […]

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

Download Source Code and Example

In reaction about my article ‘Creating a full application using the CPropertySheet’ someone mailed me and asked to add an icon and a minimize button to the PropertySheet window. Adding the icon is the easy task.

Adding the minimize button was the difficult part, it needs very litle code,
but the way it is done is the interesting part.
We cant just overload the PrecreateWindow() and change the window style.
We must do the style changing when OnInitDialog() Event happens and we must change the application’s system menu in order to make the minimize button to work.

The code below should be very easy to understand for some one that have read my previous example.

class CSheet : public CPropertySheet
{
public:

CPropertyPage Page1;
CPropertyPage Page2;
CPropertyPage Page3;
CPropertyPage Page4;
CMenu Menu;

CSheet() : CPropertySheet( “CPropertySheet By Piperopoulos Panagiotis” )
{
Page1.Construct( IDD_VIEW1 );
Page2.Construct( IDD_VIEW2 );
Page3.Construct( IDD_VIEW3 );
Page4.Construct( IDD_VIEW4 );
AddPage( &Page1 );
AddPage( &Page2 );
AddPage( &Page3 );
AddPage( &Page4 );
}

~CSheet(){}

BOOL OnInitDialog( )
{
CPropertySheet::OnInitDialog();

GetDlgItem( IDOK )->ShowWindow( SW_HIDE );
GetDlgItem( IDCANCEL )->ShowWindow( SW_HIDE );
GetDlgItem( ID_APPLY_NOW )->ShowWindow( SW_HIDE );

Menu.LoadMenu( IDR_MENU );
SetMenu( &Menu );

// NEW LINES START

// Load the app icons
SetIcon( AfxGetApp()->LoadIcon( IDI_ICONS ), FALSE );
SetIcon( AfxGetApp()->LoadIcon( IDI_ICONB ), TRUE );

// add the minimize button to the window
::SetWindowLong( m_hWnd, GWL_STYLE, GetStyle() | WS_MINIMIZEBOX );

// add the minimize command to the system menu
GetSystemMenu( FALSE )->InsertMenu( -1, MF_BYPOSITION | MF_STRING,
SC_ICON, “Minimize” );

// activate the new sysmenu
DrawMenuBar();

// NEW LINES END

return TRUE;
}

void DisplayPage( int Page )
{
switch( Page )
{
case IDM_1 :
SetActivePage( &Page1 );
break;
case IDM_2 :
SetActivePage( &Page2 );
break;
case IDM_3 :
SetActivePage( &Page3 );
break;
case IDM_4 :
SetActivePage( &Page4 );
break;
}
}

DECLARE_MESSAGE_MAP()
};

BEGIN_MESSAGE_MAP( CSheet, CPropertySheet )
ON_COMMAND_RANGE( IDM_1, IDM_4, DisplayPage )
END_MESSAGE_MAP()

class TheApp : public CWinApp
{
public:

TheApp(){}
~TheApp(){}

virtual BOOL InitInstance()
{
#ifdef _AFXDLL
Enable3dControls();
#else
Enable3dControlsStatic();
#endif

CSheet ps;
m_pMainWnd = &ps;
ps.DoModal();

return FALSE;
}
};

Last updated: 21 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.