Click here to Skip to main content
13,254,077 members (61,957 online)
Click here to Skip to main content
Add your own
alternative version


20 bookmarked
Posted 25 May 2003

Property sheet callbacks in the Pocket PC 2002

, 25 May 2003
Rate this:
Please Sign up or sign in to vote.
How to insert title and footer links in Pocket PC property sheets, using MFC

Sample Image - CePropertySheet.jpg


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.


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.


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

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.



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


About the Author

João Paulo Figueira
Software Developer (Senior) Frotcom International
Portugal Portugal
I work on R&D for Frotcom International, a company that develops web-based fleet management solutions.

You may also be interested in...

Comments and Discussions

Questionmenu bar not appearing on the command bar for VS 2008 migrated from evc++ 4.0 Pin
Member 1095000816-Jul-14 0:18
memberMember 1095000816-Jul-14 0:18 
QuestionLicensing Pin
MKahlow1-Oct-07 8:50
memberMKahlow1-Oct-07 8:50 
AnswerRe: Licensing Pin
Joao Paulo Figueira2-Oct-07 22:29
memberJoao Paulo Figueira2-Oct-07 22:29 
General&quot;Please enter an integer&quot; Problem! Pin
epeyman19-Jul-05 13:21
memberepeyman19-Jul-05 13:21 
GeneralRe: &quot;Please enter an integer&quot; Problem! Pin
João Paulo Figueira20-Jul-05 7:23
memberJoão Paulo Figueira20-Jul-05 7:23 
GeneralRe: &quot;Please enter an integer&quot; Problem! Pin
epeyman21-Jul-05 10:45
memberepeyman21-Jul-05 10:45 
GeneralRe: &quot;Please enter an integer&quot; Problem! Pin
epeyman21-Jul-05 13:36
memberepeyman21-Jul-05 13:36 
GeneralRe: &quot;Please enter an integer&quot; Problem! Pin
epeyman28-Jul-05 7:05
memberepeyman28-Jul-05 7:05 
GeneralRe: &quot;Please enter an integer&quot; Problem! Pin
rohinivn13-Mar-07 23:50
memberrohinivn13-Mar-07 23:50 
GeneralTitle Pin
Marco Giuntoni13-Oct-04 1:17
memberMarco Giuntoni13-Oct-04 1:17 
GeneralRe: Title Pin
João Paulo Figueira13-Oct-04 1:35
memberJoão Paulo Figueira13-Oct-04 1:35 
Generalintegration Pin
OsoPolar8-Oct-04 7:45
memberOsoPolar8-Oct-04 7:45 
GeneralRe: integration Pin
João Paulo Figueira8-Oct-04 7:51
memberJoão Paulo Figueira8-Oct-04 7:51 
GeneralRe: integration Pin
OsoPolar12-Oct-04 23:35
memberOsoPolar12-Oct-04 23:35 
QuestionCan not run on STANDARDSDK_420 Pin
Dungoi6-Sep-04 21:06
memberDungoi6-Sep-04 21:06 
AnswerRe: Can not run on STANDARDSDK_420 Pin
João Paulo Figueira6-Sep-04 23:37
memberJoão Paulo Figueira6-Sep-04 23:37 
Questioncode modification?? Pin
benahpets1-Sep-04 4:35
memberbenahpets1-Sep-04 4:35 
AnswerRe: code modification?? Pin
João Paulo Figueira1-Sep-04 4:45
memberJoão Paulo Figueira1-Sep-04 4:45 
GeneralProblem Pin
benahpets31-Aug-04 4:45
memberbenahpets31-Aug-04 4:45 
GeneralRe: Problem Pin
João Paulo Figueira31-Aug-04 5:34
memberJoão Paulo Figueira31-Aug-04 5:34 
GeneralRe: Problem Pin
benahpets31-Aug-04 5:37
memberbenahpets31-Aug-04 5:37 
GeneralRe: Problem Pin
João Paulo Figueira31-Aug-04 5:46
memberJoão Paulo Figueira31-Aug-04 5:46 
GeneralRe: Problem Pin
benahpets31-Aug-04 5:55
memberbenahpets31-Aug-04 5:55 
GeneralRe: Problem Pin
João Paulo Figueira31-Aug-04 6:19
memberJoão Paulo Figueira31-Aug-04 6:19 
GeneralRe: Problem Pin
benahpets31-Aug-04 6:35
memberbenahpets31-Aug-04 6:35 
GeneralProperty Sheet in ViewDocument Pin
Antonio Lezzi23-Apr-04 8:34
memberAntonio Lezzi23-Apr-04 8:34 
Questionis it possible to change the title if the propertysheet is active? Pin
Taoge29-Sep-03 21:38
memberTaoge29-Sep-03 21:38 
AnswerRe: is it possible to change the title if the propertysheet is active? Pin
João Paulo Figueira29-Sep-03 23:06
memberJoão Paulo Figueira29-Sep-03 23:06 
GeneralThis Was Very Helpful Pin
John Simmons / outlaw programmer20-Jun-03 5:46
memberJohn Simmons / outlaw programmer20-Jun-03 5:46 
Generalthanks, great Pin
ldr28-May-03 5:29
memberldr28-May-03 5:29 
GeneralNice ... but one question ... Pin
Daniel S.26-May-03 21:08
memberDaniel S.26-May-03 21:08 
GeneralRe: Nice ... but one question ... Pin
João Paulo Figueira26-May-03 22:55
memberJoão Paulo Figueira26-May-03 22:55 
GeneralRe: Nice ... but one question ... Pin
João Paulo Figueira26-May-03 23:01
memberJoão Paulo Figueira26-May-03 23:01 
GeneralRe: Nice ... but one question ... Pin
Daniel S.27-May-03 23:50
memberDaniel S.27-May-03 23:50 
GeneralRe: Nice ... but one question ... Pin
João Paulo Figueira28-May-03 4:47
memberJoão Paulo Figueira28-May-03 4:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    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 | Terms of Use | Mobile
Web03 | 2.8.171114.1 | Last Updated 26 May 2003
Article Copyright 2003 by João Paulo Figueira
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid