Creating a full application using the CPropertySheet

Hello Windows Programmers.

I discovered recently that it is possible to create a full application using the CPropertySheet as the class for the main window of the application.

If you read the source of the small demo you will understand better what i mean.

I created a new class named CSheet that has CPropertySheet as the base class.
CSheet does have four member variables of type CPropertyPage, named: Page1, Page2, Page3 and Page4.
It also contains a CMenu variable.

When the CSheet constructor is called i am creating the four pages and i am adding them to the property sheet.

CSheet is overloading the virtual OnInitDialog function and in this function its doing two thinks.
1) Hides the property sheet buttons OK, CANCEL and APPLY.
2) Loads the applications menu.

	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 );
		return TRUE;
CSheet does have a message map, which redirects the menu message to the display member function which displays the page selected.

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


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


After defining the CSheet class, i am creating a CWinApp derived class that creates a CSheet Window as its main window and thats all.
I have an application that is based on CPropertySheet as the main window class.

I hope that my code will help you.
May the SOURCE be with you.

Download demo project - 91KB

Date Posted: 05/03/98


  • How to change this application to a wizard-like

    Posted by Legacy on 04/02/2003 12:00am

    Originally posted by: Egor

    I tried SetWizardMode() and got an error.

    Any suggestion would be appreciated.

  • When you add the menu, buttons get chopped off at bottom...

    Posted by Legacy on 09/18/2002 12:00am

    Originally posted by: Tam Bui


    I downloaded the source and got it to work. However, when
    I comment the part that hides the OK, CANCEL, and APPLY
    Buttons, I noticed that they were not within the Property
    Sheet window size. They got chopped in half. How do I
    resize the Property Sheet to fit everything, including the
    menu and Property Sheet buttons? Please e-mail me if you
    can help!

  • Your example was very useful!

    Posted by Legacy on 12/08/2001 12:00am

    Originally posted by: Antonio Ramirez

    Thanks for your example, some times it is needed a small but compiled source code.

  • How to add icon?

    Posted by Legacy on 09/05/2001 12:00am

    Originally posted by: hong

    How to add an icon on the window title?

  • How do you add a Minimize Button on the Caption Bar??

    Posted by Legacy on 06/14/2001 12:00am

    Originally posted by: HP

    Could you tell me how do you add a Minimize button on the Caption Bar of this application?


  • Preventing ENTER key from closing the dialog

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

    Originally posted by: Ian Littlewood

    Preventing this type of application from exiting when the ENTER key is pressed requires a different approach than with CDialog-derived applications.

    When you hit ENTER inside this type of app, the framework first calls CPropertyPage::OnApply(). If CPropertyPage::OnApply() returns TRUE, then CPropertyPage::OnOK() is called. By this point, it's already too late to prevent the dialog-box from closing as the next call is to DestroyWindow().

    What you have to do is provide an implementation for OnApply() in your CPropertyPage-derived class(es) and ensure that it always returns FALSE. This effectively prevents OnOK() from being called.

    The downside is that clicks on the OK button are tricky -- easiest work-around is to hide the default OK button and provide your own.

    You also may have to manually ghost your APPLY button as it will never ghost on it's own (OnApply() does return FALSE all the time, after-all!) :)

    Hope someone finds this useful.

    - Ian

  • There is an app wizard for doing this

    Posted by Legacy on 11/12/1999 12:00am

    Originally posted by: Bogdan

    Use the property sheet app wizard at, and you'll have your application generated.

  • How to get notification on tab change/changing?

    Posted by Legacy on 04/23/1999 12:00am

    Originally posted by: Murray Bilker

    I created a propertysheet application like this example
    with no real problem. I can't seem to get an on_notify
    message to let me know when the user has selected a new
    property page. I am trying the OnSelChange and OnSelChanging
    messages but apparently I'm doing something wrong.

    Need help (other than mental).



  • do it with AppWizard

    Posted by Legacy on 04/09/1999 12:00am

    Originally posted by: Konstantin Avdeev

    I found that a pretty simple way to make an application that
    is CPropertySheet based, is to create the DialogBased app with
    AppWizard and then change some code (and add some of yours, of course)
    in YourAppDlg.cpp and YourAppDlg.h.
    That way you have CAboutDlg created for you by AppWizard and most of
    the code in OnInitDialog() that handles icon drawing,
    OnSysCommand() and OnQueryDragIcon(). I discarded OnPaint() immediately,
    so I'm not sure if you can use it without changing or if you can use it at all.
    You just have to change "CDialog" to "CPropertySheet" in most places,
    change constructor and a bit of other code.

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

Top White Papers and Webcasts

  • On-demand EventEvent Date: March 21, 2017 With the rise in ransomware attacks, bank heists that reached new levels of sophistication, and extortion plots that were beyond anything we could have imagined, 2016 certainly was an eventful year for cybersecurity. Going into 2017, no business can afford to be uninformed about cybersecurity or unprepared for an attack. Watch this informative webinar, presented by Andrey Pozhogin, Senior B2B Product Marketing Manager at Kaspersky Lab, as he examines predictions for …

  • Speed. Agility. Flexibility. There are the big drivers behind most organizations' move to the cloud for their test/dev environments. Freed from the shackles of physical, on-premises infrastructures means test/dev teams can be incredibly fast, both in standing up and tearing down test beds. They can manage version control and they can share work between teams faster ever than below. Read this white paper to learn how your business can respond faster to the rapidly changing needs of customers with a cloud-based …

Most Popular Programming Stories

More for Developers

RSS Feeds

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