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.

166 lines
6.8 KiB

  1. #ifndef _BROWSEXT_H
  2. #define _BROWSEXT_H
  3. #include "tbext.h"
  4. #define FCIDM_TOOLS_EXT_PLACEHOLDER 0x9000
  5. #define FCIDM_TOOLS_EXT_MOD_MARKER 0x9001
  6. #define FCIDM_HELP_EXT_PLACEHOLDER 0x9002
  7. #define FCIDM_HELP_EXT_MOD_MARKER 0x9003
  8. //
  9. // This class is used to store/retrieve images by name (guid) from shared image lists
  10. //
  11. class CImageList
  12. {
  13. public:
  14. CImageList(HIMAGELIST himl = NULL);
  15. ~CImageList();
  16. CImageList& operator=(HIMAGELIST himl);
  17. operator HIMAGELIST() { return _himl; }
  18. int GetImageIndex(REFGUID rguid);
  19. int AddIcon(HICON hicon, REFGUID rguid);
  20. BOOL HasImages() { return (_himl != NULL); }
  21. void FreeImages();
  22. protected:
  23. static int _DPADestroyCallback(LPVOID p, LPVOID d);
  24. // Associate guids with indices into the image list
  25. struct ImageAssoc
  26. {
  27. GUID guid;
  28. int iImage;
  29. };
  30. HIMAGELIST _himl;
  31. HDPA _hdpa; // Array of ImageAssoc
  32. };
  33. //
  34. // Internal interface fo managing buttons added to the internet toolbar and menu items added to the
  35. // tools menu. This interface will likely go away afer IE5B2 when we move this functionality to
  36. // a browser helper object.
  37. //
  38. EXTERN_C const IID IID_IToolbarExt;
  39. DECLARE_INTERFACE_(IToolbarExt, IUnknown)
  40. {
  41. // *** IUnknown methods ***
  42. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj) PURE;
  43. virtual STDMETHODIMP_(ULONG) AddRef(void) PURE;
  44. virtual STDMETHODIMP_(ULONG) Release(void) PURE;
  45. // *** IToolbarExt methods ***
  46. virtual STDMETHODIMP GetButtons(TBBUTTON* ptbArr, int nNumButtons, BOOL fInit) PURE;
  47. virtual STDMETHODIMP GetNumButtons(UINT* pButtons) PURE;
  48. virtual STDMETHODIMP InitButtons(IExplorerToolbar* pxtb, UINT* puStringIndex, const GUID* pguidCommandGroup) PURE;
  49. virtual STDMETHODIMP OnCustomizableMenuPopup(HMENU hMenuParent, HMENU hMenu) PURE;
  50. virtual STDMETHODIMP OnMenuSelect(UINT nCmdID) PURE;
  51. };
  52. class CBrowserExtension : public IToolbarExt
  53. , public IObjectWithSite
  54. , public IOleCommandTarget
  55. {
  56. public:
  57. // *** IUnknown methods ***
  58. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
  59. virtual STDMETHODIMP_(ULONG) AddRef(void);
  60. virtual STDMETHODIMP_(ULONG) Release(void);
  61. // *** IObjectWithSite methods ***
  62. virtual STDMETHODIMP SetSite(IUnknown* pUnkSite);
  63. virtual STDMETHODIMP GetSite(REFIID riid, void ** ppvSite);
  64. // *** IToolbarExt methods ***
  65. virtual STDMETHODIMP GetButtons(TBBUTTON* ptbArr, int nNumButtons, BOOL fInit);
  66. virtual STDMETHODIMP GetNumButtons(UINT* pButtons);
  67. virtual STDMETHODIMP InitButtons(IExplorerToolbar* pxtb, UINT* puStringIndex, const GUID* pguidCommandGroup);
  68. virtual STDMETHODIMP OnCustomizableMenuPopup(HMENU hMenuParent, HMENU hMenu);
  69. virtual STDMETHODIMP OnMenuSelect(UINT nCmdID);
  70. // *** IOleCommandTarget methods ***
  71. virtual STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
  72. virtual STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup, ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
  73. protected:
  74. // Instance creator
  75. friend HRESULT CBrowserExtension_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppunk, LPCOBJECTINFO poi);
  76. CBrowserExtension();
  77. ~CBrowserExtension();
  78. HRESULT Update();
  79. struct ExtensionItem
  80. {
  81. CLSID guid; // id of the extension
  82. IBrowserExtension* pIBE;
  83. BITBOOL fButton:1; // if has a button
  84. BITBOOL fVisible:1; // if defaults to visible on the toolbar
  85. int iStringID; // Keeps track of the location in the string resource for the button
  86. int iImageID; // The ID of the icon in the image lists
  87. int idCmd; // toolbar CmdId
  88. UINT idmMenu; // idm of the menu this extension belongs to
  89. };
  90. void _AddItem(HKEY hkeyExtensions, LPCWSTR pszButtonGuid, REFGUID rguid);
  91. ExtensionItem* _FindItem(REFGUID rguid);
  92. void _FreeItems();
  93. HRESULT _Exec(int nItem, int nCmdID);
  94. UINT _GetImageLists(CImageList** ppimlDef, CImageList** ppimlHot, BOOL fSmall);
  95. void _ReleaseImageLists(UINT uiIndex);
  96. HRESULT _AddCustomImagesToImageList(CImageList& rimlNormal, CImageList& rimlHot, BOOL fSmallIcons);
  97. HRESULT _AddCustomStringsToBuffer(IExplorerToolbar * pxtb, const GUID* pguidCommandGroup);
  98. int _GetCmdIdFromClsid(LPCWSTR pszGuid);
  99. int _GetIdpaFromCmdId(int nCmdId);
  100. typedef struct tagBROWSEXT_MENU_INFO
  101. {
  102. UINT idmMenu; // idm for this menu
  103. UINT idmPlaceholder;
  104. UINT idmModMarker; // separator with this idm is present if customizations have been made
  105. int iInsert; // insertion point for custom items
  106. } BROWSEXT_MENU_INFO;
  107. HRESULT _GetCustomMenuInfo(HMENU hMenuParent, HMENU hMenu, BROWSEXT_MENU_INFO * pMI);
  108. LONG _cRef; // reference count
  109. HDPA _hdpa; // array of ExtensionItem*
  110. int _nExtButtons; // Number of Buttons
  111. int _nExtToolsMenuItems; // Number of Tools Menu Items
  112. IShellBrowser* _pISB; // Passed into the IObjectWithSite::GetSite
  113. UINT _uStringIndex; // index of first string added to toolbar
  114. // Used for CUT/COPY/PASTE imagelist
  115. struct CImageCache
  116. {
  117. UINT uiResDef; // resource id for grey-scale bitmap
  118. UINT uiResHot; // resource id for color bitmap
  119. CImageList imlDef; // grey scale imagelist
  120. CImageList imlHot; // color imagelist
  121. int cUsage; // number of instances using this item
  122. BOOL bShell32; // resource stored in shell32
  123. };
  124. static CImageCache _rgImages[3]; // cached image lists:
  125. // 16 color 16x16
  126. // 16 color 20x20
  127. // 256 color 20x20
  128. UINT _uiImageIndex; // Currently used index into _rgImages (-1 is none)
  129. #ifdef DEBUG
  130. BOOL _fStringInit; // These are used to insure that AddExtButtonsTBArray is only called after
  131. BOOL _fImageInit; // AddCustomImag... and AddCustomStrin... have been called.
  132. #endif
  133. };
  134. EXTERN_C const CLSID CLSID_PrivBrowsExtCommands;
  135. typedef enum {
  136. PBEC_GETSTRINGINDEX = 1,
  137. } PBEC_COMMANDS;
  138. #endif // _BROWSEXT_H