Creating a full application using the CPropertySheet


Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame

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 08: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 07: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 08: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 07: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 07: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 08: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 08:00am

    Originally posted by: Bogdan

    Use the property sheet app wizard at
    http://codeguru.developer.com/propertysheet/PropSheet_Wizard.shtml, and you'll have your application generated.

  • How to get notification on tab change/changing?

    Posted by Legacy on 04/23/1999 07: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 07: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.

  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

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