Click here to Skip to main content
Licence CPOL
First Posted 25 May 2003
Views 86,992
Downloads 75
Bookmarked 20 times

Property sheet callbacks in the Pocket PC 2002

By | 25 May 2003 | Article
How to insert title and footer links in Pocket PC property sheets, using MFC

Sample Image - CePropertySheet.jpg

Introduction

This article describes a scarcely documented feature of Pocket PC 2002 property sheets: how to include a title and a footer with link. Both title and footer will be present in all pages of the property sheet. This article also shows how to hide the application menu bar, like a standard CDialog.

Callbacks

Both titles and footers are implemented through a callback function present in all MFC handled property sheets, through CPropertySheet. The callback function address is stored in the pfnCallback member of the PROPSHEETHEADER structure stored in CPropertySheet's m_psh member. When you create a property sheet, MFC will fill in this pointer with the address of its own handler, AfxPropSheetCallback. This callback handles the PSCB_INITIALIZED and PSCB_GETVERSION messages. This is needed in order to put the tabs in the bottom, and to report which version of the controls, the property sheet is using. But we can do more with this callback: we can use it to insert a title and a footer, just like the property sheet in the demo project (see picture).

In order to access these functionalities, we must handle the PSCB_GETTITLE and PSCB_GETLINKTEXT messages in the callback. The problem is that MFC has already provided one callback for the property sheet, so how can we provide our own callback function? The answer is very simple: we hook it.

CCePropertySheet

All the relevant code is in the CCePropertySheet class. This class derives from MFC's CPropertySheet, and specializes its functionality in the following aspects:

  • Provides a standard CCeCommandBar;
  • Inserts a caption taken from the constructor parameters;
  • Allows the user to insert a footer with an optional link.

Using CCePropertySheet

Using the class is very straightforward:

CLinkSheet    dlg(_T("Link"));

dlg.SetLink(_T("Start <file:pword.exe{Word}>"));
dlg.DoModal();

The first line declares the object (derived from CCePropertySheet). The second line sets the footer link text. Finally, the dialog is called.

Implementing CCePropertySheet

The class is not complex, as you can see from the source code.

The first thing we have to do is hook the callback function (see HookCallback). This function is called from the constructors, where we store the sheet's caption in a static CString. When HookCallback is called, MFC has already stored its own callback function pointer in m_psh.pfnCallback. The pointer is stored in a static member, and is replaced by the class' own callback.

Serving the callback is quite straightforward. The title and link messages are checked for and served. The MFC callback is always called to handle the message, so we retain all the functionality we already know. Serving the messages means copying the specific strings to the address given by lParam.

Finally, the OnInitDialog handler is used to create an empty CCeCommandBar. Besides hiding the application's command bar, this can be used as a regular command bar, meaning you can insert menus and buttons.

Note that both m_strLink and m_strTitle are static member variables. This is required because they are both referenced by the callback function that must be static itself (will not receive the implicit this in the parameter list). Also, note that these variables are only accessed once, during the property sheet creation cycle. If you need to create a second property sheet as a result of a command issued by the first, you can be sure that the overridden string values will have no effect on the first property sheet.

Thanks

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Joao Paulo Figueira

Software Developer
Primeworks
Portugal Portugal

Member

João is a partner at Primeworks, a company that develops remote database access software for Windows Mobile. He also works for Frotcom, a company that develops web-based fleet management solutions.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionLicensing PinmemberMKahlow7:50 1 Oct '07  
AnswerRe: Licensing PinmemberJoao Paulo Figueira21:29 2 Oct '07  
General"Please enter an integer" Problem! Pinmemberepeyman12:21 19 Jul '05  
GeneralRe: "Please enter an integer" Problem! PinmemberJoão Paulo Figueira6:23 20 Jul '05  
GeneralRe: "Please enter an integer" Problem! Pinmemberepeyman9:45 21 Jul '05  
GeneralRe: "Please enter an integer" Problem! Pinmemberepeyman12:36 21 Jul '05  
GeneralRe: "Please enter an integer" Problem! Pinmemberepeyman6:05 28 Jul '05  
GeneralRe: "Please enter an integer" Problem! Pinmemberrohinivn22:50 13 Mar '07  
GeneralTitle PinmemberMarco Giuntoni0:17 13 Oct '04  
GeneralRe: Title PinmemberJoão Paulo Figueira0:35 13 Oct '04  
Generalintegration PinmemberOsoPolar6:45 8 Oct '04  
GeneralRe: integration PinmemberJoão Paulo Figueira6:51 8 Oct '04  
GeneralRe: integration PinmemberOsoPolar22:35 12 Oct '04  
QuestionCan not run on STANDARDSDK_420 PinmemberDungoi20:06 6 Sep '04  
AnswerRe: Can not run on STANDARDSDK_420 PinmemberJoão Paulo Figueira22:37 6 Sep '04  
Questioncode modification?? Pinmemberbenahpets3:35 1 Sep '04  
AnswerRe: code modification?? PinmemberJoão Paulo Figueira3:45 1 Sep '04  
GeneralProblem Pinmemberbenahpets3:45 31 Aug '04  
GeneralRe: Problem PinmemberJoão Paulo Figueira4:34 31 Aug '04  
GeneralRe: Problem Pinmemberbenahpets4:37 31 Aug '04  
GeneralRe: Problem PinmemberJoão Paulo Figueira4:46 31 Aug '04  
GeneralRe: Problem Pinmemberbenahpets4:55 31 Aug '04  
GeneralRe: Problem PinmemberJoão Paulo Figueira5:19 31 Aug '04  
GeneralRe: Problem Pinmemberbenahpets5:35 31 Aug '04  
GeneralProperty Sheet in ViewDocument PinmemberAntonio Lezzi7:34 23 Apr '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120528.1 | Last Updated 26 May 2003
Article Copyright 2003 by Joao Paulo Figueira
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid