Chinaunix首页 | 论坛 | 博客
  • 博客访问: 14497774
  • 博文数量: 5645
  • 博客积分: 9880
  • 博客等级: 中将
  • 技术积分: 68081
  • 用 户 组: 普通用户
  • 注册时间: 2008-04-28 13:35
文章分类

全部博文(5645)

文章存档

2008年(5645)

我的朋友

分类:

2008-04-28 21:34:23

下载本文示例代码
  免费教你开发IE插件Toolbar的文章可真是少见。还好我在codeproject里找到一篇。不过还是花了一天的时间才自己编写一个Google Search Toolbar。  如果你下载了Internet Explorer Toolbar (Deskband) Tutorial的源代码后编译不通过,也不用奇怪,我就是耽搁在这些地方。先说说都有哪些编译问题。  1.编译的问题    如果遇到下面的问题,就说明commctrl.h的版本低。我们完全可以不用TBSTYLE_EX_MIXEDBUTTONS,用TBSTYLE_EX_DRAWDDARROWS就行。另外的三个删掉,换成TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE,这个问题就解决了。 error C2065: 'TBSTYLE_EX_MIXEDBUTTONS' : undeclared identifiererror C2065: 'BTNS_BUTTON' : undeclared identifiererror C2065: 'BTNS_AUTOSIZE' : undeclared identifiererror C2065: 'BTNS_SHOWTEXT' : undeclared identifier  如果遇到下面问题,把工程文件(dsp)里面的/D _ATL_MIN_CRT删掉。 Linking...Creating library ReleaseUMinDependency/MotleyFool.lib and object ReleaseUMinDependency/MotleyFool.expLIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _mainReleaseUMinDependency/MotleyFool.dll : fatal error LNK1120: 1 unresolved externalsError executing link.exe. MotleyFool.dll - 2 error(s), 0 warning(s)  如果你自己重新编写一个新的项目实现IE Toolbar的话,注意一下2个地方。  1.注意CMFToolbar的消息映射顺序。CHAIN_MSG_MAP_MEMBER一定要在WM_CREATE的前面。 BEGIN_MSG_MAP(CToolbarWnd)CHAIN_MSG_MAP_MEMBER(m_EditWnd)MESSAGE_HANDLER(WM_CREATE, OnCreate)…END_MSG_MAP()  2.注意CReflectionWnd的消息映射顺序。WM_CREATE一定要在CHAIN_MSG_MAP_MEMBER的前面。 BEGIN_MSG_MAP(CReflectWnd)MESSAGE_HANDLER(WM_CREATE, OnCreate)CHAIN_MSG_MAP_MEMBER(m_ToolbarWnd)END_MSG_MAP()  3.Google Search Toolbar   codeproject有非常详细的开发步骤,在这里就不重复了。本节的目的是实现Google Search功能。创建ColimasBar工程,创建CColimasBar类,IE Plugin接口: public CComObjectRootEx,public CComCoClass,public IDeskBand,public IInputObject,public IObjectWithSite,public IDispatchImpl  创建CEditWnd类,输入栏控件,继承 public CWindowImpl  创建CReflectWnd类,消息传递空间,继承 public CWindowImpl  创建CToolbarWnd类,Toolbar控件,继承 public CWindowImpl  修改Toolbar的Title: const WCHAR TITLE_CColimasBar[] = L"Google";  修改Button的Title: TCHAR* pCaption = _T("Search!");  增加Button点击事件的Google Search处理函数GetValue void CToolbarWnd::GetValue(){ // if we have a web browser pointer then try to navigate to google site to retrieve search if (m_pBrowser) {  VARIANT vEmpty;  VariantInit(&vEmpty);  m_pBrowser->Stop();  _bstr_t bsSite;  // if the user has entered url then append them to the edit  if (m_EditWnd.GetWindowTextLength())  {   WCHAR *bstr = NULL;   m_EditWnd.GetWindowText(&bstr);   UINT i= WideCharToMultiByte(CP_UTF8,0,bstr,-1,NULL,0,NULL,NULL); //双字节转换   char *strB=new char[i];    WideCharToMultiByte (CP_UTF8,0,bstr,-1,strB,i,NULL,NULL); //转换为ASCII   UINT len=i;   char* tmp=new char[len*3];   tmp[0]='\0';   for(i=0;iNavigate(bsSite, &vEmpty, &vEmpty, &vEmpty, &vEmpty); }}   免费教你开发IE插件Toolbar的文章可真是少见。还好我在codeproject里找到一篇。不过还是花了一天的时间才自己编写一个Google Search Toolbar。  如果你下载了Internet Explorer Toolbar (Deskband) Tutorial的源代码后编译不通过,也不用奇怪,我就是耽搁在这些地方。先说说都有哪些编译问题。  1.编译的问题    如果遇到下面的问题,就说明commctrl.h的版本低。我们完全可以不用TBSTYLE_EX_MIXEDBUTTONS,用TBSTYLE_EX_DRAWDDARROWS就行。另外的三个删掉,换成TBSTYLE_BUTTON | TBSTYLE_AUTOSIZE,这个问题就解决了。 error C2065: 'TBSTYLE_EX_MIXEDBUTTONS' : undeclared identifiererror C2065: 'BTNS_BUTTON' : undeclared identifiererror C2065: 'BTNS_AUTOSIZE' : undeclared identifiererror C2065: 'BTNS_SHOWTEXT' : undeclared identifier  如果遇到下面问题,把工程文件(dsp)里面的/D _ATL_MIN_CRT删掉。 Linking...Creating library ReleaseUMinDependency/MotleyFool.lib and object ReleaseUMinDependency/MotleyFool.expLIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _mainReleaseUMinDependency/MotleyFool.dll : fatal error LNK1120: 1 unresolved externalsError executing link.exe. MotleyFool.dll - 2 error(s), 0 warning(s)  如果你自己重新编写一个新的项目实现IE Toolbar的话,注意一下2个地方。  1.注意CMFToolbar的消息映射顺序。CHAIN_MSG_MAP_MEMBER一定要在WM_CREATE的前面。 BEGIN_MSG_MAP(CToolbarWnd)CHAIN_MSG_MAP_MEMBER(m_EditWnd)MESSAGE_HANDLER(WM_CREATE, OnCreate)…END_MSG_MAP()  2.注意CReflectionWnd的消息映射顺序。WM_CREATE一定要在CHAIN_MSG_MAP_MEMBER的前面。 BEGIN_MSG_MAP(CReflectWnd)MESSAGE_HANDLER(WM_CREATE, OnCreate)CHAIN_MSG_MAP_MEMBER(m_ToolbarWnd)END_MSG_MAP()  3.Google Search Toolbar   codeproject有非常详细的开发步骤,在这里就不重复了。本节的目的是实现Google Search功能。创建ColimasBar工程,创建CColimasBar类,IE Plugin接口: public CComObjectRootEx,public CComCoClass,public IDeskBand,public IInputObject,public IObjectWithSite,public IDispatchImpl  创建CEditWnd类,输入栏控件,继承 public CWindowImpl  创建CReflectWnd类,消息传递空间,继承 public CWindowImpl  创建CToolbarWnd类,Toolbar控件,继承 public CWindowImpl  修改Toolbar的Title: const WCHAR TITLE_CColimasBar[] = L"Google";  修改Button的Title: TCHAR* pCaption = _T("Search!");  增加Button点击事件的Google Search处理函数GetValue void CToolbarWnd::GetValue(){ // if we have a web browser pointer then try to navigate to google site to retrieve search if (m_pBrowser) {  VARIANT vEmpty;  VariantInit(&vEmpty);  m_pBrowser->Stop();  _bstr_t bsSite;  // if the user has entered url then append them to the edit  if (m_EditWnd.GetWindowTextLength())  {   WCHAR *bstr = NULL;   m_EditWnd.GetWindowText(&bstr);   UINT i= WideCharToMultiByte(CP_UTF8,0,bstr,-1,NULL,0,NULL,NULL); //双字节转换   char *strB=new char[i];    WideCharToMultiByte (CP_UTF8,0,bstr,-1,strB,i,NULL,NULL); //转换为ASCII   UINT len=i;   char* tmp=new char[len*3];   tmp[0]='\0';   for(i=0;iNavigate(bsSite, &vEmpty, &vEmpty, &vEmpty, &vEmpty); }} 下载本文示例代码


IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介IE工具条插件Toolbar开发简介
阅读(123) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~