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.

139 lines
5.5 KiB

  1. ///////////////////////////////////////////////////////
  2. // File: TBBxt.h (Toolbar Button Extension Headers
  3. // Author: Karim Farouki
  4. //
  5. // We declare here three classes:
  6. // (1) CToolbarExt a base class that takes care of the
  7. // button work for our custom extensions
  8. // (2) CToolbarExtBand the object which deals with custom
  9. // buttons that plug into bands
  10. // (3) CToolbarExtExec the object which deals with custom
  11. // buttons (or tools menu items) that exec stuff.
  12. //
  13. // The latter two are derived from the former
  14. #ifndef _TBEXT_H
  15. #define _TBEXT_H
  16. #include "priv.h"
  17. //
  18. // Internal interface for accessing ther properties of a button/menu extension.
  19. // This interface will likely go away afer IE5B2 when we move this functionality to
  20. // a browser helper object.
  21. //
  22. typedef enum _tagGetPropertyIDs
  23. {
  24. TBEX_BUTTONTEXT = 100, // VT_BSTR
  25. TBEX_TOOLTIPTEXT = 101, // VT_BSTR
  26. TBEX_GRAYICON = 102, // HICON as a VT_BYREF
  27. TBEX_HOTICON = 103, // HICON as a VT_BYREF
  28. TBEX_GRAYICONSM = 104, // HICON as a VT_BYREF
  29. TBEX_HOTICONSM = 105, // HICON as a VT_BYREF
  30. TBEX_DEFAULTVISIBLE = 106, // VT_BOOL
  31. TMEX_MENUTEXT = 200, // VT_BSTR
  32. TMEX_STATUSBARTEXT = 201, // VT_BSTR
  33. TMEX_CUSTOM_MENU = 202, // VT_BSTR
  34. } GETPROPERTYIDS;
  35. interface IBrowserExtension : IUnknown
  36. {
  37. virtual STDMETHODIMP Init(REFGUID refguid) = 0;
  38. virtual STDMETHODIMP GetProperty(SHORT iPropID, VARIANTARG * varProperty) = 0;
  39. };
  40. class CToolbarExt : public IBrowserExtension,
  41. public IOleCommandTarget,
  42. public IObjectWithSite
  43. {
  44. public:
  45. // Constructor/Destructor
  46. CToolbarExt();
  47. virtual ~CToolbarExt();
  48. // IUnknown Interface Members
  49. STDMETHODIMP QueryInterface(const IID& iid, void** ppv);
  50. STDMETHODIMP_(ULONG) AddRef();
  51. STDMETHODIMP_(ULONG) Release();
  52. // IBrowserExtension Interface Members
  53. STDMETHODIMP Init(REFGUID rguid);
  54. STDMETHODIMP GetProperty(SHORT iPropID, VARIANTARG * pvarProperty);
  55. // IOleCommandTarget Interface Members
  56. STDMETHODIMP QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT * pCmdText);
  57. STDMETHODIMP Exec(const GUID * pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut) = 0;
  58. // IObjectWithSite Interface Members
  59. STDMETHODIMP SetSite(IUnknown* pUnkSite);
  60. STDMETHODIMP GetSite(REFIID riid, void ** ppvSite);
  61. protected:
  62. BOOL _RegGetBoolValue(LPCWSTR pszPropName, BOOL fDefault);
  63. BOOL _RegReadString(HKEY hkeyThisExtension, LPCWSTR szPropName, BSTR * pbstrProp, BOOL fExpand = FALSE);
  64. HICON _ExtractIcon(LPWSTR pszPath, int resid, int cx, int cy);
  65. HRESULT _GetIcon(LPCWSTR pszIcon, int nWidth, int nHeight, HICON& rhIcon, VARIANTARG * pvarProperty);
  66. long _cRef;
  67. HICON _hIcon; // gray icon regular size
  68. HICON _hIconSm; // gray icon small
  69. HICON _hHotIcon; // Hot... are color versions of above
  70. HICON _hHotIconSm;
  71. BSTR _bstrButtonText; // The buttons caption
  72. BSTR _bstrToolTip; // This is optional (not supported on our side yet)
  73. HKEY _hkeyThisExtension;
  74. HKEY _hkeyCurrentLang; // optional location for localized strings
  75. IShellBrowser* _pisb; // passed in by IObjectWithSite::SetSite() Used to load band
  76. };
  77. class CToolbarExtBand : public CToolbarExt
  78. {
  79. public:
  80. // Constructor / Destructor
  81. CToolbarExtBand();
  82. virtual ~CToolbarExtBand();
  83. // Overridden IBrowserExtension Interface Members
  84. STDMETHODIMP Init(REFGUID rguid);
  85. // Overridden IOleCommandTarget Interface Members
  86. STDMETHODIMP QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT * pCmdText);
  87. STDMETHODIMP Exec(const GUID * pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut);
  88. protected:
  89. BOOL _bBandState; // This is a hack... ideally state will be determined from the browser
  90. BSTR _bstrBandCLSID; // CLSID of band to load. Kept as BSTR because this is how it is passed
  91. // to load the band
  92. };
  93. class CToolbarExtExec : public CToolbarExt
  94. {
  95. public:
  96. // Constructor / Destructor
  97. CToolbarExtExec();
  98. virtual ~CToolbarExtExec();
  99. // Overridden IBrowserExtension Interface Members
  100. STDMETHODIMP Init(REFGUID rguid);
  101. STDMETHODIMP GetProperty(SHORT iPropID, VARIANTARG * pvarProperty);
  102. // Overridden IObjectWithSite Interface Members
  103. STDMETHODIMP SetSite(IUnknown* pUnkSite);
  104. // Overridden IOleCommandTarget Interface Members
  105. STDMETHODIMP QueryStatus(const GUID * pguidCmdGroup, ULONG cCmds, OLECMD prgCmds[], OLECMDTEXT * pCmdText);
  106. STDMETHODIMP Exec(const GUID * pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut);
  107. protected:
  108. BOOL _bButton; // Does this object support being a button?
  109. BOOL _bMenuItem; // Does it support being a menu item?
  110. BOOL _bExecCalled; // if Exec was called
  111. BSTR _bstrExec; // Thing to ShellExecute
  112. BSTR _bstrScript; // Script to Execute
  113. BSTR _bstrMenuText;
  114. BSTR _bstrMenuCustomize; // the menu that is to be customized
  115. BSTR _bstrMenuStatusBar;
  116. IUnknown* _punkExt; // (Optional) created when button is first pressed
  117. };
  118. #endif // _TBEXT_H