|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionThis working example is based on the Toolbar for IE sample by Rashid Thadha. I tried to incorporate most features that are found in the Google toolbar (and some new ones). It looks much like the Google Bar now and now you can even customize it. I am planning to list of support bug, features list at toolbar's homepage. Hope there will be more images, FAQs and knowledge bases. Features
New Features
I am sure I forgot about some other features I implemented :( Have a look through source code to find some more... :) InstallationTo install the ToolBar: run "regsvr32.exe %path%\2Find.dll". It will check for the 2find.xml and some other files in the same directory. If they are not present there then it will try to download them from http://zmike.chat.ru/toolbar directory. If it can't be done it will display an "empty" toolbar in IE. In the new version you can open toolbar_sample.html in your IE and installation process will start automatically. Note: you can use WinZip to extract the .dll file from the .cab file. BuildingYou have to download and install Microsoft Platform SDK (at least Core SDK). Also check that you installed SP5 for Visual Studio. On NT4 ensure you have installed SP6a. Add in the first include directory for Platform Sdk (something like "E:\Microsoft Platform SDK\Include" in VC++ -> Tools -> Options -> Directories -> Include files). For example:
To help you (if you don't want to download and install Platform SDK), I've put the necessary compressed includes from the Platform SDK here. Use the latest WinRar to extract them:
Don't forget to include the WTL library (7.0). Check out NamesInc.cpp for some important constants. I tried to help you (if you don't want to download and install Platform SDK) I've put the comppresed includes from Platform SDK here. Use the latest WinRar to extract them:
Don't forget about the WTL library. See NamesInc.cpp for some important constants. Sample OverviewI'll describe here only the differences and new features that I added/changed. For more details see the Toolbar for IE sample by Rashid Thadha. To Implement the automatic detection of changed files and downloading them from web-server - feature and to prevent changing the toolbar on client side (disabled in this sample). I use the You can even make .asp file on your web server and send a .xml file (with settings ) as output of it. Look at these lines: #ifdef _ECOACH if (sstrFile == _bstr_t(L"ecoach.xml")) sstrFile = L"ecoach.asp"; #endif Here is main code to open a new web browser to display and enable the toolbar. IWebBrowser2 *pIE;
HRESULT hr = CoCreateInstance(CLSID_InternetExplorer, NULL,
CLSCTX_LOCAL_SERVER,
IID_IWebBrowser2,(void**)&pIE);
pIE->put_Visible(VARIANT_TRUE);
VARIANT vtBandGUID;
VARIANT vtShow;
VARIANT vtNotUsed;
vtBandGUID.vt = VT_BSTR;
vtBandGUID.bstrVal = SysAllocString( pszBarCLSID );
vtShow.vt = VT_BOOL;
vtShow.boolVal = bShow;
vtNotUsed.vt = VT_INT;
vtNotUsed.intVal = 1;
HRESULT hr = pIE->ShowBrowserBar(&vtBandGUID, &vtShow,
&vtNotUsed);
SysFreeString(vtBandGUID.bstrVal);
Here is an example of how to register the IHTMLElementPtr e3 = NULL; pHtmlDoc3->getElementById(_bstr_t(m_id.c_str()),&e3); if (e3) { IHTMLDocument2Ptr pHtmlDoc2 = pHtmlDoc3; IHTMLSelectElement *e = NULL; HRESULT hr= e3->QueryInterface( __uuidof( IHTMLSelectElement ), (void**)&e); e3->Release(); if (e) { LPDISPATCH dispFO = CHtmlEventObject<CBANDTOOLBARCTRL>::CreateHandler(ctrl, CBandToolBarCtrl::OnSelChange, 1); VARIANT vIn; V_VT(&vIn) = VT_DISPATCH; V_DISPATCH(&vIn) = dispFO; hr = e->put_onchange( vIn ); } } And here is the prototype for the handler: void OnSelChange( DISPID id, VARIANT* pVarResult );
I use these functions to detect if any documents (for example the options page) have been loaded. BEGIN_SINK_MAP(CPugiObj) SINK_ENTRY_EX(0, DIID_DWebBrowserEvents2, DISPID_ONQUIT, OnQuit) SINK_ENTRY_EX(0, DIID_DWebBrowserEvents2, DISPID_DOWNLOADCOMPLETE, OnDownloadComplete) END_SINK_MAP() We can also modify the loaded page and/or add new elements: IHTMLElementPtr element; hr = pHtmlDoc2->createElement(_bstr_t(L"OPTION"),&element); IHTMLOptionElementPtroption = element; option->put_text(_bstr_t(ctrl->m_toolbar-> m_toolbarItems->m_caption.c_str())); hr = e->add(element,_variant_t(long(-1))); or change old ones. IHTMLInputElement *i = NULL; HRESULT hr = el->QueryInterface( __uuidof( IHTMLInputElement), (void**)&i ); if (i) { i->put_checked(VARIANT_TRUE);i->Release(); } I use this code to load the bitmaps from disk. CImageList list; list.CreateFromImage((wchar_t*)filebmp,bSize.cy,0, CLR_DEFAULT,IMAGE_BITMAP, LR_CREATEDIBSECTION|LR_LOADFROMFILE); And this from the resources: CImageList ilCool; ilCool.CreateFromImage(IDB_TOPICONS,16,0, CLR_DEFAULT,IMAGE_BITMAP, LR_CREATEDIBSECTION); m_wndToolBar.SetImageList(ilCool); And this one to load from another .dll file: h_image = LoadLibrary(filebmp.c_str());
EnumResourceNames(h_image,RT_BITMAP,EnumResNameProc,0);
CImageList list;
list.Create (bSize.cx,bSize.cy,ILC_COLORDDB|ILC_MASK,0,1);
list.Add(LoadImage(s),clr_format);
Here is the appending owner-draw menu: handle.AppendMenu(MF_OWNERDRAW,WM_MENU_USER + MAX_MENU_SIZE*id +j,
LPCTSTR(pMI));
I added this handler to process the default function; you can find them in Platform SDK. MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem) MESSAGE_HANDLER(WM_MEASUREITEM, OnMeasureItem) Expected multi-level menu ! CAB packageI demonstrate how to make an install packgage. Use CabArc.Exe, makecert.exe, exptext.exe, signcode.exe See toolbar_sample.bat and toolbar_sample.html for details. POST requestSee post attribute in Include additional XML.use (<INCLUDEXML>toolbar_sample_ex.xml</INCLUDEXML>)in XML file Single / Split / None types for Buttons in the main menu.
You can use current URL, domain, toolbar_id and some other in web url and posting data. Some commands are replaced with a new You can set/get attributes to the toolbar from javascript put_NID, put_Pass, get_ver. Uninstall removes ALL Downloaded files. I store them in HKEY_CURRENT_USER\Software\toolbar_sample\toolbar_sample\Historyfiles Added xmill support to compress XML files. I didn't add sources it in this sample but you can easy insert it. see Added icon into standard toolbar to show/hide your toolbar. CRegKey keyAppID; keyAppID.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Internet Explorer\\Extensions PAGE tag - you can insert HTML page into toolbar. See... class CPage : public IDispEventImpl<1, CPage, &DIID_DWebBrowserEvents2, ...for details - it is very short. Hot images into multi-level menu. I chaged CCommandBarCtrlImpl::DrawItem3D function a little. Load xml and images from resources. Find load images from external dll file. Find Several fonts You can add several Also:
<SHELLEXECUTE name="Send mail" command="mailto:mtscf@microsoft.com?subject=Feedback&body= All other features and functions implemented looking in MSDN and codeproject site :-)
Auto Complete and Tooltips
Chevrons
Drag - drop in search combo-box
Change Image on Mouse Image Entering, All Buttons as Images
XML SchemaYou can see xml source here
I am using my own XML parser helper to process it. OptionsNote that there are NO scripts in options page. I use events to set/get settings. You can see the HTML text here
Adrian Bickle helped me in editing of this article. I am planning to add more details about implementation. But please tell me what items are more interesting for you. Victor Chiel made a great index of Index of Bugs, fixes, request, isntalation problems I am planing to support list of bug, features list at toolbar's homepage. Thank you for your attention. History
|
||||||||||||||||||||||