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 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
	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 );


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

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


		// 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

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


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

class TheApp : public CWinApp

	virtual BOOL InitInstance()
	#ifdef _AFXDLL

	CSheet ps;
	m_pMainWnd = &ps

	return FALSE;

Last updated: 21 July 1998


  • Why doesnt F1 help work ?

    Posted by Mike Pliam on 10/06/2008 03:05pm

    F1 help won't work using this method. If one selects the HTML Help option in the Wizard, a dialog-based app is created wherein F1 will summon HTML help. Once the original dialog-based application is converted to a CPropertySheet derived application, F1 no longer works and pressing it results in the message 'Failed to launch help.' Any idea how to get this to work?

  • Really great!

    Posted by Legacy on 07/26/2003 12:00am

    Originally posted by: Ramesh

    Was struggling for a whole day to get a minimize button on a property sheet application.

    Saved my another day.

    Thanks a lot.

  • setwindowlong is not working in property page - help pls

    Posted by Legacy on 06/26/2002 12:00am

    Originally posted by: soni

    i want to create a simple propertypage with validations:

    i created a propertysheet and 3 propertypages
    the property pages are created using dialog resource derived fro cpropertypage.

    now i did addpage in property sheet

    next i handled onkillactive and ok events of property page.

    In onkillactive, i am doing validations and in case of error i want the focus to reman on the same page. For thta i have to do
    SetWindowLong correct?

    I am using pure mfc, not sdk. The control is not remaining in the same page. what shouls i do? can u send me a simple sample app of propertypages with validations?

  • VeryGood

    Posted by Legacy on 01/17/2002 12:00am

    Originally posted by: limj

    very good , i just meet the same question in my work.

  • How about other languages?

    Posted by Legacy on 11/10/2000 12:00am

    Originally posted by: Andreas J�ger

    You add some entries to the systems menu. But what about other languages? I cannot add "Minimize" or "Restore" to a german menu... It is very ugly. Do you have a solution for this (difficult) task?


    Andreas Jaeger

  • Accessing Data at the Property Sheet Level

    Posted by Legacy on 09/06/2000 12:00am

    Originally posted by: Jim Brown

    I am trying to build an application using only the property sheet interface. I am able to get the application built to the point that it displays the property sheets in the tabbed dialog box as it should.

    The problem I am having is:

    I want all the property pages (tabs) to have access to the same object. This object should be created at the property sheet "level". The property pages could then set the properties of the object and call methods of the object and display the object data in edit controls on the property page.

    I can not seem to find a way for the property pages to be able to access an object created at the property sheet level.

    Any suggestions on how to pull this off?


  • How do you do this same task, accept using a modeless PropertySheet?

    Posted by Legacy on 03/22/2000 12:00am

    Originally posted by: Ellen Lay

    In the interest of letting a user use your propert sheet application multiple times before it quits, how could you use a modeless propertysheet to do this. Inquiring minds are dying to know.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Moving from an on-premises environment to Office 365 does not remove the need to plan for disruptions or reduce the business risk requirements for protecting email services. If anything, some risks increase with a move to the cloud. Read how to ease the transition every business faces if considering or already migrating to cloud email. This white paper discusses: Setting expectations when migrating to Office 365 Understanding the implications of relying solely on Exchange Online security Necessary archiving …

  • As the mobile enterprise marketplace expands and customer needs grow more diverse, Samsung recognizes that solution partners and developers play an essential role by continually innovating to meet their customers' needs. Samsung works to provide these developers and partners with the latest tools and resources needed to create these solutions. Read this program guide to learn how the Samsung Enterprise Alliance Program provides partners and developers with Samsung enterprise software development kits (SDKs) …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date