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.

174 lines
3.9 KiB

  1. // coming soon: new deskbar (old deskbar moved to browbar base class)
  2. #include "priv.h"
  3. #include "sccls.h"
  4. #include "resource.h"
  5. #include "deskbar.h"
  6. #define SUPERCLASS CDockingBar
  7. //*** CDeskBar_CreateInstance --
  8. //
  9. STDAPI CDeskBar_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppunk, LPCOBJECTINFO poi)
  10. {
  11. // aggregation checking is handled in class factory
  12. CDeskBar *pwbar = new CDeskBar();
  13. if (pwbar) {
  14. *ppunk = SAFECAST(pwbar, IDockingWindow*);
  15. return S_OK;
  16. }
  17. return E_OUTOFMEMORY;
  18. }
  19. //***
  20. // NOTES
  21. // REARCHITECT: nuke this, fold it into CDeskBar_CreateInstance
  22. HRESULT DeskBar_Create(IUnknown** ppunk, IUnknown** ppbs)
  23. {
  24. HRESULT hres;
  25. *ppunk = NULL;
  26. if (ppbs)
  27. *ppbs = NULL;
  28. CDeskBar *pdb = new CDeskBar();
  29. if (!pdb)
  30. return E_OUTOFMEMORY;
  31. IDeskBarClient *pdbc;
  32. hres = CoCreateInstance(CLSID_RebarBandSite, NULL, CLSCTX_INPROC_SERVER,
  33. IID_IDeskBarClient, (LPVOID*)&pdbc);
  34. if (SUCCEEDED(hres))
  35. {
  36. hres = pdb->SetClient(pdbc);
  37. if (SUCCEEDED(hres))
  38. {
  39. if (ppbs) {
  40. *ppbs = pdbc;
  41. pdbc->AddRef();
  42. }
  43. *ppunk = SAFECAST(pdb, IDeskBar*);
  44. }
  45. pdbc->Release();
  46. }
  47. if (FAILED(hres))
  48. {
  49. pdb->Release();
  50. }
  51. return hres;
  52. }
  53. CDeskBar::CDeskBar() : SUPERCLASS()
  54. {
  55. // We assume this object was ZERO-INITed on the heap.
  56. ASSERT(!_fRestrictionsInited);
  57. }
  58. //*** CDeskBar::IUnknown::* {
  59. HRESULT CDeskBar::QueryInterface(REFIID riid, void **ppvObj)
  60. {
  61. static const QITAB qit[] = {
  62. QITABENT(CDeskBar, IRestrict),
  63. { 0 },
  64. };
  65. HRESULT hres = QISearch(this, qit, riid, ppvObj);
  66. if (FAILED(hres))
  67. hres = SUPERCLASS::QueryInterface(riid, ppvObj);
  68. return hres;
  69. }
  70. // }
  71. //*** CDeskBar::IPersistStream*::* {
  72. HRESULT CDeskBar::GetClassID(CLSID *pClassID)
  73. {
  74. *pClassID = CLSID_DeskBar;
  75. return S_OK;
  76. }
  77. // }
  78. //*** CDeskBar::IRestrict::* {
  79. HRESULT CDeskBar::IsRestricted(const GUID * pguidID, DWORD dwRestrictAction, VARIANT * pvarArgs, DWORD * pdwRestrictionResult)
  80. {
  81. HRESULT hr = S_OK;
  82. if (!EVAL(pguidID) || !EVAL(pdwRestrictionResult))
  83. return E_INVALIDARG;
  84. *pdwRestrictionResult = RR_NOCHANGE;
  85. if (IsEqualGUID(RID_RDeskBars, *pguidID))
  86. {
  87. if (!_fRestrictionsInited)
  88. {
  89. _fRestrictionsInited = TRUE;
  90. if (SHRestricted(REST_NOCLOSE_DRAGDROPBAND))
  91. _fRestrictDDClose = TRUE;
  92. else
  93. _fRestrictDDClose = FALSE;
  94. if (SHRestricted(REST_NOMOVINGBAND))
  95. _fRestrictMove = TRUE;
  96. else
  97. _fRestrictMove = FALSE;
  98. }
  99. switch(dwRestrictAction)
  100. {
  101. case RA_DRAG:
  102. case RA_DROP:
  103. case RA_ADD:
  104. case RA_CLOSE:
  105. if (_fRestrictDDClose)
  106. *pdwRestrictionResult = RR_DISALLOW;
  107. break;
  108. case RA_MOVE:
  109. if (_fRestrictMove)
  110. *pdwRestrictionResult = RR_DISALLOW;
  111. break;
  112. }
  113. }
  114. if (RR_NOCHANGE == *pdwRestrictionResult) // If we don't handle it, let our parents have a wack at it.
  115. hr = IUnknown_HandleIRestrict(_ptbSite, pguidID, dwRestrictAction, pvarArgs, pdwRestrictionResult);
  116. return hr;
  117. }
  118. // }
  119. //*** CDeskBar::IServiceProvider::* {
  120. HRESULT CDeskBar::QueryService(REFGUID guidService,
  121. REFIID riid, void **ppvObj)
  122. {
  123. if (ppvObj)
  124. *ppvObj = NULL;
  125. if (IsEqualGUID(guidService, SID_SRestrictionHandler))
  126. {
  127. return QueryInterface(riid, ppvObj);
  128. }
  129. return SUPERCLASS::QueryService(guidService, riid, ppvObj);
  130. }
  131. // }