FilterPropertiesBase.h

Go to the documentation of this file.
00001 
00035 #pragma once
00036 
00037 #pragma warning(push)     // disable for this header only
00038 #pragma warning(disable:4312)
00039 // DirectShow
00040 #include <streams.h>
00041 #pragma warning(pop)      // restore original warning level
00042 
00043 #include <Commctrl.h>
00044 
00045 #include <DirectShow/SettingsInterface.h>
00046 
00047 #include "resource.h"
00048 
00049 /*
00050 * From: http://msdn.microsoft.com/en-us/library/dd375010(VS.85).aspx Creating a Filter Property Page
00051 * OnConnect is called when the client creates the property page. It sets the IUnknown pointer to the filter.
00052 * OnActivate is called when the dialog is created.
00053 * OnReceiveMessage is called when the dialog receives a window message.
00054 * OnApplyChanges is called when the user commits the property changes by clicking the OK or Apply button.
00055 * OnDisconnect is called when the user dismisses the property sheet.
00056 */
00057 
00058 #define BUFFER_SIZE 256
00059 
00060 class FilterPropertiesBase : public CBasePropertyPage
00061 {
00062 public:
00063         HRESULT OnConnect(IUnknown *pUnk)
00064         {
00065                 if (pUnk == NULL)
00066                 {
00067                         return E_POINTER;
00068                 }
00069                 ASSERT(m_pSettingsInterface == NULL);
00070 
00071                 return pUnk->QueryInterface(IID_ISettingsInterface, 
00072                         reinterpret_cast<void**>(&m_pSettingsInterface));
00073         }
00074 
00075         HRESULT OnActivate(void)
00076         {
00077                 INITCOMMONCONTROLSEX icc;
00078                 icc.dwSize = sizeof(INITCOMMONCONTROLSEX);
00079                 icc.dwICC = ICC_BAR_CLASSES;
00080                 if (InitCommonControlsEx(&icc) == FALSE)
00081                 {
00082                         return E_FAIL;
00083                 }
00084 
00085                 ASSERT(m_pSettingsInterface != NULL);
00086 
00087                 return ReadSettings();
00088         }
00089 
00090         BOOL OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00091         {
00092                 //TODO: only SetDirty if the spin message was intercepted
00093                 SetDirty();
00094                 // Let the parent class handle the message.
00095                 return CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
00096         } 
00097 
00098         HRESULT OnApplyChanges(void) = 0;
00099 
00100         HRESULT OnDisconnect(void)
00101         {
00102                 if (m_pSettingsInterface)
00103                 {
00104                         m_pSettingsInterface->Release();
00105                         m_pSettingsInterface = NULL;
00106                 }
00107                 return S_OK;
00108         }
00109 protected:
00110 
00111         FilterPropertiesBase::FilterPropertiesBase(char* szName, IUnknown *pUnk, int nDialogId, int nTitleId) : 
00112         CBasePropertyPage(szName, pUnk, nDialogId, nTitleId),
00113                 m_pSettingsInterface(NULL)
00114         {;}
00115 
00116         virtual HRESULT ReadSettings() = 0;
00117 
00118 
00119         void SetDirty()
00120         {
00121                 m_bDirty = TRUE;
00122                 if (m_pPageSite)
00123                 {
00124                         m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
00125                 }
00126         }
00127 
00128 
00129         ISettingsInterface* m_pSettingsInterface;    // Pointer to the filter's custom interface.
00130 };
00131 

Generated on Fri Mar 13 14:12:38 2009 for RTVC by  doxygen 1.5.3