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.

277 lines
10 KiB

  1. #ifndef _bandsite_h
  2. #define _bandsite_h
  3. #ifdef __cplusplus
  4. extern "C" { /* Assume C declarations for C++ */
  5. #endif /* __cplusplus */
  6. #define SZ_REGKEY_GLOBALADMINSETTINGS TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\IEAK")
  7. #define SZ_REGVALUE_GLOBALADMINSETTINGS TEXT("Admin Band Settings")
  8. // Admin Settings (dwAdminSettings)
  9. #define BAND_ADMIN_NORMAL 0x00000000
  10. #define BAND_ADMIN_NODDCLOSE 0x00000001 // Disable Drag & Drop, and Close
  11. #define BAND_ADMIN_NOMOVE 0x00000002 // Disable Moving within a Bar.
  12. #define BAND_ADMIN_ADMINMACHINE 0x80000000 // This is an admin machine and this bit displays the two Admin Context Menu items
  13. BOOL BandSite_HandleMessage(IUnknown *punk, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres);
  14. void BandSite_SetMode(IUnknown *punk, DWORD dwMode);
  15. BOOL ConfirmRemoveBand(HWND hwnd, UINT uID, LPCTSTR szName);
  16. #ifdef WANT_CBANDSITE_CLASS
  17. // UIActivateIO callback instance data
  18. typedef struct tagACTDATA {
  19. LPMSG lpMsg; // IN
  20. HRESULT hres;
  21. IUnknown *punk;
  22. } ACTDATA;
  23. // this is a converted struct. the reason why its a class is to get refcounting.
  24. // let everybody get to the member vars.
  25. class CBandItemData
  26. {
  27. public:
  28. CBandItemData() : _cRef(1) {}
  29. ULONG AddRef() { return InterlockedIncrement(&_cRef); }
  30. ULONG Release() { ULONG cRef = InterlockedDecrement(&_cRef); if (0 == cRef) delete this; return cRef; }
  31. HWND hwnd;
  32. IDeskBand *pdb;
  33. IWinEventHandler *pweh;
  34. POINTL ptMinSize;
  35. POINTL ptMaxSize;
  36. POINTL ptIntegral;
  37. POINTL ptActual;
  38. WCHAR szTitle[256];
  39. DWORD dwModeFlags;
  40. DWORD dwBandID;
  41. BITBOOL fShow:1; // current show state
  42. BITBOOL fNoTitle:1; // 1:don't show title
  43. DWORD dwAdminSettings;
  44. COLORREF crBkgnd;
  45. private:
  46. LONG _cRef;
  47. };
  48. typedef int (*PFNBANDITEMENUMCALLBACK)(CBandItemData *pbid, LPVOID pData);
  49. int _UIActIOCallback(CBandItemData *pbid, void *pv);
  50. typedef struct {
  51. HRESULT hres;
  52. const GUID * pguidService;
  53. const IID * piid;
  54. void ** ppvObj;
  55. } QSDATA;
  56. int _QueryServiceCallback(CBandItemData *pbid, void *pv);
  57. #include "caggunk.h"
  58. class CBandSite : public CAggregatedUnknown
  59. , public IBandSite
  60. , public IInputObjectSite
  61. , public IInputObject
  62. , public IDeskBarClient
  63. , public IWinEventHandler
  64. , public IPersistStream
  65. , public IDropTarget
  66. , public IServiceProvider
  67. , public IBandSiteHelper
  68. , public IOleCommandTarget
  69. {
  70. public:
  71. // *** IUnknown ***
  72. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj) { return CAggregatedUnknown::QueryInterface(riid, ppvObj);};
  73. virtual STDMETHODIMP_(ULONG) AddRef(void) { return CAggregatedUnknown::AddRef();};
  74. virtual STDMETHODIMP_(ULONG) Release(void) { return CAggregatedUnknown::Release();};
  75. // *** IPersistStream methods ***
  76. virtual STDMETHODIMP GetClassID(CLSID *pClassID);
  77. virtual STDMETHODIMP IsDirty(void);
  78. virtual STDMETHODIMP Load(IStream *pStm);
  79. virtual STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty);
  80. virtual STDMETHODIMP GetSizeMax(ULARGE_INTEGER *pcbSize);
  81. // *** IBandSite methods ***
  82. virtual STDMETHODIMP AddBand(IUnknown* punk);
  83. virtual STDMETHODIMP EnumBands(UINT uBand, DWORD* pdwBandID);
  84. virtual STDMETHODIMP QueryBand(DWORD dwBandID, IDeskBand** ppstb, DWORD* pdwState, LPWSTR pszName, int cchName);
  85. virtual STDMETHODIMP SetBandState(DWORD dwBandID, DWORD dwMask, DWORD dwState);
  86. virtual STDMETHODIMP RemoveBand(DWORD dwBandID);
  87. virtual STDMETHODIMP GetBandObject(DWORD dwBandID, REFIID riid, LPVOID* ppvObj);
  88. virtual STDMETHODIMP SetBandSiteInfo(const BANDSITEINFO * pbsinfo);
  89. virtual STDMETHODIMP GetBandSiteInfo(BANDSITEINFO * pbsinfo);
  90. // *** IOleWindow methods ***
  91. virtual STDMETHODIMP GetWindow(HWND * lphwnd);
  92. virtual STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode) { return E_NOTIMPL; }
  93. // *** IInputObjectSite methods ***
  94. virtual STDMETHODIMP OnFocusChangeIS(IUnknown *punk, BOOL fSetFocus);
  95. // *** IInputObject methods ***
  96. virtual STDMETHODIMP UIActivateIO(BOOL fActivate, LPMSG lpMsg);
  97. virtual STDMETHODIMP HasFocusIO();
  98. virtual STDMETHODIMP TranslateAcceleratorIO(LPMSG lpMsg);
  99. // *** IDeskBarClient methods ***
  100. virtual STDMETHODIMP SetDeskBarSite(THIS_ IUnknown* punkSite) ;
  101. virtual STDMETHODIMP SetModeDBC (THIS_ DWORD dwMode) ;
  102. virtual STDMETHODIMP UIActivateDBC(THIS_ DWORD dwState) ;
  103. virtual STDMETHODIMP GetSize (THIS_ DWORD dwWhich, LPRECT prc);
  104. // *** IWinEventHandler methods ***
  105. virtual STDMETHODIMP OnWinEvent (HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT *plres);
  106. virtual STDMETHODIMP IsWindowOwner(HWND hwnd);
  107. // *** IDropTarget ***
  108. virtual STDMETHODIMP DragEnter(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  109. virtual STDMETHODIMP DragOver(DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  110. virtual STDMETHODIMP DragLeave(void);
  111. virtual STDMETHODIMP Drop(IDataObject *pdtobj, DWORD grfKeyState, POINTL pt, DWORD *pdwEffect);
  112. // *** IServiceProvider methods ***
  113. virtual STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, LPVOID* ppvObj);
  114. // *** IBandSiteHelper methods ***
  115. virtual STDMETHODIMP LoadFromStreamBS(IStream *pstm, REFIID riid, LPVOID *ppv);
  116. virtual STDMETHODIMP SaveToStreamBS(IUnknown *punk, IStream *pstm);
  117. // *** IOleCommandTarget ***
  118. virtual STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  119. virtual STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  120. CBandSite(IUnknown *punkAgg);
  121. protected:
  122. virtual HRESULT v_InternalQueryInterface(REFIID riid, LPVOID * ppvObj);
  123. IDeskBar* _pdb;
  124. IUnknown* _punkSite;
  125. IBandSite* _pbsOuter; // the aggregating bandsite
  126. virtual HRESULT _Initialize(HWND hwndParent);
  127. virtual void _OnCloseBand(DWORD dwBandID);
  128. virtual LRESULT _OnBeginDrag(NMREBAR* pnm);
  129. virtual LRESULT _OnNotify(LPNMHDR pnm);
  130. virtual IDropTarget* _WrapDropTargetForBand(IDropTarget* pdtBand);
  131. virtual DWORD _GetWindowStyle(DWORD* pdwExStyle);
  132. virtual HMENU _LoadContextMenu();
  133. HRESULT _OnBSCommand(int idCmd, DWORD idBandActive, CBandItemData *pbid);
  134. HRESULT _AddBand(IUnknown* punk);
  135. virtual HRESULT _OnContextMenu(WPARAM wParam, LPARAM lParam);
  136. IDataObject* _DataObjForBand(DWORD dwBandID);
  137. CBandItemData* _GetBandItemDataStructByID(DWORD uID);
  138. virtual int _ContextMenuHittest(LPARAM lParam, POINT* ppt);
  139. // container specific (rebar) members
  140. virtual BOOL _AddBandItem(CBandItemData *pbid);
  141. virtual void _DeleteBandItem(int i);
  142. CBandItemData * _GetBandItem(int i);
  143. int _GetBandItemCount();
  144. void _BandItemEnumCallback(int dincr, PFNBANDITEMENUMCALLBACK pfnCB, void *pv);
  145. void _DeleteAllBandItems();
  146. virtual void _ShowBand(CBandItemData *pbid, BOOL fShow);
  147. int _BandIDToIndex(DWORD dwBandID);
  148. DWORD _IndexToBandID(int i);
  149. DWORD _BandIDFromPunk(IUnknown* punk);
  150. HRESULT _SetBandStateHelper(DWORD dwBandID, DWORD dwMask, DWORD dwState);
  151. virtual void _UpdateAllBands(BOOL fBSOnly, BOOL fNoAutoSize);
  152. void _UpdateBand(DWORD dwBandID);
  153. BOOL _UpdateBandInfo(CBandItemData *pbid, BOOL fBSOnly);
  154. void _GetBandInfo(CBandItemData *pbid, DESKBANDINFO *pdbi);
  155. virtual void _BandInfoFromBandItem(REBARBANDINFO *prbbi, CBandItemData *pbid, BOOL fBSOnly);
  156. virtual void v_SetTabstop(LPREBARBANDINFO prbbi);
  157. BOOL _IsEnableTitle(CBandItemData *pbid);
  158. BOOL _IsHeightReasonable(UINT cy);
  159. HRESULT _LoadBandInfo(IStream *pstm, int i, DWORD dwVersion);
  160. HRESULT _SaveBandInfo(IStream *pstm, int i);
  161. HRESULT _AddBandByID(IUnknown *punk, DWORD dwID);
  162. BOOL _SendToToolband(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
  163. BOOL _HandleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
  164. int _BandIndexFromPunk(IUnknown *punk);
  165. BOOL _IsBandTabstop(CBandItemData *pbid);
  166. IUnknown* _GetNextTabstopBand(IUnknown* ptb, BOOL fBackwards);
  167. virtual HRESULT _CycleFocusBS(LPMSG lpMsg);
  168. void _OnRBAutoSize(NMRBAUTOSIZE* pnm);
  169. void _DoDragDrop();
  170. BOOL _PreDragDrop();
  171. virtual void _Close();
  172. BOOL _IsBandDeleteable(DWORD dwBandID);
  173. void _MinimizeBand(DWORD dwBandID);
  174. void _MaximizeBand(DWORD dwBandID);
  175. void _CheckNotifyOnAddRemove(DWORD dwBandID, int iCode);
  176. DWORD _GetAdminSettings(DWORD dwBandID);
  177. void _SetAdminSettings(DWORD dwBandID, DWORD dwNewAdminSettings);
  178. void _ReleaseBandItemData(CBandItemData *pbid, int iIndex);
  179. void _CacheActiveBand(IUnknown* ptb);
  180. HRESULT _IsRestricted(DWORD dwBandID, DWORD dwRestrictAction, DWORD dwBandFlags);
  181. virtual ~CBandSite();
  182. HWND _hwnd;
  183. HDSA _hdsaBandItemData;
  184. DWORD _dwMode;
  185. DWORD _dwShowState;
  186. DWORD _dwBandIDNext;
  187. DWORD _dwStyle;
  188. IDataObject* _pdtobj; // the stored drag drop data object;
  189. UINT _uDragBand;
  190. DWORD _dwDropEffect;
  191. IOleCommandTarget *_pct;
  192. IUnknown *_ptbActive;
  193. // cache for message reflector stuff
  194. HWND _hwndCache;
  195. IWinEventHandler *_pwehCache;
  196. // Stuff we need to remember while our context menu is up
  197. IContextMenu3* _pcm3Parent;
  198. IShellLinkA *_plink;
  199. IBandProxy * _pbp;
  200. BITBOOL _fCreatedBandProxy:1;
  201. BITBOOL _fDragSource :1;
  202. BITBOOL _fNoDropTarget :1;
  203. BITBOOL _fIEAKInstalled :1; // If TRUE, then display 2 extra contex menu items for Admins to use.
  204. UINT _fDragging:2; // we're dragging (0:FALSE 1:move [2:size])
  205. HWND _hwndDD; // window for cool D&D cursor drawing.
  206. friend HRESULT CBandSite_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppunk, LPCOBJECTINFO poi);
  207. };
  208. typedef enum {
  209. CNOAR_ADDBAND = 1,
  210. CNOAR_REMOVEBAND = 2,
  211. CNOAR_CLOSEBAR = 3,
  212. } CNOAR_CODES;
  213. #endif // WANT_CBANDSITE_CLASS
  214. #ifdef __cplusplus
  215. }; /* End of extern "C" { */
  216. #endif // __cplusplus
  217. #endif