cprop.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //------------------------------------------------------------------------------
  2. // File: CProp.h
  3. //
  4. // Desc: DirectShow base classes.
  5. //
  6. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  7. //------------------------------------------------------------------------------
  8. #ifndef __CPROP__
  9. #define __CPROP__
  10. // Base property page class. Filters typically expose custom properties by
  11. // implementing special control interfaces, examples are IDirectDrawVideo
  12. // and IQualProp on renderers. This allows property pages to be built that
  13. // use the given interface. Applications such as the ActiveMovie OCX query
  14. // filters for the property pages they support and expose them to the user
  15. //
  16. // This class provides all the framework for a property page. A property
  17. // page is a COM object that supports IPropertyPage. We should be created
  18. // with a resource ID for the dialog which we will load when required. We
  19. // should also be given in the constructor a resource ID for a title string
  20. // we will load from the DLLs STRINGTABLE. The property page titles must be
  21. // stored in resource files so that they can be easily internationalised
  22. //
  23. // We have a number of virtual methods (not PURE) that may be overriden in
  24. // derived classes to query for interfaces and so on. These functions have
  25. // simple implementations here that just return NOERROR. Derived classes
  26. // will almost definately have to override the message handler method called
  27. // OnReceiveMessage. We have a static dialog procedure that calls the method
  28. // so that derived classes don't have to fiddle around with the this pointer
  29. class AM_NOVTABLE CBasePropertyPage : public IPropertyPage, public CUnknown
  30. {
  31. protected:
  32. LPPROPERTYPAGESITE m_pPageSite; // Details for our property site
  33. HWND m_hwnd; // Window handle for the page
  34. HWND m_Dlg; // Actual dialog window handle
  35. BOOL m_bDirty; // Has anything been changed
  36. int m_TitleId; // Resource identifier for title
  37. int m_DialogId; // Dialog resource identifier
  38. static INT_PTR CALLBACK DialogProc(HWND hwnd,
  39. UINT uMsg,
  40. WPARAM wParam,
  41. LPARAM lParam);
  42. private:
  43. BOOL m_bObjectSet ; // SetObject has been called or not.
  44. public:
  45. CBasePropertyPage(__in_opt LPCTSTR pName, // Debug only name
  46. __inout_opt LPUNKNOWN pUnk, // COM Delegator
  47. int DialogId, // Resource ID
  48. int TitleId); // To get tital
  49. #ifdef UNICODE
  50. CBasePropertyPage(__in_opt LPCSTR pName,
  51. __inout_opt LPUNKNOWN pUnk,
  52. int DialogId,
  53. int TitleId);
  54. #endif
  55. virtual ~CBasePropertyPage() { };
  56. DECLARE_IUNKNOWN
  57. // Override these virtual methods
  58. virtual HRESULT OnConnect(IUnknown *pUnknown) {
  59. return NOERROR;
  60. };
  61. virtual HRESULT OnDisconnect() {
  62. return NOERROR;
  63. };
  64. virtual HRESULT OnActivate() {
  65. return NOERROR;
  66. };
  67. virtual HRESULT OnDeactivate() {
  68. return NOERROR;
  69. };
  70. virtual HRESULT OnApplyChanges() {
  71. return NOERROR;
  72. };
  73. virtual INT_PTR OnReceiveMessage(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam);
  74. // These implement an IPropertyPage interface
  75. STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);
  76. STDMETHODIMP_(ULONG) NonDelegatingRelease();
  77. STDMETHODIMP_(ULONG) NonDelegatingAddRef();
  78. STDMETHODIMP SetPageSite(__in_opt LPPROPERTYPAGESITE pPageSite);
  79. STDMETHODIMP Activate(HWND hwndParent, LPCRECT prect,BOOL fModal);
  80. STDMETHODIMP Deactivate(void);
  81. STDMETHODIMP GetPageInfo(__out LPPROPPAGEINFO pPageInfo);
  82. STDMETHODIMP SetObjects(ULONG cObjects, __in_ecount_opt(cObjects) LPUNKNOWN *ppUnk);
  83. STDMETHODIMP Show(UINT nCmdShow);
  84. STDMETHODIMP Move(LPCRECT prect);
  85. STDMETHODIMP IsPageDirty(void) {
  86. return m_bDirty ? S_OK : S_FALSE;
  87. }
  88. STDMETHODIMP Apply(void);
  89. STDMETHODIMP Help(LPCWSTR lpszHelpDir) {
  90. return E_NOTIMPL;
  91. }
  92. STDMETHODIMP TranslateAccelerator(__inout LPMSG lpMsg) {
  93. return E_NOTIMPL;
  94. }
  95. };
  96. #endif // __CPROP__