Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 lines
5.5 KiB

  1. /*--------------------------------------------------------------------------*
  2. *
  3. * Microsoft Windows
  4. * Copyright (C) Microsoft Corporation, 1999
  5. *
  6. * File: MMCAxWin.h
  7. *
  8. * Contents: Header file for CMMCAxWindow
  9. *
  10. * History: 30-Nov-99 VivekJ Created
  11. *
  12. *--------------------------------------------------------------------------*/
  13. #pragma once
  14. DEFINE_COM_SMARTPTR(IHTMLElement2); // IHTMLElement2Ptr
  15. DEFINE_COM_SMARTPTR(IElementBehaviorFactory); // IElementBehaviorFactoryPtr
  16. /*+-------------------------------------------------------------------------*
  17. * HACK_CAN_WINDOWLESS_ACTIVATE
  18. *
  19. * Bug 451918: By default, the ATL OCX host window supports hosting
  20. * windowless controls. This differs from the MMC 1.2 implementation
  21. * of the OCX host window (which used MFC), which did not. Some controls
  22. * (e.g. Disk Defragmenter OCX) claim to support windowless activation
  23. * but do not.
  24. *
  25. * For compatibility, we must only instantiate result pane OCX's as
  26. * windowed controls. IInPlaceSiteWindowless (implemented by CAxHostWindow)
  27. * gives us a nice clean way to do this, by returning S_FALSE from
  28. * CanWindowlessActivate. We instruct CAxHostWindow to do this by changing its
  29. * AllowWindowlessActivation property.
  30. *
  31. * There's a problem with that, however. ATL21 has a bug where it tests
  32. * for CanWindowlessActivate returning a FAILED code rather than S_FALSE.
  33. * This means that even if we use put_AllowWindowlessActivation, ATL21-based
  34. * controls will still try to activate windowless.
  35. *
  36. * We'll fix this problem by deriving a class, CMMCAxHostWindow, from
  37. * CAxHostWindow which will return E_FAIL instead of S_FALSE if windowless
  38. * activation is not desired.
  39. *--------------------------------------------------------------------------*/
  40. #define HACK_CAN_WINDOWLESS_ACTIVATE
  41. /*+-------------------------------------------------------------------------*
  42. * class CMMCAxWindow
  43. *
  44. *
  45. * PURPOSE: The MMC-specific version of CAxWindow. Contains any fixes and
  46. * updates.
  47. * Refer to the December 1999 issue of Microsoft Systems Journal
  48. * for details, in the article "Extending ATL3.0 Control Containers
  49. * to Help you write Real-World Containers."
  50. *
  51. *+-------------------------------------------------------------------------*/
  52. class CMMCAxWindow : public CAxWindowImplT<CMMCAxWindow, CAxWindow2>
  53. {
  54. #ifdef HACK_CAN_WINDOWLESS_ACTIVATE
  55. public:
  56. HRESULT AxCreateControl2(LPCOLESTR lpszName, HWND hWnd, IStream* pStream, IUnknown** ppUnkContainer, IUnknown** ppUnkControl = 0, REFIID iidSink = IID_NULL, IUnknown* punkSink = 0);
  57. #endif
  58. // Simply override of CAxWindow::SetFocus that handles more special cases
  59. // NOTE: this is not a virtual method. Invoking on base class pointer will
  60. // endup in executing other method.
  61. // this method is added mainly to cope with bug 433228 (MMC2.0 Can not tab in a SQL table)
  62. HWND SetFocus();
  63. };
  64. /*+-------------------------------------------------------------------------*
  65. * CMMCAxHostWindow
  66. *
  67. * Simple class that overrides IInPlaceSiteWindowless::CanWindowlessActivate
  68. * to work around an ATL21 bug. See comments for HACK_CAN_WINDOWLESS_ACTIVATE
  69. * for details.
  70. *--------------------------------------------------------------------------*/
  71. class CMMCAxHostWindow : public CAxHostWindow
  72. {
  73. #ifdef HACK_CAN_WINDOWLESS_ACTIVATE
  74. public:
  75. #ifdef _ATL_HOST_NOLOCK
  76. typedef CComCreator< CComObjectNoLock< CMMCAxHostWindow > > _CreatorClass;
  77. #else
  78. DECLARE_POLY_AGGREGATABLE(CMMCAxHostWindow)
  79. #endif
  80. STDMETHOD(CanWindowlessActivate)()
  81. {
  82. return m_bCanWindowlessActivate ? S_OK : E_FAIL /*S_FALSE*/;
  83. }
  84. // Added to solve bug 453609 MMC2.0: ActiveX container: Painting problems with the device manager control
  85. // implements workarround for DISPID_AMBIENT_SHOWGRABHANDLES and DISPID_AMBIENT_SHOWHATCHING
  86. // the actual bug is in ALT 3.0 (atliface.idl)
  87. STDMETHOD(Invoke)( DISPID dispIdMember, REFIID riid, LCID lcid,
  88. WORD wFlags, DISPPARAMS FAR* pDispParams,
  89. VARIANT FAR* pVarResult, EXCEPINFO FAR* pExcepInfo,
  90. unsigned int FAR* puArgErr);
  91. // Added to solve bug 453609 MMC2.0: ActiveX container: Painting problems with the device manager control
  92. // Since ATL 3.0 does not implement it, we have to do it to make MFC controls happy
  93. STDMETHOD(OnPosRectChange)(LPCRECT lprcPosRect);
  94. #if _ATL_VER <= 0x0301
  95. BEGIN_MSG_MAP(CMMCAxHostWindow)
  96. MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
  97. CHAIN_MSG_MAP(CAxHostWindow)
  98. END_MSG_MAP()
  99. // We handle focus here specifically because of bogus implementation in ATL 3.0
  100. // ATL tests m_bInPlaceActive instead of m_bUIActive.
  101. // We need to test this rigorously so that we don't break other snapins.
  102. // See bug 433228 (MMC2.0 Can not tab in a SQL table)
  103. LRESULT OnSetFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled);
  104. #else
  105. #error The code above was added as fix to bug in ATL 3.0; It needs to be revisited
  106. // since:
  107. // a) the bug may be fixed on newer ATL versions;
  108. // b) it relies on variables defined in ATL, which may change;
  109. #endif
  110. #endif /* HACK_CAN_WINDOWLESS_ACTIVATE */
  111. public:
  112. STDMETHOD(QueryService)( REFGUID rsid, REFIID riid, void** ppvObj); // used to supply the default behavior factory
  113. private:
  114. IElementBehaviorFactoryPtr m_spElementBehaviorFactory;
  115. };
  116. #include "mmcaxwin.inl"