UIActiveX.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #ifndef __UIACTIVEX_H__
  2. #define __UIACTIVEX_H__
  3. #pragma once
  4. struct IOleObject;
  5. namespace DuiLib {
  6. /////////////////////////////////////////////////////////////////////////////////////
  7. //
  8. class CActiveXCtrl;
  9. template< class T >
  10. class CSafeRelease
  11. {
  12. public:
  13. CSafeRelease(T* p) : m_p(p) { };
  14. ~CSafeRelease() { if( m_p != NULL ) m_p->Release(); };
  15. T* Detach() { T* t = m_p; m_p = NULL; return t; };
  16. T* m_p;
  17. };
  18. /////////////////////////////////////////////////////////////////////////////////////
  19. //
  20. class UILIB_API CActiveXUI : public CControlUI, public IMessageFilterUI
  21. {
  22. DECLARE_DUICONTROL(CActiveXUI)
  23. friend class CActiveXCtrl;
  24. public:
  25. CActiveXUI();
  26. virtual ~CActiveXUI();
  27. LPCTSTR GetClass() const;
  28. LPVOID GetInterface(LPCTSTR pstrName);
  29. HWND GetHostWindow() const;
  30. virtual bool IsDelayCreate() const;
  31. virtual void SetDelayCreate(bool bDelayCreate = true);
  32. virtual bool IsMFC() const;
  33. virtual void SetMFC(bool bMFC = false);
  34. bool CreateControl(const CLSID clsid);
  35. bool CreateControl(LPCTSTR pstrCLSID);
  36. HRESULT GetControl(const IID iid, LPVOID* ppRet);
  37. CLSID GetClisd() const;
  38. CDuiString GetModuleName() const;
  39. void SetModuleName(LPCTSTR pstrText);
  40. void SetVisible(bool bVisible = true);
  41. void SetInternVisible(bool bVisible = true);
  42. void SetPos(RECT rc, bool bNeedInvalidate = true);
  43. void Move(SIZE szOffset, bool bNeedInvalidate = true);
  44. bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
  45. void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  46. LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
  47. protected:
  48. virtual void ReleaseControl();
  49. virtual bool DoCreateControl();
  50. protected:
  51. CLSID m_clsid;
  52. CDuiString m_sModuleName;
  53. bool m_bCreated;
  54. bool m_bDelayCreate;
  55. bool m_bMFC;
  56. IOleObject* m_pUnk;
  57. CActiveXCtrl* m_pControl;
  58. HWND m_hwndHost;
  59. };
  60. } // namespace DuiLib
  61. #endif // __UIACTIVEX_H__