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

  • Enterprise cloud adoption has evolved rapidly from fringe curiosity to the mainstream. As enterprises increasingly move mission-critical workloads to the cloud, it's important to track best practices to ensure a seamless migration process. While CIOs are becoming increasingly mature and pragmatic in their approach to cloud, surprises and challenges still need to be addressed. Read this eBook to learn the key best practices for cloud deployment success, the importance of SLAs in choosing a cloud provider, and …

  • This IDC study assists senior IT leaders in assessing the current state of their hybrid cloud management processes, governance models, technologies, and skills to identify gaps and create a road map for better aligning the organization's management model and tools with the emerging needs of complex, dynamic self-service hybrid cloud environments. This IDC MaturityScape identifies five maturity stages for hybrid cloud management based on a set of specific people, process, and technology dimensions and outcomes. …

Most Popular Programming Stories

More for Developers

RSS Feeds

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