Creating a Property Sheet Inside a Form View

This topic was contributed by Asaf Levy.

Form views (CFormView) can do almost anything you want: you can easily shape and modify it, process its control's messages, and communicate with the document. It's like creating a very important dialog box.

Property sheet (CPropertySheet) is also a very convinient and simple way to gather and display information. You create property pages using the dialog template editor, and simply add them to the propery sheet's object. Most importantly, the property sheet takes care of all the page's notification messages for you. All you have to be worried about is what your code will do, not where it is routed to, and who is actually getting it (each page intercepts its own IDC_blahblah's messages).

But, have you ever tried putting a propery sheet inside a form view, together with other controls like buttons, check boxes, list boxes, ect...? Sure, you can use the tab control (CTabControl), given in the dialog template editor. But who will take care of all the notification messages? YOU?? no way!! And how will you create the page's interfaces? BY HAND?? no way!!

To my opinion, these two reasons if far from enough to convince a sane programmer to look for a way out: property sheets inside a form view! It handels your notification messages and lets you add editable dialog templates to the sheet - what more can you possibly ask??

Now, lets look at how you do this. This task has a few simple steps:

Step 1: Create a "place holder" control in your form view's template

You have to create a control that will function as a place holder for the property sheet control. The most suitable control is the picture control: it will be the sheet's parent window. Make sure the control is Visible, and that it's on type Frame. Make it big enough to include the pages in it. Lets suppose that its ID of the picture control is IDC_PLACEHOLDER.

Step 2: Create a derived CPropertySheet class

Create a class derived from CPropertySheet using ClassWizard (lets call it CMyPropertySheet), and leave only one constructor with the parent window as its parameter:
	CMyPropSheet(CWnd* pParentWnd = NULL);

Step 3: Add a pointer to the derived property sheet class in your form view class

In your derived form view class, add a pointer to the newly created derived property sheet class, so you can refer to it and use it later:
	CMyPropSheet* m_pMyPropSheet;

Step 4: Add code in CMyFormView::OnInitialUpdate() to create your property sheet

Create a handler to WM_INITIALUPDATE in CMyFromView, and after the call to CFormView::OnInitialUpdate(), add code to create a Modeless Property Sheet and associate it with the place holder control.
	// create and asociated the property sheet with the "place holder" window
	CWnd* pwndPropSheetHolder = GetDlgItem(IDC_PLACEHOLDER);
	m_pMyPropSheet = new CMyPropSheet(pwndPropSheetHolder);
	if (!m_pMyPropSheet->Create(pwndPropSheetHolder, 
		WS_CHILD | WS_VISIBLE, 0))
	{
		delete m_pMyPropSheet;
		m_pMyPropSheet = NULL;
		return;
	}

	// fit the property sheet into the place holder window, and show it
	CRect rectPropSheet;
	pwndPropSheetHolder->GetWindowRect(rectPropSheet);
	m_pMyPropSheet->SetWindowPos(NULL, 0, 0,
		rectPropSheet.Width(), rectPropSheet.Height(),
		SWP_NOZORDER | SWP_NOACTIVATE);

Step 5: Create the pages by deriving from CPropertyPage

Create as many classes as you wish which are derived from CPropertyPage using ClassWizard, and leave them as they are (you will later handle the page control's specific messages there). Associate a different IDD_blahblah to every class.

Step 6: Add the page's objects as member variables to the propery sheet class

Declare objects of your page's derived types (as was created in step 5), and put them in the class declaration of your derived property sheet:
	CMyPage1 m_pageMy1;
	CMyPage2 m_pageMy2;
	......

Step 7: Add page insertion code in the derived property sheet's constructor

Now you will associate the page's objects to your property sheet, by adding them to the sheet, using the CPropertySheet::AddPage(...) function.

Note: Here i put the code in the sheet's constructor, so it will be done automatically, but you can put this code anywhere you want in the derived property sheet class.

CMyPropSheet::CMyPropSheet(CWnd* pParentWnd)
	:CPropertySheet(AFX_IDS_APP_TITLE, pParentWnd)
{
	AddPage(&m_pageMy1);
	AddPage(&m_pageMy2);
	......
}
That's it. If you compile and run your application, you will now get a fully functional property sheets with pages you can edit easily!

All you have to do now is add message handlers in each page to the page's own control. Have Fun!!



Comments

  • where you can buy the cheapest clarisonic mia

    Posted by iouwanzi on 06/06/2013 03:01am

    [url=http://www.miaclarisonicaustralia.org/clarisonic-classic]clarisonic classic[/url] Elle devait examiner un individu ghd IV Styler avant vers le bas les avantages de l’utilisation de lisseur ghd pas cher dans Vous pouvez aussi le plus souvent de prêt-à-utiliser de l’huile durcit à intégrer les huiles végétales avec de l’huile de sésame, l’huile d’olive et de noix de coco.ghd lisseur est énorme à l’intérieur du Questionnaire, votre défrisants impliquant dela crème de la crème. L’idée n’est pas si énorme qu’aux États-Unis, qui à son tour, j’ai trouvé étrange, néanmoins je pense de la nation pour la raison que de toutes les quelques autres marques qui ont été si grands qui peut être à ce point moins décent. [url=http://www.australiaclarisonic.com/clarisonic-pro]clarisonic pro[/url] our bikini fluo avec des chandails effet de perspective au crochet, plus la féminité très sexy se tailler grosses boucles, mais pas simple. Sexy niveau populaire, tant de belles femmes a eu à envier. En fait, voulez vous débarrasser d’enfantin, d’augmenter féminin, approprié propres cheveux bouclés, mais très sculpté points de Oh! Un beau bébé et Miranda Kerr d’Australie mérite d’être un modèle de Freaky, les occasions formelles ou la rue tous les jours a attiré l’attention du public. Bien que chaque forme est différente, mais pas difficile à trouver, la plupart des enfants peuvent préférer cette exclusion boucles. [url=http://www.australiaclarisonic.com/]clarisonic brush[/url] Le courant autres avantages est la taxe avec la hausse des températures internationales. Les secondes (optimales avec 10!) après que commutation autour de la conception et de style, du sculpter va à son pouvoir alerte aux États-Unis qu’il est prêt à devenir employé. C’est vraiment un gain de temps grave de souche, même si professionnellement j’ai réellement en aucune façon utilisent mon fer plat personnel chaque fois que je suis rempli à l’intérieur.

    Reply
  • International News - gucci Believed A Necessity In recent times

    Posted by incockDak on 03/29/2013 08:03am

    The Secret dominate the longchamp-scene Is Pretty Straightforward! [url=http://growth-management.alachua.fl.us/comprehensive_planning/gucci.html]バック グッチ[/url] The Trick For gucci [url=http://growth-management.alachua.fl.us/comprehensive_planning/saclongchamp.php]Sac longchamps[/url] VygIqsEzrZbr [url=http://running-nike0.seesaa.net/]nike ランニング[/url]ItzYmcJfqNhd [[url=http://free-nike-nikeo.seesaa.net/]ナイキ フリー[/url]VghUiyYuyGiy [url=http://xn--nike-ul4c5c5fyqb.seesaa.net/]nike スニーカー[/url]BcpAvaXxdFnq [url=http://nikejapan0.seesaa.net/]ナイキスニーカー[/url]PjrHytHsfNyo [url=http://nikesneakersjp.seesaa.net/]nike[/url]YizInnIhvOal [url=http://nikegolf00.seesaa.net/]ナイキゴルフ[/url]FokZpxIlfPui [url=http://nikeshoes00.seesaa.net/]nike シューズ[/url]HemWmhCpqOzl [url=http://sneaker-adidas-jp.seesaa.net/]スニーカー アディダス[/url]ViqRioRyxIht

    Reply
  • How the bvlgari purse Enterprise Dialogue - - Who cares is successful?

    Posted by expopmerm on 03/22/2013 08:30pm

    [url=http://www.mcmoutletjpinoue.com]mcm 通販[/url] The things Folks Despises Regarding mcm And also Reason why [url=http://www.mcmsalejapanoka.com]mcm リュック 激安[/url] Interesting Challenges All mcm Fanatic Really Should Have A Go With [url=http://www.mcmzankijpshop.com]mcm 店舗[/url] The Way To Steer Clear Of mcm Complications Brief piece of content reveals the incontestable facts about bvlgari purse and how it can have an effect you. [url=http://www.bvlgarishopjprie.com]ブルガリブルガリ[/url] The best key for the bvlgari purse that you can discover more about straight away. [url=http://www.bvlgarioutletshopjp.com]ブルガリ 時計[/url] The main reason why no one is writing about bvlgari purse and because of that know what you ought to complete as we speak. [url=http://www.bvlgarisalekodojp.com]ブルガリ チョコレート[/url] Something that the competition engages in regarding bvlgari purse and consequently the thing that youwant to do different. [url=http://www.bvlgarisakaijpsale.com]ブルガリブルガリ[/url] bvlgari purse Replicas ; An Awesome bvlgari purse 'cheat' Which experts state Fools 93% of the end users [url=http://www.bvlgariaokisalejp.com]ブルガリ[/url] Results-oriented tricks of bvlgari purse that you can use beginning immediately. What You Want To Be Informed On About mcm And The Actual Reason Why [url=http://www.mcmbagsjphadori.com]mcm リュック[/url] Creative Options Into mcm Never Ever Before Revealed [url=http://www.mcmstorejpkodo.com]mcm[/url] Little Known Ways To Rule By Using mcm

    Reply
  • Goal

    Posted by snareenactina on 11/06/2012 07:51pm

    impinge News of a global economic crisis has dominated the headlines in recent months. Reports of the effects of this crisis come from as far as Iceland, Japan, and Brazil, with reports of unemployment rates spiking across the world. But the roots of this crisis are in the U.S. economy. You ve got to see it this way:zeitgeist is talking for a society with humans who care for one another,have dignity,are honest and have all the qualities we all should be looking for and try for ourselves to achieve.If you see it from the perspective of such a human ,its all possible.It wouldnt need any measures to stop the population from growing ,it would be the logic assumption to make that it is your responsibillity to keep the population within the resources abillities.And the same would be for everyone else.all humans would know ther is a problem with feeding more humans,for example,and everyone would make his /her bit ,to protect the species .and his /her own happiness and sufficiency of resources during their lifetime.Oh well ,it is not highly propable .and i hate it that i have to say this. The country, which has a rather tumultuous economic history, is today the fifth largest economy in the world and the third largest in Europe. schofield The Budget Southern African fleet is made up of over 9000 cars, offering economy, luxury and speciality vehicles, all with an average age of 6 to 9 months. World class marques form an integral part of the fleet mix, with all vehicles offering the latest safety features, and always at competitive prices. marblese The factors keeping interest rates low won’t last, says Ken Rogoff tosfos As a result of their conditional independence from Great Britain in 1922, the Egyptian royal family issued a Royal Decree establishing a national flag. This first flag was a major step for Egypt, and its colors were green with a white crescent and three stars in the middle. scalding During the 2010 Earthquake, the Port-au-Prince port suffered widespread damage, impeding aid to the victims. The main pier caved in and fell into the water. One of the main cranes also collapsed in the water. Port access roads were severely damaged as well. anytimeto As the anniversary of the first issue of Domestic Economy approaches, we can’t help but lament that another edition is long overdue. So it’s with great excitement and hefty expectations that we announce a call for submissions. The theme, as for all good Americans, is consumption; specifically, we want to talk about food. colin Get the latest savings by email serenades Robbins, Lionel (1932) 1937 An Essay on the Nature and Significance of Economic Science. 2d ed., rev. & enl. London: Macmillan.

    Reply
  • WONDERFUL tutorial

    Posted by vpappas on 11/03/2004 11:13am

    This was a great article. I have had a bit of trouble finding a clear explanation of how to use property sheets/pages and this article made it easy. Plus, it taught me why I don't want to use the tab control that comes with the VC++ resource editor. THANKS!!!!

    Reply
  • Thanks

    Posted by Legacy on 01/15/2004 12:00am

    Originally posted by: Alex K

    ^^

    Reply
  • how to call different views to different tab

    Posted by Legacy on 12/25/2003 12:00am

    Originally posted by: kalyani

    i want to create interface like workspace in vc++ application. i taken one sdi application and splitted into two portions. in left panel i want to create tabsheetand on each tab click it has to be display one view. like workspace having three tab sheets (classwizard and fileview nad resource view) how i will get that one. please help me.
    
    

    Reply
  • Thanks!

    Posted by Legacy on 10/28/2003 12:00am

    Originally posted by: Johnny Serup

    I implemented this not for FormView, but inside a Dialog box, so initial update is done in OnInitDialog before CDialog::OnInitDialog(), and it works perfect.

    Do you by any chance know how to set the tab's in the buttom instead of the top ???

    Reply
  • Can I move the tabs to the bottom?

    Posted by Legacy on 10/22/2003 12:00am

    Originally posted by: Frank Perry

    I need to use a touch screen and would like the tabs on the bottom so the user's hand doesn't block the view of the screen. Propertysheets do this if they are created from from the tools list but I can't find a way to change them when they are created this way. Ideas?

    Frank Perry

    Reply
  • Error C2440

    Posted by Legacy on 07/29/2003 12:00am

    Originally posted by: DimiGR

    I am getting an error:

    error C2440: 'static_cast' : cannot convert from 'void (__thiscall CFormView::* )(void)'
    to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'

    None of the functions with this name in scope match the target type

    It has somthing to do with the WM_INITIALUPDATE handler.
    Can some1 post the hole handler def. and decl. here?

    THX in advance

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

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • Packaged application development teams frequently operate with limited testing environments due to time and labor constraints. By virtualizing the entire application stack, packaged application development teams can deliver business results faster, at higher quality, and with lower risk.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds