Using ON_UPDATE_COMMAND_UI in Property Pages

Using ON_UPDATE_COMMAND_UI message maps in property pages is the same as in dialogs except for one extra step required.
You need to derive a class from CPropertySheet and intercept the WM_KICKIDLE messages.

1. Use class wizard to create a new class called CMyPropSheet with a base class of CPropertSheet.
2. In the header add the message function. afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM, LPARAM);
3. In the source file #include afxpriv.h
4. Add the message map ON_MESSAGE(WM_KICKIDLE, OnKickIdle)
5. Implement the function.

LRESULT CMyPropSheet::OnKickIdle(WPARAM, LPARAM)
{
	SendMessageToDescendants(WM_WM_KICKIDLE, 0, 0, FALSE, FALSE);
	return 0;
}

The property sheet now passes all WM_KICKIDLE message to its property pages.

In the property page class, just add a message map for WM_KICKIDLE and call UpdateDialogControls.

LRESULT CMyPropPage::OnKickIdle(WPARAM, LPARAM)
{
	UpdateDialogControls(this, FALSE);
	return 0L;
}

Then all you need is ON_UPDATE_COMMAND_UI message maps.

P.S. This does not work for modeless property sheets. You need to trap the WM_IDLEUPDATECMDUI message in the property sheet's owner window and send it WK_KICKIDLE messages.

Date Posted: 08/13/98



Comments

  • Perfect! I looked far and wide for this.

    Posted by Legacy on 02/01/2002 12:00am

    Originally posted by: Zhiyong He

    Thanks very much.

    Reply
  • Thanks Tim!

    Posted by Legacy on 03/18/2001 12:00am

    Originally posted by: Artem

    /

    Reply
  • great! but why ContinueModal doesn't work?

    Posted by Legacy on 12/24/1999 12:00am

    Originally posted by: Xiang

    Just what i want! but why overriding ContinueModal() doesn't work? which works well in dlg based app. OnkickIdle works too there. I think the key is sending msg to propertypage

    Reply
  • A small change

    Posted by Legacy on 08/01/1999 12:00am

    Originally posted by: Jonathan Schafer

    I too have used this method.  However, instead of use SendMessageToDescendents, I use 
    
    

    CPropertyPage* pActivePage=GetActivePage();
    if (NULL==pActivePage)
    return lParam <= 2;

    return pActivePage->SendMessage(WM_KICKIDLE, wParam, lParam);

    This way, I only send the message to the active page, as it is the only one I'm interested in updating.

    Reply
  • Great!

    Posted by Legacy on 07/09/1999 12:00am

    Originally posted by: Ernie Cooper

    This was exactly what I was looking for. I have the "MFC Answer Book" which describes how to do it for dialogs but not for property sheets.

    Your post gets me what I need, thanks.

    Ernie Cooper

    Reply
  • Fantastic! Just what I was looking for.

    Posted by Legacy on 05/07/1999 12:00am

    Originally posted by: Whitney Kew

    Title says it all - this code was exactly what I was looking for. Good job, and thanks!

    Reply
  • Few typos

    Posted by Legacy on 03/22/1999 12:00am

    Originally posted by: Tim Lewis

    I think it should be OnKickIdle instead of OnIdleUpdateCommandUI. Also, should be WM_KICKIDLE instead of WM_WM_KICKIDLE.

    Picky, I know, but...

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

Top White Papers and Webcasts

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 23, 2014 @ 12:00 p.m. ET / 9:00 a.m. PT Despite the current "virtualize everything" mentality, there are advantages to utilizing physical hardware for certain tasks. This is especially true for backups. In many cases, it is clearly in an organization's best interest to make use of physical, purpose-built backup appliances rather than relying on virtual backup software (VBA - Virtual Backup Appliances). Join us for this eSeminar to learn why physical appliances are preferable to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds