Source code of Windows XP (NT5)
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.

159 lines
3.1 KiB

  1. #include "priv.h"
  2. #include "bands.h"
  3. ULONG CToolBand::AddRef()
  4. {
  5. _cRef++;
  6. return _cRef;
  7. }
  8. ULONG CToolBand::Release()
  9. {
  10. ASSERT(_cRef > 0);
  11. _cRef--;
  12. if (_cRef > 0)
  13. return _cRef;
  14. delete this;
  15. return 0;
  16. }
  17. HRESULT CToolBand::QueryInterface(REFIID riid, void **ppvObj)
  18. {
  19. static const QITAB qit[] = {
  20. QITABENT(CToolBand, IDeskBand), // IID_IDeskBand
  21. QITABENTMULTI(CToolBand, IOleWindow, IDeskBand), // IID_IOleWindod
  22. QITABENTMULTI(CToolBand, IDockingWindow, IDeskBand), // IID_IDockingWindow
  23. QITABENT(CToolBand, IInputObject), // IID_IInputObject
  24. QITABENT(CToolBand, IObjectWithSite), // IID_IObjectWithSite
  25. QITABENT(CToolBand, IPersistStream), // IID_IPersistStream
  26. { 0 },
  27. };
  28. return QISearch(this, qit, riid, ppvObj);
  29. }
  30. HRESULT CToolBand::GetWindow(HWND * lphwnd)
  31. {
  32. *lphwnd = _hwnd;
  33. if (*lphwnd)
  34. return(S_OK);
  35. else
  36. return(E_FAIL);
  37. }
  38. HRESULT CToolBand::TranslateAcceleratorIO(LPMSG lpMsg)
  39. {
  40. return E_NOTIMPL;
  41. }
  42. HRESULT CToolBand::HasFocusIO()
  43. {
  44. HRESULT hres;
  45. HWND hwndFocus = GetFocus();
  46. hres = SHIsChildOrSelf(_hwnd, hwndFocus);
  47. return hres;
  48. }
  49. HRESULT CToolBand::UIActivateIO(BOOL fActivate, LPMSG lpMsg)
  50. {
  51. ASSERT(NULL == lpMsg || IS_VALID_WRITE_PTR(lpMsg, MSG));
  52. if (!_fCanFocus)
  53. {
  54. return S_FALSE;
  55. }
  56. if (fActivate)
  57. {
  58. // UnkOnFocusChangeIS(_punkSite, SAFECAST(this, IInputObject*), TRUE);
  59. SetFocus(_hwnd);
  60. }
  61. return S_OK;
  62. }
  63. // }
  64. HRESULT CToolBand::ResizeBorderDW(LPCRECT prcBorder,
  65. IUnknown* punkToolbarSite,
  66. BOOL fReserved)
  67. {
  68. return S_OK;
  69. }
  70. HRESULT CToolBand::ShowDW(BOOL fShow)
  71. {
  72. return S_OK;
  73. }
  74. HRESULT CToolBand::SetSite(IUnknown *punkSite)
  75. {
  76. if (punkSite != _punkSite)
  77. {
  78. IUnknown_Set(&_punkSite, punkSite);
  79. IUnknown_GetWindow(_punkSite, &_hwndParent);
  80. }
  81. return S_OK;
  82. }
  83. HRESULT CToolBand::_BandInfoChanged()
  84. {
  85. VARIANTARG v = {0};
  86. VARIANTARG* pv = NULL;
  87. if (_dwBandID != (DWORD)-1)
  88. {
  89. v.vt = VT_I4;
  90. v.lVal = _dwBandID;
  91. pv = &v;
  92. }
  93. else
  94. {
  95. // if this fires, fix your band's GetBandInfo to set _dwBandID.
  96. // o.w. it's a *big* perf loss since we refresh *all* bands rather
  97. // than just yours.
  98. // do *not* remove this ASSERT, bad perf *is* a bug.
  99. ASSERT(_dwBandID != (DWORD)-1);
  100. }
  101. return IUnknown_Exec(_punkSite, &CGID_DeskBand, DBID_BANDINFOCHANGED, 0, pv, NULL);
  102. }
  103. CToolBand::CToolBand() : _cRef(1)
  104. {
  105. _dwBandID = (DWORD)-1;
  106. _hwnd = NULL;
  107. _hwndParent = NULL;
  108. _fCanFocus = TRUE;
  109. _dwBandID = -1;
  110. _punkSite = NULL;
  111. DllAddRef();
  112. }
  113. CToolBand::~CToolBand()
  114. {
  115. DllRelease();
  116. }
  117. HRESULT CToolBand::CloseDW(DWORD dw)
  118. {
  119. if (_hwnd)
  120. {
  121. DestroyWindow(_hwnd);
  122. _hwnd = NULL;
  123. }
  124. return S_OK;
  125. }
  126. HRESULT CToolBand::IsDirty(void)
  127. {
  128. return S_FALSE; // never be dirty
  129. }
  130. HRESULT CToolBand::GetSizeMax(ULARGE_INTEGER *pcbSize)
  131. {
  132. return E_NOTIMPL;
  133. }