Add property page in DirectShow Filter

Source: Internet
Author: User

Create a DirectShow property page and add an attribute page to the cball filter.

Perform the following steps:
 1. inherit the ispecifypropertypages class from the class of the property to be displayed, and implement the getpages () function of this class.


As follows:
HresultStdmethodcalltype cbouncingball: getpages (cauuid * ppages)
{
  If (ppages = NULL) return e_pointer;
  Ppages-> celems = 1;
  Ppages-> pelems = reinterpret_cast (cotaskmemalloc (sizeof (guid )));
   (Guid *) cotaskmemalloc (sizeof (guid ));
  If (ppages-> pelems = NULL)
  {
   Return e_outofmemory;
  }
  * (Ppages-> pelems) = clsid_myballprop;
  Return s_ OK;
}


The (ppages-> pelems) pointer array points to the CLSID of all attribute pages, which was previously defined and registered.


// Guid on the property page
Define_guid (clsid_myballprop, 0xa9bd4eb, 0xded5,
0x4df0, 0xba, 0xf6, 0x2c, 0xea, 0x23, 0xf5, 0x72, 0x61 );
Definition in the class factory:
Cfactorytemplate g_templates [] = {
 {L "Bouncing Ball"
  , & Clsid_bouncingball
  , Cbouncingball: createinstance
  , Null
  , & Sudballax },
 
 {
  L "my ball page ",
   & Clsid_myballprop,
   Cballprop: createinstance,
   Null,
   Null
 }


 2. Supports QueryInterface, that is, implementing the overload cunknown: nondelegatingqueryinterfAce Functions
First, declare that your filter contains the declare_iunknown macro:
 Public:
 Declare_iunknown;
 Then the interface function is exposed as follows:
 Hresult stdmethodcalltype cbouncingball: nondelegatingqueryinterfACE (refiid riid, void ** GMM)
{
 Checkpointer (GMM, e_pointer );
 
 If (riid = iid_ballparas) // The actual filter interface is exposed here, for example, some parameters need to be set.
 {
       Return getinterface (iballpara *) This, GMM );
   }
 
  Else if (riid = iid_ispecifypropertypages)// This is the interface for exposing the property page to display the property page
 {
      Return getinterface (ispecifypropertypages *) This, GMM );
   }
 Else

 
 Return cbasefilter: nondelegatingqueryinterfACE (riid, GMM );
}


3.Create property page
Insert a dialog box resource and set the attribute to child and notitlebar. Add the required controls.
Create a class that inherits the cbasepropertypage class. The first two functions must be implemented:
Cunknown * winapi cballprop: createinstance (lpunknown punk, hresult * phr)
{
 Cunknown * punk = new cballprop (punk );
 
 If (null = punk)
 {
 * Phr = e_outofmemory;
 }
 
 Return punk;
}

Call the constructor.
Cballprop: cballprop (iunknown * punk ):
Cbasepropertypage (name ("grayprop"), punk, idd_dialog_ballpara (ID of the information in the dialog box), and ids_title)
, M_pballpara (null), m_bisinitialized (false), m_ballcolour (idc_radio_blue)
{
 // Mibouncingball = NULL;
}
By now, you can add your filter to greatedit, so right-click it to view your property page.
The following steps are required to complete data interaction:

4. Create a virtual class that inherits iunknow, such as iballpara, and use pure virtual functions to represent the interface functions to be implemented.
For example:
Declare_interface _ (iballpara, iunknown)
 {
  Stdmethod (getballpara) (This _ int * colornum) pure;
  Stdmethod (setballpara) (This _ int colornum) pure;
 }; // Declare two simple parameter settings and the obtained functions.
Inherit this virtual class from the class of the primary filter (that is, the filter interface to be introduced) and implement these pure virtual functions in heavy load.


5. Define an interface virtual class pointer in the property page class, such as iballpara * ptrballpara,
And implement the following interactive functions.
Onconnect: When an attribute page is created, you can use the QueryInterface method to obtain the pointer instance (for the primary filter)
For example, HR = punknown-> QueryInterface (iid_ballparas, (void **) & m_pballpara );
The function calls the interface function we most want to implement to complete data interaction.
Onactivate is called when the dialog box is created. Obtain the parameter values in the filter to initialize the dialog box.
Onreceivemessage is called when the dialog box receives a window message and changes the status of the dialog box.
Onapplychanges: Click OK or apply to update the attribute parameters.
The function assigns the new value to the attribute parameter of the filter.
Ondisconnect is called when the user cancels the property sheet.

Add property page in DirectShow Filter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.