Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Step 7. Handle Window Messages

Override the CBasePropertyPage::OnReceiveMessage method to update the dialog controls in response to user input. If you don't handle a particular message, call the OnReceiveMessage method on the parent class. Whenever the user changes a property, do the following:

  • Set the m_bDirty variable of the property page to TRUE.
  • Call the IPropertyPageSite::OnStatusChange method of the property frame with the PROPPAGESTATUS_DIRTY flag. This flag informs the property frame that it should enable the Apply button. The CBasePropertyPage::m_pPageSite member holds a pointer to the IPropertyPageSite interface.

To simplify this step, you can add the following helper function to your property page:

    void SetDirty()
        m_bDirty = TRUE;
        if (m_pPageSite)

Call this private method inside OnReceiveMessage whenever a user action changes a property, as shown in the following example:

BOOL CGrayProp::OnReceiveMessage(HWND hwnd,
    UINT uMsg, WPARAM wParam, LPARAM lParam)
    switch (uMsg)
    case WM_COMMAND:
        if (LOWORD(wParam) == IDC_DEFAULT)
            // User clicked the 'Revert to Default' button.
            m_lNewVal = SATURATION_DEFAULT;

            // Update the slider control.
            SendDlgItemMessage(m_Dlg, IDC_SLIDER1, TBM_SETPOS, 1,
            return (LRESULT) 1;

    case WM_HSCROLL:
            // User moved the slider.
            case TB_PAGEDOWN:
            case SB_THUMBTRACK:
            case TB_PAGEUP:
                m_lNewVal = SendDlgItemMessage(m_Dlg, IDC_SLIDER1,
                    TBM_GETPOS, 0, 0);
            return (LRESULT) 1;
    } // Switch.
    // Let the parent class handle the message.
    return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);

The property page in this example has two controls, a slider bar and a Revert to Default button. If the user scrolls the slider bar, the property page sets the saturation value on the filter. If the user clicks the button, the property page restores the filter's default saturation value. In each case, m_lNewVal holds the current value and m_lVal holds the original value. The value of m_lVal is not updated until the user commits the change, which happens when the user clicks the OK or Apply button on the property frame.

Next: Step 8. Apply Property Changes.

Related topics

Creating a Filter Property Page



Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2014 Microsoft. All rights reserved.