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

IT Offers

Comments

  • There are no comments yet. Be the first to comment!

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

Go Deeper

  • This interactive white paper from CIO Magazine and EMC lays out the benefits of big data and predictive analytics, provides tips on how to …
  • This buyers guide provides independent research and test results to help you determine your endpoint protection requirements and identify …
  • When the economy is stable, a company's IT organization may view Finance as just one of many internal customers competing for attention. But …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds