tbext.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 6k
Category:

Windows Kernel

Development Platform:

Visual C++

  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.     
  84.     // Overridden IBrowserExtension Interface Members
  85.     STDMETHODIMP Init(REFGUID rguid);
  86.     // Overridden IOleCommandTarget Interface Members
  87.     STDMETHODIMP QueryStatus(const GUID * pguidCmdGroup, ULONG  cCmds, OLECMD prgCmds[], OLECMDTEXT * pCmdText);
  88.     STDMETHODIMP Exec(const GUID * pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut);
  89. protected:
  90.     BOOL            _bBandState;        // This is a hack... ideally state will be determined from the browser
  91.     BSTR            _bstrBandCLSID;     // CLSID of band to load.  Kept as BSTR because this is how it is passed
  92.                                         // to load the band
  93. };
  94. class CToolbarExtExec : public CToolbarExt
  95. {
  96. public:
  97.     // Constructor / Destructor
  98.     CToolbarExtExec();
  99.     virtual ~CToolbarExtExec();
  100.     
  101.     // Overridden IBrowserExtension Interface Members
  102.     STDMETHODIMP Init(REFGUID rguid);
  103.     STDMETHODIMP GetProperty(SHORT iPropID, VARIANTARG * pvarProperty);
  104.     // Overridden IObjectWithSite Interface Members        
  105.     STDMETHODIMP SetSite(IUnknown* pUnkSite);
  106.     // Overridden IOleCommandTarget Interface Members
  107.     STDMETHODIMP QueryStatus(const GUID * pguidCmdGroup, ULONG  cCmds, OLECMD prgCmds[], OLECMDTEXT * pCmdText);
  108.     STDMETHODIMP Exec(const GUID * pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANT* pvaIn, VARIANT* pvaOut);
  109. protected:
  110.     BOOL            _bButton;           // Does this object support being a button?
  111.     BOOL            _bMenuItem;         // Does it support being a menu item?
  112.     BOOL            _bExecCalled;       // if Exec was called
  113.     BSTR            _bstrExec;          // Thing to ShellExecute
  114.     BSTR            _bstrScript;        // Script to Execute
  115.     BSTR            _bstrMenuText;
  116.     BSTR            _bstrMenuCustomize; // the menu that is to be customized
  117.     BSTR            _bstrMenuStatusBar;
  118.     IUnknown*       _punkExt;           // (Optional) created when button is first pressed
  119. };
  120. #endif // _TBEXT_H