UIActiveX.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. friend class CActiveXCtrl;
  23. public:
  24. CActiveXUI();
  25. virtual ~CActiveXUI();
  26. LPCTSTR GetClass() const;
  27. LPVOID GetInterface(LPCTSTR pstrName);
  28. UINT GetControlFlags() const;
  29. HWND GetNativeWindow() const;
  30. bool IsDelayCreate() const;
  31. void SetDelayCreate(bool bDelayCreate = true);
  32. bool CreateControl(const CLSID clsid);
  33. bool CreateControl(LPCTSTR pstrCLSID);
  34. HRESULT GetControl(const IID iid, LPVOID* ppRet);
  35. CLSID GetClisd() const;
  36. CDuiString GetModuleName() const;
  37. void SetModuleName(LPCTSTR pstrText);
  38. void SetVisible(bool bVisible = true);
  39. void SetInternVisible(bool bVisible = true);
  40. void SetPos(RECT rc, bool bNeedInvalidate = true);
  41. void Move(SIZE szOffset, bool bNeedInvalidate = true);
  42. void DoPaint(HDC hDC, const RECT& rcPaint);
  43. void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  44. LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, bool& bHandled);
  45. protected:
  46. virtual void ReleaseControl();
  47. virtual bool DoCreateControl();
  48. protected:
  49. CLSID m_clsid;
  50. CDuiString m_sModuleName;
  51. bool m_bCreated;
  52. bool m_bDelayCreate;
  53. IOleObject* m_pUnk;
  54. CActiveXCtrl* m_pControl;
  55. HWND m_hwndHost;
  56. };
  57. } // namespace DuiLib
  58. #endif // __UIACTIVEX_H__