共用方式為


Step 4. Create the Property Page

 
Microsoft DirectShow 9.0

Step 4. Create the Property Page

At this point the filter supports everything that it needs for a property page. The next step is implementing the property page itself. Start by deriving a new class from CBasePropertyPage. The following example shows part of the declaration, including some private member variables that will be used later in the example:

class CGrayProp : public CBasePropertyPage
{
private:
    ISaturation *m_pGray;    // Pointer to the filter's custom interface.
    long        m_lVal       // Store the old value, so we can revert.
    long        m_lNewVal;   // New value.
public:
    /* ... */
};

Next, create a dialog resource in the resource editor, along with a string resource for the dialog title. The string will appear in the tab for the property page. The two resource IDs are arguments to the CBasePropertyPage constructor:

CGrayProp::CGrayProp(IUnknown *pUnk) : 
  CBasePropertyPage(NAME("GrayProp"), pUnk, IDD_PROPPAGE, IDS_PROPPAGE_TITLE),
  m_pGray(0)
{ }

The following illustration shows the dialog resource for the example property page.

Property Page Dialog

Now you are ready to implement the property page. Here are the methods in CBasePropertyPage to override:

  • OnConnect is called when the client creates the property page. It sets the IUnknown pointer to the filter.
  • OnActivate is called when the dialog is created.
  • OnReceiveMessage is called when the dialog receives a window message.
  • OnApplyChanges is called when the user commits the property changes by clicking the OK or Apply button.
  • OnDisconnect is called when the user dismisses the property sheet.

The remainder of this tutorial describes each of these methods.

Next: Step 5. Store a Pointer to the Filter.

See Also