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

END_MESSAGE_MAP()

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

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


Comments

  • 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.

    Reply
  • 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

    Hi,
    
    

    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!


    Reply
  • 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.

    Reply
  • 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?

    Reply
  • 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?

    Thank!

    Reply
  • 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

    Reply
  • 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
    http://codeguru.developer.com/propertysheet/PropSheet_Wizard.shtml, and you'll have your application generated.

    Reply
  • 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).

    Thanks,

    Murray

    Reply
  • 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.

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

Top White Papers and Webcasts

  • Live Event Date: August 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • With 81% of employees using their phones at work, companies have stopped asking: "Is corporate data leaking from personal devices?" and started asking: "How do we effectively prevent corporate data from leaking from personal devices?" The answer has not been simple. ZixOne raises the bar on BYOD security by not allowing email data to reside on the device. In addition, Zix allows employees to maintain complete control of their personal device, therefore satisfying privacy demands of valued employees and the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds