itbar.cpp
资源名称:shell.rar [点击查看]
上传用户:xhy777
上传日期:2007-02-14
资源大小:24088k
文件大小:318k
源码类别:
系统编程
开发平台:
Visual C++
- #include "priv.h"
- #include "sccls.h"
- #include "itbdrop.h"
- #include <urlhist.h>
- #include "autocomp.h"
- #include "itbar.h"
- #include "address.h"
- #include "isfband.h"
- #include <winbase.h>
- #include "qlink.h"
- #include "inpobj.h"
- #include "basebar.h"
- #include "shbrowse.h"
- #include "menuisf.h"
- #include "menuband.h"
- #include "brand.h"
- #include "resource.h"
- #include "theater.h"
- #include "browmenu.h"
- #include "util.h"
- #include "tbmenu.h"
- #include "apithk.h"
- #include "shbrows2.h"
- #include "stdenum.h"
- #include "iehelpid.h"
- #define WANT_CBANDSITE_CLASS
- #include "bandsite.h"
- #include "schedule.h"
- #include "uemapp.h"
- #include "mluisupp.h"
- #ifdef UNIX
- extern "C" const GUID CLSID_MsgBand;
- #endif
- // The edit button hackery needs to be moved to shdocvw. This define identifies this code.
- #define EDIT_HACK
- // Offset of the comctl32 default bitmaps
- #define OFFSET_HIST (MAX_TB_BUTTONS - 1 + 0) // 15
- #define OFFSET_STD (MAX_TB_BUTTONS - 1 + 6) // 21
- #define OFFSET_VIEW (MAX_TB_BUTTONS - 1 + 21) // 36
- // This is the offset in the toolbar for the Shell glyphs and the Shell toolbar labels
- #define SHELLTOOLBAR_OFFSET (MAX_TB_BUTTONS - 1 + 1) // 16
- #define FONTGLYPH_OFFSET (MAX_TB_BUTTONS - 1 + 38) // 53
- #define BRIEFCASEGLYPH_OFFSET (MAX_TB_BUTTONS - 1 + 34) // 49
- #define RNAUIGLYPH_OFFSET (MAX_TB_BUTTONS - 1 + 36) // 51
- #define WEBCHECKGLYPH_OFFSET (MAX_TB_BUTTONS - 1 + 42) // 57
- #ifdef EDIT_HACK
- #define EDITGLYPH_OFFSET (9)
- #endif
- #define IDT_UPDATETOOLBAR 0x1
- #define TIMEOUT_UPDATETOOLBAR 400
- const GUID CLSID_Separator = { 0x67077B90L, 0x4F9D, 0x11D0, 0xB8, 0x84, 0x00, 0xAA, 0x00, 0xB6, 0x01, 0x04 };
- extern HRESULT VariantClearLazy(VARIANTARG *pvarg);
- // How many CT_TABLE structures to allocated at a time.
- #define TBBMPLIST_CHUNK 5
- #define MAX_EXTERNAL_BAND_NAME_LEN 64
- #define MAX_TB_COMPRESSED_WIDTH 42
- // 16 is added to the the MAX_TB defines. This is added through the strings
- // in the RC file. This is done so that the localization folks can increase
- // or decrease the width of the toolbar buttons
- #define MAX_TB_WIDTH_LORES 38
- #define MAX_TB_WIDTH_HIRES 60
- // Dimensions of Coolbar Glyphs ..
- #define TB_SMBMP_CX 16
- #define TB_SMBMP_CY 16
- #define TB_BMP_CX 20
- #define TB_BMP_CY 20
- #define CX_SEPARATOR 6 // we override toolbar control's default separator width of 8
- #define DM_TBSITE 0
- #define DM_TBCMD 0
- #define DM_TBREF TF_SHDREF
- #define DM_LAYOUT 0
- #define DM_ITBAR 0
- #define TF_TBCUST 0x01000000
- #if CBIDX_LAST != 5
- #error Expected CBIDX_LAST to have value of 5
- #endif
- #if (FCIDM_EXTERNALBANDS_LAST - FCIDM_EXTERNALBANDS_FIRST + 1) < MAXEXTERNALBANDS
- #error Insufficient range for FCIDM_EXTERNALBANDS_FIRST to FCIDM_EXTERNALBANDS_LAST
- #endif
- __inline UINT EXTERNALBAND_VBF_BIT(UINT uiBandExt)
- {
- ASSERT(uiBandExt < MAXEXTERNALBANDS);
- // Formula: take 1, shift left by uiBandExt + 16
- // => a bit in range (0x80000000, 0x00010000)
- UINT uBit = 1 << (uiBandExt + 16);
- ASSERT(uBit & VBF_EXTERNALBANDS);
- return uBit;
- }
- __inline BOOL IS_EXTERNALBAND(int idBand)
- {
- return (InRange(idBand, CBIDX_EXTERNALFIRST, CBIDX_EXTERNALLAST));
- }
- __inline int MAP_TO_EXTERNAL(int idBand)
- {
- ASSERT(IS_EXTERNALBAND(idBand));
- // CBIDX_LAST is one-based, mapping is zero-based
- return (idBand - (1 + CBIDX_LAST));
- }
- // maximum number of menu items in the context menus for back and forward.
- #define MAX_NAV_MENUITEMS 9
- #define DEFAULT_SEARCH_GUID SRCID_SFileSearch //SRCID_SWebSearch
- #define SZ_PROP_CUSTDLG TEXT("Itbar custom dialog hwnd")
- #define REG_KEY_BANDSTATE TEXT("Software\Microsoft\Internet Explorer\Toolbar")
- DWORD DoNetConnect(HWND hwnd);
- DWORD DoNetDisconnect(HWND hwnd);
- void _LoadToolbarGlyphs(HWND hwnd, IMLCACHE *pimlCache, int cx, int idBmp);
- BOOL _UseSmallIcons();
- typedef struct tagTBBMP_LIST
- {
- HINSTANCE hInst;
- UINT_PTR uiResID;
- UINT uiOffset;
- BITBOOL fNormal:1;
- BITBOOL fHot:1;
- BITBOOL fDisabled:1;
- } TBBMP_LIST;
- typedef struct tagCMDMAP
- {
- GUID guidButtonGroup;
- UINT nCmdID;
- LPARAM lParam; // app's data
- } CMDMAP;
- typedef struct tagCMDMAPCUSTOMIZE
- {
- TBBUTTON btn;
- CMDMAP cm;
- } CMDMAPCUSTOMIZE;
- typedef struct {
- // the IOleCommandTarget info:
- GUID guid;
- UINT nCmdID;
- UINT fButtonState;
- } BUTTONSAVEINFO;
- #define TBSI_VERSION 7
- typedef struct {
- int cVersion;
- } TOOLBARSAVEINFO;
- typedef struct {
- HDSA hdsa;
- BITBOOL fAdjust:1;
- BITBOOL fDirty:1;
- } CUSTOMIZEINFO, *LPCUSTOMIZEINFO;
- //Current latest version.
- #define CBS_VERSION 17
- // NOTE: Be very careful changing COOLBARSAVE because _LoadUpgradeSettings makes
- // assumptions about the layout of the structure. To avoid breaking that
- // upgrade code, be sure you:
- //
- // - don't change the order of existing members
- // - always add new members to the end of the structure.
- // - update _LoadUpgradeSettings if appropriate
- //
- typedef struct tagCOOLBARSAVE
- {
- UINT cbVer;
- UINT uiMaxTBWidth;
- UINT uiMaxQLWidth;
- #ifdef UNIX
- BITBOOL fUnUsed : 28; // unused
- #endif
- BITBOOL fVertical : 1; // The bar is oriented vertically
- BITBOOL fNoText :1; // "NoText"
- BITBOOL fList : 1; // toolbar is TBSTYLE_LIST (text on right) + TBSTYLE_EX_MIXEDBUTTONS
- BITBOOL fAutoHide : 1; // Auto hide toolbar in theater mode
- BITBOOL fStatusBar : 1; // Status bar in theater mode
- BITBOOL fSaveInShellIntegrationMode : 1; // Did we save in shell integration mode?
- UINT uiVisible; // "Visible bands"
- UINT cyRebar;
- BANDSAVE bs[CBANDSMAX];
- CLSID aclsidExternalBands[ MAXEXTERNALBANDS ]; // Check classid
- CLSID clsidVerticalBar; //clsid of bar persisted within vertical band
- CLSID clsidHorizontalBar;
- } COOLBARSAVE, *LPCOOLBARSAVE;
- //Flags for dwFlags passed to UpdateToolbarDisplay()
- #define UTD_TEXTLABEL 0x00000001
- #define UTD_VISIBLE 0x00000002
- static const TCHAR c_szRegKeyCoolbar[] = TSZIEPATH TEXT("\Toolbar");
- static const TCHAR c_szValueTheater[] = TEXT("Theater");
- typedef struct tagFOLDERSEARCHITEM
- {
- UINT idCmd;
- GUID guidSearch;
- int iIcon;
- WCHAR wszUrl[MAX_URL_STRING];
- WCHAR wszName[80]; // friendly name
- }FOLDERSEARCHITEM, *LPFOLDERSEARCHITEM;
- BOOL NavigateSearchBar(IWebBrowser2 *pwb2, LPCWSTR pwszUrl);
- BOOL _GetSearchHKEY(LPGUID lpguidSearch, HKEY *phkey);
- #define REG_SZ_STATIC TEXT("Software\Microsoft\Windows\CurrentVersion\Explorer\FindExtensions\Static")
- #define REG_SZ_SEARCH_GUID TEXT("SearchGUID")
- #define REG_SZ_SEARCH_URL TEXT("SearchGUID\Url")
- #define VIEW_OFFSET (SHELLGLYPHS_OFFSET + HIST_MAX + STD_MAX)
- #define VIEW_ALLFOLDERS (VIEW_NETCONNECT + 14)
- static const TBBUTTON c_tbExplorer[] =
- {
- // override default toolbar width for separators; iBitmap member of
- // TBBUTTON struct is a union of bitmap index & separator width
- { 0, TBIDM_BACK , 0, BTNS_DROPDOWN | BTNS_SHOWTEXT, {0,0}, 0, 0 },
- { 1, TBIDM_FORWARD, 0, BTNS_DROPDOWN, {0,0}, 0, 1 },
- { 2, TBIDM_STOPDOWNLOAD, TBSTATE_ENABLED, BTNS_BUTTON, {0,0}, 0, 2 },
- { 3, TBIDM_REFRESH, TBSTATE_ENABLED, BTNS_BUTTON, {0,0}, 0, 3 },
- { 4, TBIDM_HOME, TBSTATE_ENABLED, BTNS_BUTTON, {0,0}, 0, 4 },
- { VIEW_PARENTFOLDER + VIEW_OFFSET, TBIDM_PREVIOUSFOLDER, TBSTATE_ENABLED, BTNS_BUTTON, {0,0}, 0, VIEW_PARENTFOLDER + VIEW_OFFSET },
- { VIEW_NETCONNECT + VIEW_OFFSET, TBIDM_CONNECT, TBSTATE_ENABLED, BTNS_BUTTON, {0,0}, 0, VIEW_NETCONNECT + VIEW_OFFSET },
- { VIEW_NETDISCONNECT + VIEW_OFFSET, TBIDM_DISCONNECT, TBSTATE_ENABLED, BTNS_BUTTON, {0,0}, 0, VIEW_NETDISCONNECT + VIEW_OFFSET },
- { CX_SEPARATOR, 0, TBSTATE_ENABLED, BTNS_SEP, {0,0}, 0, -1 },
- { 5, TBIDM_SEARCH, TBSTATE_ENABLED, BTNS_SHOWTEXT, {0,0}, 0, 5 },
- { VIEW_ALLFOLDERS + VIEW_OFFSET, TBIDM_ALLFOLDERS, TBSTATE_ENABLED, BTNS_SHOWTEXT, {0,0}, 0, VIEW_ALLFOLDERS + VIEW_OFFSET },
- { 6, TBIDM_FAVORITES, TBSTATE_ENABLED, BTNS_SHOWTEXT, {0,0}, 0, 6 },
- { 12, TBIDM_HISTORY, TBSTATE_ENABLED, BTNS_SHOWTEXT, {0,0}, 0, 12},
- { CX_SEPARATOR, 0, TBSTATE_ENABLED, BTNS_SEP, {0,0}, 0, -1 },
- #ifndef DISABLE_FULLSCREEN
- // IE UNIX : No theater mode for beta1
- { 14, TBIDM_THEATER, TBSTATE_ENABLED, BTNS_BUTTON, {0,0}, 0, 14 },
- #endif
- };
- static const BROWSER_RESTRICTIONS c_rest[] = {
- REST_BTN_BACK,
- REST_BTN_FORWARD,
- REST_BTN_STOPDOWNLOAD,
- REST_BTN_REFRESH,
- REST_BTN_HOME,
- REST_BROWSER_NONE, // no policy for up
- REST_BROWSER_NONE, // no policy for map drive
- REST_BROWSER_NONE, // no policy for disconnect drive
- REST_BROWSER_NONE, // separator
- REST_BTN_SEARCH,
- REST_BTN_ALLFOLDERS,
- REST_BTN_FAVORITES,
- REST_BTN_HISTORY,
- REST_BROWSER_NONE, // separator
- #ifndef DISABLE_FULLSCREEN
- REST_BTN_THEATER,
- #endif
- };
- #define SUPERCLASS CBaseBar
- class CInternetToolbar :
- public CBaseBar,
- public IDockingWindow,
- public IObjectWithSite, // *not* CObjectWithSite (want _ptbSite)
- public IExplorerToolbar,
- public DWebBrowserEvents,
- public IPersistStreamInit,
- public IShellChangeNotify,
- public ISearchItems
- {
- public:
- // *** IUnknown ***
- virtual STDMETHODIMP QueryInterface(REFIID riid, void ** ppvObj);
- virtual STDMETHODIMP_(ULONG) AddRef(void) { return SUPERCLASS::AddRef(); };
- virtual STDMETHODIMP_(ULONG) Release(void){ return SUPERCLASS::Release(); };
- // *** IOleWindow methods ***
- virtual STDMETHODIMP GetWindow(HWND * lphwnd) { return SUPERCLASS::GetWindow(lphwnd);};
- virtual STDMETHODIMP ContextSensitiveHelp(BOOL fEnterMode) {return SUPERCLASS::ContextSensitiveHelp(fEnterMode);};
- // *** IDockingWindow methods ***
- virtual STDMETHODIMP ShowDW(BOOL fShow);
- virtual STDMETHODIMP CloseDW(DWORD dwReserved);
- virtual STDMETHODIMP ResizeBorderDW(LPCRECT prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
- // *** IObjectWithSite methods ***
- virtual STDMETHODIMP SetSite(IUnknown* punkSite);
- // BUGBUG is E_NOTIMPL ok?
- virtual STDMETHODIMP GetSite(REFIID riid, void** ppvSite) { ASSERT(0); return E_NOTIMPL; };
- // *** IInputObjectSite methods ***
- virtual STDMETHODIMP OnFocusChangeIS(IUnknown *punk, BOOL fSetFocus);
- // *** IInputObject methods ***
- virtual STDMETHODIMP TranslateAcceleratorIO(LPMSG lpMsg);
- // *** IServiceProvider methods ***
- virtual STDMETHODIMP QueryService(REFGUID guidService, REFIID riid, LPVOID* ppvObj);
- // *** IExplorerToolbar method ***
- virtual STDMETHODIMP SetCommandTarget(IUnknown* punkCmdTarget, const GUID* pguidButtonGroup, DWORD dwFlags);
- virtual STDMETHODIMP AddStdBrowserButtons(void);
- virtual STDMETHODIMP AddButtons(const GUID* pguidButtonGroup, UINT nButtons, const TBBUTTON * lpButtons);
- virtual STDMETHODIMP AddString(const GUID * pguidButtonGroup, HINSTANCE hInst, UINT_PTR uiResID, LONG_PTR *pOffset);
- virtual STDMETHODIMP GetButton(const GUID* pguidButtonGroup, UINT uiCommand, LPTBBUTTON lpButton);
- virtual STDMETHODIMP GetState(const GUID* pguidButtonGroup, UINT uiCommand, UINT * pfState);
- virtual STDMETHODIMP SetState(const GUID* pguidButtonGroup, UINT uiCommand, UINT fState);
- virtual STDMETHODIMP AddBitmap(const GUID * pguidButtonGroup, UINT uiBMPType, UINT uiCount, TBADDBITMAP * ptb,
- LRESULT * pOffset, COLORREF rgbMask);
- virtual STDMETHODIMP GetBitmapSize(UINT * uiID);
- virtual STDMETHODIMP SendToolbarMsg(const GUID * pguidButtonGroup, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT * plRes);
- virtual STDMETHODIMP SetImageList( const GUID* pguidCmdGroup, HIMAGELIST himlNormal, HIMAGELIST himlHot, HIMAGELIST himlDisabled);
- virtual STDMETHODIMP ModifyButton( const GUID * pguidButtonGroup, UINT uiCommand, LPTBBUTTON lpButton);
- // IOleCommandTarget
- virtual STDMETHODIMP QueryStatus(const GUID *pguidCmdGroup,
- ULONG cCmds, OLECMD rgCmds[], OLECMDTEXT *pcmdtext);
- virtual STDMETHODIMP Exec(const GUID *pguidCmdGroup,
- DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn,
- VARIANTARG *pvarargOut);
- // IPersistStreamInit
- STDMETHOD(GetClassID)(GUID *pguid);
- STDMETHOD(Load)(IStream *pStm);
- STDMETHOD(Save)(IStream *pStm, BOOL fClearDirty);
- STDMETHOD(InitNew)(void);
- STDMETHOD(IsDirty)(void);
- STDMETHOD(GetSizeMax)(ULARGE_INTEGER *pcbSize);
- /* IDispatch methods */
- virtual STDMETHODIMP GetTypeInfoCount(UINT *pctinfo);
- virtual STDMETHODIMP GetTypeInfo(UINT itinfo,LCID lcid,ITypeInfo **pptinfo);
- virtual STDMETHODIMP GetIDsOfNames(REFIID riid,OLECHAR **rgszNames,UINT cNames,
- LCID lcid, DISPID * rgdispid);
- virtual STDMETHODIMP Invoke(DISPID dispidMember,REFIID riid,LCID lcid,WORD wFlags,
- DISPPARAMS * pdispparams, VARIANT * pvarResult,
- EXCEPINFO * pexcepinfo,UINT * puArgErr);
- // IShellChangeNotify
- virtual STDMETHODIMP OnChange(LONG lEvent, LPCITEMIDLIST pidl1, LPCITEMIDLIST pidl2);
- // CBaseBar overrides
- virtual LRESULT v_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- // *** ISearchItems methods ***
- virtual STDMETHODIMP GetDefaultSearchUrl(LPWSTR pwzUrl, UINT cch);
- CInternetToolbar();
- protected:
- virtual ~CInternetToolbar();
- static LRESULT CALLBACK SizableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- void _OnCommand(WPARAM wParam, LPARAM lParam);
- BOOL _SendToToolband(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
- LRESULT _OnNotify(LPNMHDR pnmh);
- void _OnTooltipNeeded(LPTOOLTIPTEXT pnmTT);
- void _QueryStatusTip(IOleCommandTarget *pct, LPTOOLTIPTEXT pnmTT, UINT uiCmd, const GUID* pguid);
- BOOL _UpEnabled();
- void _UpdateCommonButton(int iCmd, UINT nCmdID);
- void _UpdateToolbar(BOOL fForce);
- void _UpdateToolbarNow();
- void _UpdateGroup(const GUID *pguidCmdGroup, int cnt, OLECMD rgcmds[], const GUID* pguidButton, const int buttonsInternal[]);
- void _CSHSetStatusBar(BOOL fOn);
- void _StartDownload();
- void _StopDownload(BOOL fClosing);
- void _SendDocCommand(UINT idCmd);
- BOOL _CompressBands(BOOL fCompress, UINT uRowsNew, BOOL fForceUpdate);
- void _TrackSliding(int x, int y);
- HRESULT _DoNavigateA(LPSTR pszURL,int iNewSelection);
- HRESULT _DoNavigateW(LPWSTR pwzURL,int iNewSelection);
- HRESULT _DoNavigate(BSTR bstrURL,int iNewSelection);
- void _Unadvise(void);
- LRESULT _OnBeginDrag(NMREBAR* pnm);
- void _InsertURL(LPTSTR pszURL);
- void _ShowContextMenu(HWND hwnd, LPARAM lParam, LPRECT prcExclude);
- BOOL _ShowBackForwardMenu(BOOL fForward, POINT pt, LPRECT prcExclude);
- // search helper methods
- BOOL _GetFolderSearchData();
- void _SetSearchStuff();
- BOOL _GetSearchUrl(LPWSTR pwszUrl, DWORD cch);
- HRESULT _GetFolderSearches(IFolderSearches **ppfs);
- void _ReloadButtons();
- void _UpdateToolsStyle(BOOL fList);
- void _InitBitmapDSA();
- void _InitForScreenSize();
- void _InitToolbar();
- BOOL _FoldersButtonAvailable();
- void _AdminMarkDefaultButtons(PTBBUTTON ptbb, UINT cButtons);
- void _MarkDefaultButtons(PTBBUTTON ptbb, UINT cButtons);
- void _AddCommonButtons();
- HRESULT _CreateBands();
- BOOL _ShowBands(UINT fVisible);
- HRESULT _ShowTools(PBANDSAVE pbs);
- HRESULT _ShowAddressBand(PBANDSAVE pbs);
- HRESULT _ShowExternalBand(PBANDSAVE pbs, int idBand );
- HRESULT _ShowLinks(PBANDSAVE pbs);
- HRESULT _ShowBrand(PBANDSAVE pbs);
- HRESULT _ShowMenu(PBANDSAVE pbs);
- void _ShowBandCommon(PBANDSAVE pbs, LPBANDITEMDATA pbid, BOOL fShow);
- void _EnsureAllBandsShown();
- HRESULT _GetMinRowHeight();
- HBITMAP _LoadBackBmp(LPTSTR * ppszBitmap, BMPCACHE * pbmpCache, BOOL fInternet);
- HBITMAP _LoadBackBitmap();
- void _SetBackground();
- void _CommonHandleFileSysChange(LONG lEvent, LPITEMIDLIST* ppidl);
- LPITEMIDLIST _GetCurrentPidl(void);
- int _ConvertHwndToID(HWND hwnd);
- HRESULT _GetPersistedBand(const CLSID clsid, REFIID riid, void ** ppiface);
- // Multiple command target
- LRESULT _AddBitmapFromForeignModule(UINT uiGetMSG, UINT uiSetMSG, UINT uiCount, HINSTANCE hinst,
- UINT_PTR nID, COLORREF rgbMask);
- HRESULT _LoadDefaultSettings(void);
- HRESULT _LoadUpgradeSettings(ULONG cbRead);
- HRESULT _LoadDefaultWidths(void);
- void _TryLoadIE3Settings();
- HRESULT _UpdateToolbarDisplay(DWORD dwFlags, UINT uVisibleBands, BOOL fNoText, BOOL fPersist);
- void _UpdateBrandSize();
- void _ShowVisible(DWORD dwVisible, BOOL fPersist);
- void _BuildSaveStruct(COOLBARSAVE* pcs);
- void _RestoreSaveStruct(COOLBARSAVE* pcs);
- void _GetVisibleBrowserBar(UINT idBar, CLSID *pclsidOut);
- LPBANDITEMDATA _AddNewBand(IDeskBand* pdb, DWORD dwID);
- void _TheaterModeLayout(BOOL fEnter);
- HBITMAP _bmpBack; // this is the state we think the itbar is in
- static BMPCACHE s_bmpBackShell; // this is the state of the shell bmp cache
- static BMPCACHE s_bmpBackInternet; // this is the state of the internet bmp cache
- static IMLCACHE s_imlTBGlyphs;
- HWND _hwndMenu;
- HWND _hwndAddressBand;
- IDockingWindowSite* _ptbsite;
- IOleCommandTarget* _ptbsitect;
- IBrowserService2* _pbs2;
- IServiceProvider* _psp;
- IBandProxy * _pbp;
- BITBOOL _fCreatedBandProxy:1;
- BITBOOL _fBackEnabled:1;
- BITBOOL _fForwardEnabled:1;
- BITBOOL _fEditEnabled:1;
- BITBOOL _fShow:1;
- BITBOOL _fAnimating:1;
- BITBOOL _fCompressed:1;
- BITBOOL _fUserNavigated :1;
- BITBOOL _fAutoCompInitialized :1;
- BITBOOL _fDirty:1;
- BITBOOL _fUsingDefaultBands:1;
- BITBOOL _fTransitionToHTML:1;
- BITBOOL _fInitialPidlIsWeb:1;
- BITBOOL _fTheater: 1; // are we in theater mode? claim no border space
- BITBOOL _fAutoHide :1;
- BITBOOL _fRebarDragging :1;
- BITBOOL _fShellView:1; // are we in shell view or web view?
- BITBOOL _fNoShowMenu:1; // can show menu band?
- BITBOOL _fUpdateToolbarTimer:1;
- BITBOOL _fNeedUpdateToolbar:1;
- BITBOOL _fNavigateComplete:1;
- BITBOOL _fLoading:1; // are we still loading the bar?
- BITBOOL _fDestroyed:1; // Did we destroy our member varibles and are shutting down? If so, don't use the varibles. (Stress bug w/messages coming in)
- UINT _nVisibleBands; // bitmask of which bands are visible: VBF_*
- IWebBrowser2* _pdie;
- DWORD _dwcpCookie; // DIID_DWebBrowserEvents2
- int _xCapture;
- int _yCapture;
- // for multiple command target support
- HDSA _hdsaTBBMPs;
- UINT _uiMaxTBWidth;
- UINT _uiTBTextRows;
- UINT _uiTBDefaultTextRows;
- // search stuff
- HDPA _hdpaFSI; // folder search items
- GUID _guidCurrentSearch;
- GUID _guidDefaultSearch;
- COOLBARSAVE _cs; //Coolbar layout info from registry!
- struct EXTERNALBANDINFO {
- CLSID clsid; // CLSID of the band
- LPWSTR pwszName; // Band name
- LPWSTR pwszHelp; // Band help text
- };
- EXTERNALBANDINFO _rgebi[ MAXEXTERNALBANDS ];
- void _LoadExternalBandInfo();
- TBBUTTON _tbExplorer[ARRAYSIZE(c_tbExplorer)];
- int _iButtons;
- #ifdef EDIT_HACK
- // Variables for customizing the edit button glyph
- HIMAGELIST _himlEdit; // Monochrome Image list for the edit button
- HIMAGELIST _himlEditHot; // Hot image list for edit button
- int _iEditIcon; // index of current edit icon
- // Functions for managing a custom edit glyph
- void _InitEditButtonStyle();
- void _SetEditGlyph(int iIcon);
- void _RefreshEditGlyph();
- void _UpdateEditButton();
- static HIMAGELIST _CreateGrayScaleImagelist(HBITMAP hbmpImage, HBITMAP hbmpMask);
- static BSTR _GetEditProgID(IHTMLDocument2* pHTMLDocument);
- //
- // We can have multiple edit verbs associated with a document. The following class
- // maintains a list of verbs.
- //
- #define FCIDM_EDITFIRST 2000
- #define FCIDM_EDITLAST 2100
- #define SZ_EDITVERB_PROP TEXT("CEditVerb_This")
- #define IL_EDITBUTTON 2 // Index of image list used for the edit button
- #define IL_SEARCHBUTTON 3 // || search button
- // MSAA Menu Info declarations.
- // These will eventually be incorporated into oleacc.h - but for the
- // moment, we declare them privately...
- #define MSAA_MENU_SIG 0xAA0DF00DL
- class CEditVerb
- {
- public:
- CEditVerb();
- ~CEditVerb();
- // Functions for managing the verbs
- BOOL Add(LPTSTR pszProgID);
- UINT GetSize() { return _nElements; }
- void RemoveAll();
- // Functions to access the default edit verb
- int GetIcon() { return (_nElements && _pVerb[_nDefault].fShowIcon) ? _GetVerb(_nDefault).iIcon : -1; }
- BOOL GetToolTip(LPTSTR pszToolTip, UINT cchMax, BOOL fStripAmpersands = TRUE);
- BOOL GetMenuText(LPTSTR pszText, UINT cchMax) { return GetToolTip(pszText, cchMax, FALSE); }
- void Edit(LPCTSTR pszUrl) { _Edit(pszUrl, _nDefault); }
- // Pop-up menu
- BOOL ShowEditMenu(POINT pt, HWND hwnd, LPTSTR pszUrl);
- // Get default editor from the registry
- void InitDefaultEditor(HKEY hkey = NULL);
- protected:
- struct MSAAMenuInfo
- {
- DWORD m_MSAASig; // Must be MSAA_MENU_SIG
- DWORD m_CharLen; // Length in characters of text, excluding terminating NUL
- LPWSTR m_pWStr; // Menu text, in UNICODE, with terminating UNICODE-NUL.
- };
- struct EDITVERB
- {
- MSAAMenuInfo m_MSAA; // MSAA info - must be first element.
- HKEY hkeyProgID; // Key the we shellexec
- BITBOOL fUseOpenVerb:1; // use open verb instead of edit
- BITBOOL fInit:1; // true if the data below has beed initialized
- BITBOOL fShowIcon:1; // true if icon should show up on button
- int iIcon; // cached icon index
- UINT idCmd; // menu id
- LPTSTR pszDesc; // executable name or document name
- LPTSTR pszMenuText; // Menu text
- LPTSTR pszExe; // Path of the exe used to edit
- };
- EDITVERB* _Add(HKEY hkeyProgID, BOOL fPermitOpenVerb, BOOL fCheckForOfficeApp, BOOL fShowIcon);
- EDITVERB& _GetVerb(UINT nIndex);
- void _FetchInfo(UINT nIndex);
- void _Edit(LPCTSTR pszUrl, UINT nIndex);
- LPCTSTR _GetDescription(EDITVERB& rVerb);
- void _SetMSAAMenuInfo(EDITVERB& rVerb);
- void _ClearMSAAMenuInfo(EDITVERB& rVerb);
- void _FormatMenuText(UINT nIndex);
- BOOL _IsUnique(EDITVERB& rNewVerb);
- BOOL _IsHtmlStub(LPCWSTR pszPath);
- LPCTSTR _GetExePath(EDITVERB& rVerb);
- LPCTSTR _GetDefaultEditor();
- static LRESULT CALLBACK _WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- // Member data
- UINT _nElements; // number of edit verbs
- UINT _nDefault; // Default edit verb
- EDITVERB* _pVerb; // array of edit verbs
- WNDPROC _lpfnOldWndProc; // former wndProc
- LPWSTR _pszDefaultEditor; // Friendly name of default HTML editor
- BOOL _fInitEditor; // if we checked for a default editor
- };
- CEditVerb _aEditVerb;
- #endif
- // internal bandsite class
- class CBrowserToolsBand;
- class CITBandSite : public CBandSite
- {
- CITBandSite();
- virtual STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
- virtual STDMETHODIMP AddBand(IUnknown *punk);
- virtual STDMETHODIMP HasFocusIO();
- protected:
- virtual void v_SetTabstop(LPREBARBANDINFO prbbi);
- BOOL _SetMinDimensions();
- friend class CInternetToolbar;
- friend class CBrowserToolsBand;
- virtual HRESULT _OnContextMenu(WPARAM wParm, LPARAM lParam);
- virtual HRESULT _Initialize(HWND hwndParent);
- };
- CITBandSite _bs;
- #define TOOLSBANDCLASS CInternetToolbar::CBrowserToolsBand
- class CBrowserToolsBand : public CToolbarBand
- {
- CMDMAP* _GetCmdMapByIndex(int nIndex) { return _GetCmdMap(nIndex, TRUE);};
- CMDMAP* _GetCmdMapByID(int id) { return _GetCmdMap(id, FALSE);};
- LRESULT _ToolsCustNotify (LPNMHDR pnmh); // Handle TBCustomization Notify
- BOOL _SaveRestoreToolbar(BOOL fSave);
- void _FreeCustomizeInfo();
- void _FreeCmdMap(CMDMAP*);
- BOOL _RemoveAllButtons();
- int _CommandFromIndex(UINT uIndex);
- HRESULT _ConvertCmd(const GUID* pguidButtonGroup, UINT id, GUID* pguidOut, UINT * pid);
- void _OnDeletingButton(TBNOTIFY* ptbn);
- LONG_PTR _AddString(LPWSTR pwstr);
- void _PreProcessButtonString(TBBUTTON *ptbn, DWORD dwFlags);
- void _PreProcessExternalTBButton(TBBUTTON *ptbn);
- UINT _ProcessExternalButtons(PTBBUTTON ptbb, UINT cButtons);
- void _GetButtons(IOleCommandTarget* pct, const GUID* pguid, HDSA hdsa);
- void _RecalcButtonWidths();
- void _UpdateTextSettings(INT_PTR ids);
- static BOOL_PTR CALLBACK _BtnAttrDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
- static void _PopulateComboBox(HWND hwnd, const int iResource[], UINT cResources);
- static void _SetComboSelection(HWND hwnd, int iCurOption);
- void _SetDialogSelections(HWND hDlg, BOOL fSmallIcons);
- static void _PopulateDialog(HWND hDlg);
- void _OnBeginCustomize(LPNMTBCUSTOMIZEDLG pnm);
- BOOL _BuildButtonDSA();
- CMDMAPCUSTOMIZE* _GetCmdMapCustomize(GUID* guid, UINT nCmdID);
- virtual STDMETHODIMP Exec(const GUID *pguidCmdGroup, DWORD nCmdID, DWORD nCmdexecopt, VARIANTARG *pvarargIn, VARIANTARG *pvarargOut);
- virtual STDMETHODIMP GetClassID(CLSID *pClassID) {return E_NOTIMPL;};
- virtual STDMETHODIMP Load(IStream *pStm) {return E_NOTIMPL;};
- virtual STDMETHODIMP Save(IStream *pStm, BOOL fClearDirty) {return E_NOTIMPL;};
- // *** IUnknown ***
- virtual STDMETHODIMP_(ULONG) AddRef(void) { return CToolBand::AddRef(); };
- virtual STDMETHODIMP_(ULONG) Release(void){ return CToolBand::Release(); };
- virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID * ppvObj);
- // *** IDeskBand methods ***
- virtual STDMETHODIMP GetBandInfo(DWORD dwBandID, DWORD fViewMode, DESKBANDINFO* pdbi);
- // *** IWinEventHandler methods ***
- virtual STDMETHODIMP OnWinEvent(HWND hwnd, UINT dwMsg, WPARAM wParam, LPARAM lParam, LRESULT* plres);
- // *** IDockingWindow methods ***
- virtual STDMETHODIMP CloseDW(DWORD dwReserved) { return S_OK;};
- // *** IInputObject methods ***
- virtual STDMETHODIMP TranslateAcceleratorIO(LPMSG lpMsg);
- protected:
- IOleCommandTarget* _CommandTargetFromCmdMap(CMDMAP* pcm);
- LRESULT _OnToolbarDropDown(TBNOTIFY *ptbn);
- virtual LRESULT _OnNotify(LPNMHDR pnmh);
- LRESULT _OnContextMenu(LPARAM lParam, WPARAM wParam);
- CMDMAP* _GetCmdMap(int i, BOOL fByIndex);
- void _OnEndCustomize();
- LRESULT _TryShowBackForwardMenu(DWORD dwItemSpec, LPPOINT ppt, LPRECT prcExclude);
- CBrowserToolsBand();
- void _FreeBtnsAdded();
- friend class CInternetToolbar;
- friend class CITBandSite;
- GUID _guidCurrentButtonGroup;
- IOleCommandTarget* _pctCurrentButtonGroup;
- LPTBBUTTON _pbtnsAdded;
- int _cBtnsAdded;
- DWORD _nNextCommandID;
- CUSTOMIZEINFO *_pcinfo;
- BITBOOL _fCustomize :1;
- BITBOOL _fNeedFreeCmdMapsAdded :1;
- };
- CBrowserToolsBand _btb;
- friend class CBrowserToolsBand;
- friend class CITBandSite;
- friend void CInternetToolbar_CleanUp();
- friend void CInternetToolbar_Preload();
- friend void ITBar_LoadToolbarGlyphs(HWND hwnd);
- };
- //
- // Gets the stream corresponding to the type of the given pidl
- // If the stream already doesn't exist, then it returns NULL.
- HRESULT _GetStreamName(DWORD dwITBS, LPTSTR pszName, DWORD cchSize)
- {
- HRESULT hr = S_OK;
- ASSERT(pszName);
- switch (dwITBS)
- {
- case ITBS_WEB:
- StrCpyN(pszName, TEXT("WebBrowser"), cchSize);
- break;
- case ITBS_SHELL:
- StrCpyN(pszName, TEXT("ShellBrowser"), cchSize);
- break;
- case ITBS_EXPLORER:
- StrCpyN(pszName, TEXT("Explorer"), cchSize);
- break;
- default:
- hr = E_FAIL;
- break;
- }
- if (FAILED(hr))
- pszName[0] = ' ';
- return hr;
- }
- //
- // Gets the stream corresponding to the type of the given pidl
- // If the stream already doesn't exist, then it returns NULL.
- IStream *GetRegStream(BOOL fInternet, LPCTSTR pszValue, DWORD grfMode)
- {
- IStream *pstm = NULL;
- HKEY hkToolbar;
- if (RegCreateKey(HKEY_CURRENT_USER, c_szRegKeyCoolbar, &hkToolbar) == ERROR_SUCCESS)
- {
- TCHAR szStreamName[MAX_PATH];
- if (SUCCEEDED(_GetStreamName(fInternet, szStreamName, ARRAYSIZE(szStreamName))))
- pstm = OpenRegStream(hkToolbar, szStreamName, pszValue, grfMode);
- RegCloseKey(hkToolbar);
- }
- return(pstm);
- }
- //
- // Gets the stream corresponding to the type of the given pidl
- // If the stream already doesn't exist, then it returns NULL.
- IStream *GetITBarStream(BOOL fInternet, DWORD grfMode)
- {
- return GetRegStream(fInternet, TEXT("ITBarLayout"), grfMode);
- }
- IMLCACHE CInternetToolbar::s_imlTBGlyphs = {NULL};
- BMPCACHE CInternetToolbar::s_bmpBackShell = {NULL};
- BMPCACHE CInternetToolbar::s_bmpBackInternet = {NULL};
- BOOL g_fSmallIcons = FALSE;
- void IMLCACHE_CleanUp(IMLCACHE * pimlCache, DWORD dwFlags)
- {
- for (int i = 0; i < CIMLISTS; i++)
- {
- if (pimlCache->arhimlPendingDelete[i])
- ImageList_Destroy(pimlCache->arhimlPendingDelete[i]);
- if ((dwFlags & IML_DESTROY) && pimlCache->arhiml[i])
- ImageList_Destroy(pimlCache->arhiml[i]);
- }
- }
- void ITBar_LoadToolbarGlyphs(HWND hwnd)
- {
- int cx, idBmp;
- g_fSmallIcons = _UseSmallIcons();
- if (g_fSmallIcons) {
- cx = TB_SMBMP_CX;
- idBmp = IDB_IETOOLBAR16;
- } else {
- cx = TB_BMP_CX;
- idBmp = IDB_IETOOLBAR;
- }
- if (SHGetCurColorRes() > 8)
- idBmp += DELTA_HICOLOR;
- _LoadToolbarGlyphs(hwnd, &CInternetToolbar::s_imlTBGlyphs, cx, idBmp);
- }
- void CInternetToolbar_Preload()
- {
- ENTERCRITICAL;
- ITBar_LoadToolbarGlyphs(NULL);
- Brand_InitBrandContexts();
- LEAVECRITICAL;
- }
- void CInternetToolbar_CleanUp()
- {
- TraceMsg(DM_ITBAR, "CInternetToolbar: Destroying shared GDI objects");
- if (CInternetToolbar::s_bmpBackInternet.hbmp)
- DeleteObject(CInternetToolbar::s_bmpBackInternet.hbmp);
- if (CInternetToolbar::s_bmpBackShell.hbmp)
- DeleteObject(CInternetToolbar::s_bmpBackShell.hbmp);
- IMLCACHE_CleanUp(&CInternetToolbar::s_imlTBGlyphs, IML_DESTROY);
- }
- STDAPI CInternetToolbar_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppunk, LPCOBJECTINFO poi)
- {
- // aggregation checking is handled in class factory
- CInternetToolbar *pitbar = new CInternetToolbar();
- if (pitbar)
- {
- *ppunk = SAFECAST(pitbar, IDockingWindow *);
- return S_OK;
- }
- return E_OUTOFMEMORY;
- }
- LRESULT CInternetToolbar::v_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- if ( uMsg == WM_SYSCOLORCHANGE )
- {
- // refresh the back drop incase the colours have changed
- _SetBackground();
- }
- return SUPERCLASS::v_WndProc( hwnd, uMsg, wParam, lParam );
- }
- void CInternetToolbar::_LoadExternalBandInfo()
- {
- #ifdef DEBUG
- int i;
- // Should have been zero-initialized
- for (i = 0; i < ARRAYSIZE(_rgebi); i++)
- {
- ASSERT(IsEqualGUID(_rgebi[i].clsid, GUID_NULL));
- ASSERT(_rgebi[i].pwszName == NULL);
- ASSERT(_rgebi[i].pwszHelp == NULL);
- }
- #endif
- HKEY hkey;
- DWORD dwClsidIndex = 0;
- if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, REG_KEY_BANDSTATE, 0, KEY_READ, &hkey) == ERROR_SUCCESS)
- {
- TCHAR tszReg[MAX_PATH];
- StrCpy(tszReg, TEXT("CLSID\"));
- const int cchClsidPrefix = 6; // 6 = strlen("CLSID\")
- LPTSTR ptszClsid = tszReg + cchClsidPrefix;
- DWORD cchClsid;
- for (DWORD dwIndex = 0;
- cchClsid = ARRAYSIZE(tszReg) - cchClsidPrefix,
- dwClsidIndex < ARRAYSIZE(_rgebi) &&
- RegEnumValue( hkey, dwIndex, ptszClsid, &cchClsid, NULL, NULL, NULL, NULL ) == ERROR_SUCCESS;
- dwIndex++)
- {
- CLSID clsid;
- if (GUIDFromString( ptszClsid, &clsid ))
- {
- // Don't save the CLSID until we're sure it worked
- _rgebi[dwClsidIndex].clsid = clsid;
- HKEY hkeyClsid;
- if (RegOpenKeyEx(HKEY_CLASSES_ROOT, tszReg, 0, KEY_READ, &hkeyClsid) == ERROR_SUCCESS)
- {
- WCHAR wszBuf[MAX_PATH];
- // Get the name; use SHLoadRegUIString so the app can localize
- SHLoadRegUIStringW( hkeyClsid, L"", wszBuf, ARRAYSIZE(wszBuf) );
- Str_SetPtrW( &_rgebi[dwClsidIndex].pwszName, wszBuf);
- // Get the help; use SHLoadRegUIString so the app can localize
- SHLoadRegUIStringW( hkeyClsid, L"HelpText", wszBuf, ARRAYSIZE(wszBuf) );
- Str_SetPtrW( &_rgebi[dwClsidIndex].pwszHelp, wszBuf);
- RegCloseKey(hkeyClsid);
- }
- dwClsidIndex++;
- }
- }
- RegCloseKey( hkey );
- }
- }
- CInternetToolbar::CInternetToolbar() : CBaseBar(), _yCapture(-1), _iButtons(-1)
- #ifdef EDIT_HACK
- , _iEditIcon(-1)
- #endif
- {
- DllAddRef();
- if (GetSystemMetrics(SM_CXSCREEN) < 650)
- _uiMaxTBWidth = MAX_TB_WIDTH_LORES;
- else
- _uiMaxTBWidth = MAX_TB_WIDTH_HIRES;
- ASSERT(_fLoading == FALSE);
- ASSERT(_btb._guidCurrentButtonGroup == CLSID_NULL);
- _btb._nNextCommandID = 1000;
- _LoadExternalBandInfo();
- }
- void CInternetToolbar::_Unadvise(void)
- {
- if(_dwcpCookie)
- {
- ConnectToConnectionPoint(NULL, DIID_DWebBrowserEvents2, FALSE, _pdie, &_dwcpCookie, NULL);
- }
- }
- int CALLBACK DeleteDPAPtrCB(void *pItem, void *pData)
- {
- LocalFree(pItem);
- return TRUE;
- }
- CInternetToolbar::~CInternetToolbar()
- {
- ATOMICRELEASE(_pdie);
- if(_pbp && _fCreatedBandProxy)
- _pbp->SetSite(NULL);
- ATOMICRELEASE(_pbp);
- ASSERT(!_ptbsite && !_ptbsitect && !_psp && !_pbs2);
- SetSite(NULL);
- DPA_DestroyCallback(_hdpaFSI, DeleteDPAPtrCB, NULL);
- for (int i = 0; i < ARRAYSIZE(_rgebi); i++)
- {
- Str_SetPtrW( &_rgebi[i].pwszName, NULL);
- Str_SetPtrW( &_rgebi[i].pwszHelp, NULL);
- }
- TraceMsg(TF_SHDLIFE, "dtor CInternetToolbar %x", this);
- DllRelease();
- }
- #define IID_DWebBrowserEvents DIID_DWebBrowserEvents
- HRESULT CInternetToolbar::QueryInterface(REFIID riid, void ** ppvObj)
- {
- static const QITAB qit[] = {
- // perf: last tuned 980728
- QITABENTMULTI(CInternetToolbar, IDispatch, DWebBrowserEvents), // IID_IDispatch
- QITABENT(CInternetToolbar, IExplorerToolbar), // IID_IDispatch
- QITABENT(CInternetToolbar, IObjectWithSite), // IID_IObjectWithSite
- QITABENT(CInternetToolbar, IPersistStreamInit), // IID_IPersistStreamInit
- QITABENT(CInternetToolbar, IDockingWindow), // IID_IDockingWindow
- QITABENT(CInternetToolbar, DWebBrowserEvents), // IID_DWebBrowserEvents
- QITABENT(CInternetToolbar, IShellChangeNotify), // rare IID_IShellChangeNotify
- QITABENT(CInternetToolbar, ISearchItems), // rare IID_ISearchItems
- { 0 },
- };
- HRESULT hres = QISearch(this, qit, riid, ppvObj);
- if (FAILED(hres))
- hres = SUPERCLASS::QueryInterface(riid, ppvObj);
- return hres;
- }
- /* IDispatch methods */
- HRESULT CInternetToolbar::GetTypeInfoCount(UINT *pctinfo)
- {
- return(E_NOTIMPL);
- }
- HRESULT CInternetToolbar::GetTypeInfo(UINT itinfo,LCID lcid,ITypeInfo **pptinfo)
- {
- return(E_NOTIMPL);
- }
- HRESULT CInternetToolbar::GetIDsOfNames(REFIID riid,OLECHAR **rgszNames,UINT cNames,
- LCID lcid, DISPID * rgdispid)
- {
- return(E_NOTIMPL);
- }
- #if 0
- // BUGBUG - StevePro changed it so this code isnt called
- // this is a goodness, because it calls SHVerbExists() which
- // is a TCHAR API, that is actually compiled as an ANSI API
- // and since we are UNICODE it just always fails.
- // leaving this in so that we know about the issue of
- // frontpad.exe possibly needing to be disabled.
- BOOL _ShowEditForExtension(LPCTSTR pszExtension)
- {
- TCHAR szBuf[MAX_PATH];
- if (SHVerbExists(pszExtension, TEXT("edit"), szBuf)) {
- // don't show it if it's just our own
- if (StrStrI(szBuf, TEXT("frontpad.exe"))) {
- return FALSE;
- }
- return TRUE;
- }
- return FALSE;
- }
- #endif
- #ifdef EDIT_HACK
- //+-------------------------------------------------------------------------
- // This function scans the html document for META tags that indicate the
- // program that was used to create the HTML page. Examples are:
- //
- // <meta name="ProgID" content="word.document" >
- // <meta name="ProgID" content="excel.sheet" >
- //
- // If a match is found, the content of the first match is returned. This
- // progid is used to edit the document.
- //--------------------------------------------------------------------------
- BSTR CInternetToolbar::_GetEditProgID
- (
- IHTMLDocument2* pHTMLDocument
- )
- {
- BSTR bstrProgID = NULL;
- //
- // First get all document elements. Note that this is very fast in
- // ie5 because the collection directly accesses the internal tree.
- //
- IHTMLElementCollection * pAllCollection;
- if (SUCCEEDED(pHTMLDocument->get_all(&pAllCollection)))
- {
- IHTMLMetaElement* pMetaElement;
- IHTMLBodyElement* pBodyElement;
- IHTMLFrameSetElement* pFrameSetElement;
- IDispatch* pDispItem;
- //
- // Now we scan the document for meta tags. Since these must reside in
- // in the head, and since Trident always creates a body tag, we can
- // stop looking when we hit the body.
- //
- // Note, the alternative of using pAllCollection->tags to return the
- // collection of meta tags is likely more expensive because it will
- // walk the whole tree (unless Trident optimizes this).
- //
- long lItemCnt;
- VARIANT vEmpty;
- V_VT(&vEmpty) = VT_EMPTY;
- VARIANT vIndex;
- V_VT(&vIndex) = VT_I4;
- EVAL(SUCCEEDED(pAllCollection->get_length(&lItemCnt)));
- for (long lItem = 0; lItem < lItemCnt; lItem++)
- {
- V_I4(&vIndex) = lItem;
- if (S_OK == pAllCollection->item(vIndex, vEmpty, &pDispItem))
- {
- //
- // First see if it's a meta tag
- //
- if (SUCCEEDED(pDispItem->QueryInterface(IID_IHTMLMetaElement,
- (void **)&pMetaElement)))
- {
- BSTR bstrName = NULL;
- //
- // We have a META element, check its NAME and CONTENT
- //
- if ( SUCCEEDED(pMetaElement->get_name(&bstrName)) && (bstrName != NULL) &&
- (StrCmpIW(bstrName, OLESTR("ProgId")) == 0) &&
- SUCCEEDED(pMetaElement->get_content(&bstrProgID)) && (bstrProgID != NULL)
- )
- {
- // We got the ProgID, so terminate the search;
- lItem = lItemCnt;
- }
- if (bstrName != NULL)
- SysFreeString(bstrName);
- pMetaElement->Release();
- }
- //
- // Next check for the body tag
- //
- else if (SUCCEEDED(pDispItem->QueryInterface(IID_IHTMLBodyElement,
- (void **)&pBodyElement)) )
- {
- // Found the body tag, so terminate the search
- lItem = lItemCnt;
- pBodyElement->Release();
- }
- //
- // Finally, check for a frameset tag
- //
- else if (SUCCEEDED(pDispItem->QueryInterface(IID_IHTMLFrameSetElement,
- (void **)&pFrameSetElement)) )
- {
- // Found a frameset tag, so terminate the search
- lItem = lItemCnt;
- pFrameSetElement->Release();
- }
- pDispItem->Release();
- }
- }
- // Make sure that these don't have to be cleared (should not have been modified)
- ASSERT(vEmpty.vt == VT_EMPTY);
- ASSERT(vIndex.vt == VT_I4);
- pAllCollection->Release();
- }
- return bstrProgID;
- }
- //+-------------------------------------------------------------------------
- // Returns grey-scale image from the icon passed in.
- //--------------------------------------------------------------------------
- HIMAGELIST CInternetToolbar::_CreateGrayScaleImagelist(HBITMAP hbmpImage, HBITMAP hbmpMask)
- {
- // Determine the button dimensions
- int cx = g_fSmallIcons ? TB_SMBMP_CX : TB_BMP_CX;
- int cy = g_fSmallIcons ? TB_SMBMP_CY : TB_BMP_CY;
- // Start with a 24 bit color image list
- HIMAGELIST himlEdit = ImageList_Create(cx, cy, ILC_COLOR24 | ILC_MASK, 1, 1);
- if (NULL == himlEdit)
- {
- return NULL;
- }
- ImageList_Add(himlEdit, hbmpImage, hbmpMask);
- // Get the dib section from the image list
- IMAGEINFO ii;
- if (ImageList_GetImageInfo(himlEdit, 0, &ii))
- {
- DIBSECTION ds = {0};
- if (GetObject(ii.hbmImage, sizeof(ds), &ds))
- {
- //
- // Map each pixel to a monochrome equivalent.
- //
- BYTE* pBits = (BYTE*)ds.dsBm.bmBits;
- BYTE* pScan = pBits;
- int xWid = ds.dsBm.bmWidth;
- int yHei = ds.dsBm.bmHeight;
- long cbScan = ((xWid * 24 + 31) & ~31) / 8;
- for (int y=0; y < yHei; ++y)
- {
- for (int x=0; x < xWid; ++x)
- {
- //
- // Map to equivalent gray color by setting r,g,b to the same value.
- // Using the average of r,g,b can be too dark, and using the max
- // of r,g,b can be too bright. So, as a simple algorithm we use
- // the average of the two schemes. This is cheaper than using true
- // intensity matching.
- //
- BYTE nMax = max(max(pScan[0], pScan[1]), pScan[2]);
- BYTE nAve = ((UINT)pScan[0] + pScan[1] + pScan[2])/3;
- pScan[0] = pScan[1] = pScan[2] = ((UINT)nMax + nAve)/2;
- // Increment to next pixel
- pScan += 3;
- }
- // Increment to the next scan line
- pBits += cbScan;
- pScan = pBits;
- }
- }
- }
- return himlEdit;
- }
- //+-------------------------------------------------------------------------
- // Returns image and mask bitmaps for the desired image list item
- //--------------------------------------------------------------------------
- BOOL MyImageList_GetBitmaps
- (
- HIMAGELIST himl, // image list to use
- int iImage, // image to copy
- int x, // x-offset to draw in bitmap
- int y, // x-offset to draw in bitmap
- int cx, // width of bitmap
- int cy, // height of bitmap
- HBITMAP* phbmpImage, // returned color bitmap
- HBITMAP* phbmpMask // returned mask bitmap
- )
- {
- ASSERT(phbmpImage);
- ASSERT(phbmpMask);
- BOOL fRet = FALSE;
- HDC hdc = GetDC(NULL);
- HDC hdcDst = CreateCompatibleDC(hdc);
- if (hdcDst)
- {
- HBITMAP hbmpImage = CreateCompatibleBitmap(hdc, cx, cy);
- if (hbmpImage)
- {
- HBITMAP hbmpMask = CreateBitmap(cx, cy, 1, 1, NULL);
- if (hbmpMask)
- {
- // Draw mask bitmap
- HBITMAP hbmpOld = (HBITMAP)SelectObject(hdcDst, hbmpMask);
- PatBlt(hdcDst, 0, 0, cx, cy, WHITENESS);
- ImageList_Draw(himl, iImage, hdcDst, x, y, ILD_MASK);
- // Draw image bitmap
- SelectObject(hdcDst, hbmpImage);
- ImageList_Draw(himl, iImage, hdcDst, x, y, ILD_NORMAL);
- SelectObject(hdcDst, hbmpOld);
- *phbmpImage = hbmpImage;
- *phbmpMask = hbmpMask;
- fRet = TRUE;
- }
- else
- {
- DeleteObject(hbmpImage);
- }
- }
- DeleteDC(hdcDst);
- }
- ReleaseDC(NULL, hdc);
- return fRet;
- }
- extern HBITMAP CreateMirroredBitmap( HBITMAP hbmOrig);
- //+-------------------------------------------------------------------------
- // Creates a special image list for the edit button and configures the edit
- // button to use it. If the hIcon is -1, the edit button is reset to use
- // it's default glyph.
- //--------------------------------------------------------------------------
- void CInternetToolbar::_SetEditGlyph
- (
- int iIcon // new edit button glyph, index into shell image cache
- )
- {
- // If no toolbar, we just need to see if we need to free the old image lists.
- if (_btb._hwnd == NULL)
- {
- if (iIcon == -1)
- {
- if (_himlEdit)
- {
- ImageList_Destroy(_himlEdit);
- _himlEdit = NULL;
- }
- if (_himlEditHot)
- {
- ImageList_Destroy(_himlEditHot);
- _himlEditHot = NULL;
- }
- }
- else
- {
- // Can't set the glyph if no toolbar!
- ASSERT(FALSE);
- }
- return;
- }
- UINT uiCmd = -1;
- // Dochost merges under one of two clsids, so have to check both
- if (FAILED(_btb._ConvertCmd(&CLSID_InternetButtons, DVIDM_EDITPAGE, NULL, &uiCmd)) &&
- FAILED(_btb._ConvertCmd(&CLSID_MSOButtons, DVIDM_EDITPAGE, NULL, &uiCmd)))
- {
- // The edit button is not on toolbar, so free the edit glyphs
- iIcon = -1;
- }
- // If the current icon is already set, we are done
- if (_iEditIcon == iIcon)
- {
- if (_himlEdit)
- {
- // Set up the new image lists
- SendMessage(_btb._hwnd, TB_SETIMAGELIST, IL_EDITBUTTON, (LPARAM)_himlEdit);
- if (_himlEditHot)
- {
- SendMessage(_btb._hwnd, TB_SETHOTIMAGELIST, IL_EDITBUTTON, (LPARAM)_himlEditHot);
- }
- // Redirect the edit button to the new image list
- TBBUTTONINFO tbi = {0};
- tbi.cbSize = sizeof(tbi);
- tbi.dwMask = TBIF_IMAGE;
- tbi.iImage = MAKELONG(0, IL_EDITBUTTON);
- SendMessage(_btb._hwnd, TB_SETBUTTONINFO, uiCmd, (LPARAM)&tbi);
- }
- return;
- }
- _iEditIcon = iIcon;
- if (-1 == iIcon)
- {
- if (_himlEdit)
- {
- if (uiCmd != -1)
- {
- // Reset to the original edit glyph
- TBBUTTONINFO tbi = {0};
- tbi.cbSize = sizeof(tbi);
- tbi.dwMask = TBIF_IMAGE;
- tbi.iImage = EDITGLYPH_OFFSET;
- SendMessage(_btb._hwnd, TB_SETBUTTONINFO, uiCmd, (LPARAM)&tbi);
- }
- // Destroy the custom edit glyphs. Note that we have to reset the primary image list
- // or the image sizes are screwed up.
- SendMessage(_btb._hwnd, TB_SETIMAGELIST, IL_EDITBUTTON, (LPARAM)NULL);
- ImageList_Destroy(_himlEdit);
- _himlEdit = NULL;
- }
- if (_himlEditHot)
- {
- SendMessage(_btb._hwnd, TB_SETHOTIMAGELIST, IL_EDITBUTTON, (LPARAM)NULL);
- ImageList_Destroy(_himlEditHot);
- _himlEditHot = NULL;
- }
- }
- else
- {
- // Determine the button dimensions
- int cx = g_fSmallIcons ? TB_SMBMP_CX : TB_BMP_CX;
- int cy = g_fSmallIcons ? TB_SMBMP_CY : TB_BMP_CY;
- // Get the image bitmaps
- HBITMAP hbmpImage = NULL;
- HBITMAP hbmpMask = NULL;
- BOOL bMirrored = IS_WINDOW_RTL_MIRRORED(_btb._hwnd);
- HIMAGELIST himlSmall;
- int cxSmall;
- int cySmall;
- if (Shell_GetImageLists(NULL, &himlSmall) &&
- ImageList_GetIconSize(himlSmall, &cxSmall, &cySmall) &&
- MyImageList_GetBitmaps(himlSmall, iIcon, (cx - cxSmall)/2, (cy - cySmall)/2,
- cx, cy, &hbmpImage, &hbmpMask))
- {
- if (bMirrored)
- {
- HBITMAP hbmpTemp;
- hbmpTemp = CreateMirroredBitmap(hbmpImage);
- if (hbmpTemp)
- {
- DeleteObject(hbmpImage);
- hbmpImage = hbmpTemp;
- }
- hbmpTemp = CreateMirroredBitmap(hbmpMask);
- if (hbmpTemp)
- {
- DeleteObject(hbmpMask);
- hbmpMask = hbmpTemp;
- }
- }
- // Create a monochrome glyph for the edit button
- HIMAGELIST himlEdit = _CreateGrayScaleImagelist(hbmpImage, hbmpMask);
- SendMessage(_btb._hwnd, TB_SETIMAGELIST, IL_EDITBUTTON, (LPARAM)himlEdit);
- if (_himlEdit)
- {
- ImageList_Destroy(_himlEdit);
- }
- _himlEdit = himlEdit;
- // Create a hot glyph for the edit button
- HIMAGELIST himlEditHot = ImageList_Create(cx, cy, ILC_COLORDDB | ILC_MASK, 1, 1);
- int nIndex = ImageList_Add(himlEditHot, hbmpImage, hbmpMask);
- SendMessage(_btb._hwnd, TB_SETHOTIMAGELIST, IL_EDITBUTTON, (LPARAM)himlEditHot);
- if (_himlEditHot)
- {
- ImageList_Destroy(_himlEditHot);
- }
- _himlEditHot = himlEditHot;
- // Redirect the edit button to the new image list
- if (_himlEdit)
- {
- TBBUTTONINFO tbi = {0};
- tbi.cbSize = sizeof(tbi);
- tbi.dwMask = TBIF_IMAGE;
- tbi.iImage = MAKELONG(nIndex, IL_EDITBUTTON);
- SendMessage(_btb._hwnd, TB_SETBUTTONINFO, uiCmd, (LPARAM)&tbi);
- }
- DeleteObject(hbmpImage);
- DeleteObject(hbmpMask);
- }
- else
- {
- // Couldn't create images so use the default edit glyph
- _SetEditGlyph(-1);
- }
- }
- }
- //+-------------------------------------------------------------------------
- // Initializes the edit button to display a drop-down menu if there are
- // multiple verbs. Also optionally displays a custion glyph.
- //--------------------------------------------------------------------------
- void CInternetToolbar::_InitEditButtonStyle()
- {
- // If we have or want a custon edit glyph, load it
- _SetEditGlyph(_aEditVerb.GetIcon());
- UINT uiCmd;
- // Dochost merges under one of two clsids, so have to check both
- if (SUCCEEDED(_btb._ConvertCmd(&CLSID_InternetButtons, DVIDM_EDITPAGE, NULL, &uiCmd)) ||
- SUCCEEDED(_btb._ConvertCmd(&CLSID_MSOButtons, DVIDM_EDITPAGE, NULL, &uiCmd)))
- {
- ASSERT(uiCmd != -1);
- // If multiple verbs, make the button a split button
- TBBUTTONINFO tbi = {0};
- tbi.cbSize = sizeof(tbi);
- tbi.dwMask = TBIF_STYLE | TBIF_STATE;
- tbi.fsState = 0;
- if (_aEditVerb.GetSize() > 1)
- {
- tbi.fsStyle |= BTNS_DROPDOWN;
- }
- if (_aEditVerb.GetSize() > 0)
- {
- tbi.fsState = TBSTATE_ENABLED;
- }
- SendMessage(_btb._hwnd, TB_SETBUTTONINFO, uiCmd, (LPARAM)&tbi);
- }
- }
- //+-------------------------------------------------------------------------
- // If the edit button is displaying a custon glyph, this function reloads
- // the glyph.
- //--------------------------------------------------------------------------
- void CInternetToolbar::_RefreshEditGlyph()
- {
- // If we have a custon edit glyph, reload it
- if (_himlEdit)
- {
- // Refresh the edit glyph
- _iEditIcon = -1;
- _InitEditButtonStyle();
- }
- }
- //+-------------------------------------------------------------------------
- // Updates the edit button based on the document type currently loaded
- //--------------------------------------------------------------------------
- void CInternetToolbar::_UpdateEditButton()
- {
- _aEditVerb.RemoveAll();
- _fEditEnabled = FALSE;
- //
- // First add editors associated with the url
- //
- BSTR bstrUrl = NULL;
- _pdie->get_LocationURL(&bstrUrl);
- if (bstrUrl)
- {
- LPTSTR pszExt;
- //
- // Find the cache file associated with the url. The file extension for this entry
- // is based off of the mime type. (Note that get_mimeType on the document
- // returns a frindly name that is hard to translate back to an actual mimetype.
- // So we use the file extension instead.)
- //
- WCHAR szCacheFileName[MAX_PATH];
- *szCacheFileName = 0;
- if (FAILED(URLToCacheFile(bstrUrl, szCacheFileName, ARRAYSIZE(szCacheFileName))))
- {
- // If we can't get a file associated with the url, probably want to disable the edit button
- // because most apps need a file to edit.
- SysFreeString(bstrUrl);
- return;
- }
- pszExt = PathFindExtension(szCacheFileName);
- // bug 79055 - The cache has a bug where some html entries are not
- // given a file extension. Too risky to fix for 5.x, so we'll just
- // assume .htm for http if no extension is present.
- if (L' ' == *pszExt && GetUrlScheme(bstrUrl) == URL_SCHEME_HTTP)
- {
- StrCpyN(szCacheFileName, L".htm", ARRAYSIZE(szCacheFileName));
- pszExt = szCacheFileName;
- }
- if (*pszExt)
- {
- _aEditVerb.Add(pszExt);
- // If ".html", use the ".htm" editors too
- if (StrCmpI(pszExt, L".html") == 0 )
- {
- // This is an html document, so add the .htm editors
- if (!_aEditVerb.Add(TEXT(".htm")) && StrCmpI(pszExt, L".html") != 0)
- {
- _aEditVerb.Add(TEXT(".html"));
- }
- }
- }
- SysFreeString(bstrUrl);
- }
- //
- // See if the feature to search the doc for the progid is enabled
- //
- static int fCheckDocForProgID = -1;
- if (fCheckDocForProgID == -1)
- {
- fCheckDocForProgID = SHRegGetBoolUSValue(REGSTR_PATH_MAIN,
- TEXT("CheckDocumentForProgID"), FALSE, TRUE) ? 1 : 0;
- }
- // Check for a meta tag that specifies a progid for editing this document
- if (fCheckDocForProgID)
- {
- //
- // Next see if this is an html document with a progid
- //
- IWebBrowser2* pWB2 = NULL;
- IDispatch * pDispatch = NULL;
- IHTMLDocument2 * pHTMLDocument = NULL;
- // Get the html document currently loaded
- if (_psp &&
- SUCCEEDED(_psp->QueryService(SID_SWebBrowserApp, IID_IWebBrowser2, (void **)&pWB2)) &&
- SUCCEEDED(pWB2->get_Document(&pDispatch)) &&
- SUCCEEDED(pDispatch->QueryInterface(IID_IHTMLDocument2, (void **)&pHTMLDocument)))
- {
- //
- // Check the current document for a META tag specifying the program to use to
- // edit this file.
- //
- BSTR bstrProgID = _GetEditProgID(pHTMLDocument);
- if (bstrProgID)
- {
- USES_CONVERSION;
- _aEditVerb.Add(W2T(bstrProgID));
- SysFreeString(bstrProgID);
- }
- }
- SAFERELEASE(pWB2);
- SAFERELEASE(pDispatch);
- SAFERELEASE(pHTMLDocument);
- }
- _fEditEnabled = (_aEditVerb.GetSize() > 0);
- // Update edit glyph, drop-down style, & enabled state
- _InitEditButtonStyle();
- }
- #endif //EDIT_HACK
- HRESULT CInternetToolbar::Invoke(DISPID dispidMember,REFIID riid,LCID lcid,WORD wFlags,
- DISPPARAMS * pdispparams, VARIANT * pvarResult,
- EXCEPINFO * pexcepinfo,UINT * puArgErr)
- {
- ASSERT(pdispparams);
- if(!pdispparams)
- return E_INVALIDARG;
- switch(dispidMember)
- {
- case DISPID_NAVIGATECOMPLETE2:
- {
- //
- // Notify the brand and theater mode objects about whether we're in shell or
- // web mode. Wait til now to do it (rather than doing it in SetCommandTarget)
- // because they might want to ask the browser about the new pidl, which isn't
- // yet filled in at SetCommandTarget time.
- //
- DWORD nCmdexecopt = _fShellView ? CITE_SHELL : CITE_INTERNET;
- LPBANDITEMDATA pbid = _bs._GetBandItemDataStructByID(CBIDX_BRAND);
- if (pbid)
- {
- IUnknown_Exec(pbid->pdb, &CGID_PrivCITCommands, CITIDM_ONINTERNET, nCmdexecopt, NULL, NULL);
- }
- if (_fTheater)
- {
- IUnknown_Exec(_ptbsite, &CGID_Theater, THID_ONINTERNET, nCmdexecopt, NULL, NULL);
- }
- _fNavigateComplete = TRUE;
- }
- break;
- case DISPID_BEFORENAVIGATE:
- {
- BOOL fWeb = FALSE;
- ASSERT((pdispparams->rgvarg[5].vt == VT_BSTR) &&
- (pdispparams->rgvarg[5].bstrVal != NULL));
- PARSEDURL pu = { 0 };
- USES_CONVERSION;
- pu.cbSize = SIZEOF(pu);
- ParseURL(W2T(pdispparams->rgvarg[5].bstrVal), &pu);
- if ((URL_SCHEME_UNKNOWN != pu.nScheme) && (URL_SCHEME_FILE != pu.nScheme))
- fWeb = TRUE;
- UINT uiState = 0;
- GetState(&CLSID_CommonButtons, TBIDM_STOPDOWNLOAD, &uiState);
- if ((uiState & TBSTATE_HIDDEN) && fWeb)
- {
- _fTransitionToHTML = TRUE;
- uiState &= ~TBSTATE_HIDDEN;
- SetState(&CLSID_CommonButtons, TBIDM_STOPDOWNLOAD, uiState);
- }
- // Default to the edit button hidden
- _fEditEnabled = FALSE;
- }
- break;
- case DISPID_DOWNLOADBEGIN:// This is when we just started to navigate? No bits?
- _StartDownload();
- break;
- case DISPID_DOWNLOADCOMPLETE: // we be done
- _fTransitionToHTML = FALSE;
- _StopDownload(FALSE);
- break;
- case DISPID_DOCUMENTCOMPLETE: // This is where we have all the bits
- {
- //
- // Sometimes we get a premature document complete. We can catch this
- // by checking to see if we have received a DISPID_NAVIGATECOMPLETE2 event.
- //
- if (_fNavigateComplete)
- {
- _fNavigateComplete = FALSE;
- _UpdateEditButton();
- }
- break;
- }
- case DISPID_COMMANDSTATECHANGE:
- BOOL fEnable;
- if(!pdispparams || (pdispparams->cArgs != 2) ||
- (pdispparams->rgvarg[0].vt != VT_BOOL) ||
- (pdispparams->rgvarg[1].vt != VT_I4))
- return E_INVALIDARG;
- fEnable = (BOOL) pdispparams->rgvarg[0].boolVal;
- UINT uiCmd;
- switch (pdispparams->rgvarg[1].lVal)
- {
- case CSC_UPDATECOMMANDS:
- // corresponds to OLECMDID_UPDATECOMMANDS from Exec()
- _UpdateToolbar(FALSE);
- break;
- case CSC_NAVIGATEBACK:
- _fBackEnabled = fEnable;
- _btb._ConvertCmd(&CLSID_CommonButtons, TBIDM_BACK, NULL, &uiCmd);
- SendMessage(_btb._hwnd, TB_ENABLEBUTTON, uiCmd, MAKELONG(fEnable, 0));
- break;
- case CSC_NAVIGATEFORWARD:
- _fForwardEnabled = fEnable;
- _btb._ConvertCmd(&CLSID_CommonButtons, TBIDM_FORWARD, NULL, &uiCmd);
- SendMessage(_btb._hwnd, TB_ENABLEBUTTON, uiCmd, MAKELONG(fEnable, 0));
- break;
- default:
- return(E_INVALIDARG);
- }
- // BUGBUG need to handle the case of navigation failure and
- // do some cleanup
- }
- return S_OK;
- }
- //*** CInternetToolbar::IInputObjectSite::* {
- HRESULT CInternetToolbar::OnFocusChangeIS(IUnknown *punk, BOOL fSetFocus)
- {
- return UnkOnFocusChangeIS(_ptbsite, SAFECAST(this, IInputObject*), fSetFocus);
- }
- // }
- //*** CInternetToolbar::IInputObject::* {
- HRESULT CInternetToolbar::TranslateAcceleratorIO(LPMSG lpMsg)
- {
- LPBANDITEMDATA pbid;
- if (_fShow)
- {
- if (lpMsg->message == WM_KEYDOWN)
- {
- switch (lpMsg->wParam)
- {
- case VK_F4:
- Laddrband:
- if (_nVisibleBands & VBF_ADDRESS)
- {
- pbid = _bs._GetBandItemDataStructByID(CBIDX_ADDRESS);
- if (EVAL(pbid))
- {
- HRESULT hrT;
- hrT = UnkTranslateAcceleratorIO(pbid->pdb, lpMsg);
- ASSERT(hrT == S_OK);
- }
- }
- return S_OK; // (even if we just eat it)
- }
- }
- else if(lpMsg->message == WM_SYSCHAR)
- {
- static CHAR szAccel[2] = "
English
