Click here to Skip to main content
Click here to Skip to main content

Enabling context help in a PropertySheet embedded in another PropertySheet

, 14 Jun 2005
Rate this:
Please Sign up or sign in to vote.
Context sensitive help does not work for a PropertySheet embedded within the page of another PropertySheet.

Overview

This is a very short article to show a solution for context sensitive help problem for a propertysheet embedded within the page of another propertysheet. The help command gets swallowed by the system and help is not shown.

While recently upgrading the help system for one of our applications from WinHelp to HTML help, we noticed that the context sensitive help of a propertysheet embedded in the page of another sheet was not being shown. After much tracing around through the MFC source and reading MSDN, I realized that when a propertysheet gets the WM_HELPINFO message which is sent by ::IsDialogMessage(), it is not processed correctly due to the sheet having the window style of WS_CHILD.

The fix

Once I had identified the problem, the fix comes quite easily.

  1. Inherit your own class from CPropertySheet.

    This class should be used to replace the existing embedded sheet object in your property page.

  2. Map the WM_HELPINFO message.

    This is the message we need to map to fix the problem.

// add the header function prototype
afx_msg BOOL OnHelpInfo(HELPINFO * pHelpInfo);

// add the message map entry
ON_WM_HELPINFO()

// add the function code
BOOL CPropertySheetEx::OnHelpInfo(HELPINFO* pHelpInfo)
{
    BOOL ret = FALSE;
    bool handled = false;

    if (GetStyle() & WS_CHILD)
    {
        // were an embedded property sheet, need to pass up 
        // the chain to get this message processed correctly
        CWnd * pWnd = GetParent();
        while (pWnd != NULL && pWnd->GetStyle() & WS_CHILD)
        {
            // move up the window heirarchy while 
            // finding child windows
            pWnd = pWnd->GetParent();
        }
        if (pWnd != NULL)
        {
            ret = GetParent()->GetParent()->SendMessage(WM_HELP, 
                                         0, (LPARAM)(pHelpInfo));
            handled = true;
        }
        // the sheet does not have a non child parent, 
        // some kind of problem!
        ASSERT(handled);    
    }
    if (!handled)
    {
        ret = CPropertySheet::OnHelpInfo(pHelpInfo);
    }
    return ret;
}

And that's it, everything should now work correctly.

License

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

Share

About the Author

Roger Allen
Software Developer (Senior) Sirius Analytical Instruments
United Kingdom United Kingdom
A research and development programmer working for a pharmaceutical instrument company for the past 17 years.
 
I am one of those lucky people who enjoys his work and spends more time than he should either doing work or reseaching new stuff. I can also be found on playing DDO on the Cannith server (Send a tell to "Maetrim" who is my current main)
 
I am also a keep fit fanatic, doing cross country running and am seriously into [url]http://www.ryushinkan.co.uk/[/url] Karate at this time of my life, training from 4-6 times a week and recently achieved my 1st Dan after 6 years.

Comments and Discussions

 
QuestionHow to embed a property sheet into an other one Pinmemberpaulgafa19-Jul-06 19:41 

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.

| Advertise | Privacy | Mobile
Web01 | 2.8.140826.1 | Last Updated 14 Jun 2005
Article Copyright 2005 by Roger Allen
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid