电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

用VC开发IE浏览器插件:IE Toolbar


发布日期:2019/9/21
 
如果你下载了Internet Explorer Toolbar (Deskband) Tutorial的源代码后编译不通过也不用奇怪我就是耽搁在这些地方先说说都有哪些编译问题

.编译的问题

如果遇到下面的问题就说明commctrlh的版本低我们完全可以不用TBSTYLE_EX_MIXEDBUTTONS用TBSTYLE_EX_DRAWDDARROWS就行另外的三个删掉换成

TBSTYLE_BUTTON TBSTYLE_AUTOSIZE这个问题就解决了

error C: TBSTYLE_EX_MIXEDBUTTONS : undeclared identifier

error C: BTNS_BUTTON : undeclared identifier

error C: BTNS_AUTOSIZE : undeclared identifier

error C: BTNS_SHOWTEXT : undeclared identifier

如果遇到下面问题把工程文件(dsp)里面的/D _ATL_MIN_CRT删掉

Linking

Creating library ReleaseUMinDependency/MotleyFoollib and object ReleaseUMinDependency/MotleyFoolexp

LIBCMTlib(crtobj) : error LNK: unresolved external symbol _main

ReleaseUMinDependency/MotleyFooldll : fatal error LNK: unresolved externals

Error executing linkexe

MotleyFooldll error(s) warning(s)

如果你自己重新编写一个新的项目实现IE Toolbar的话注意一下个地方

.注意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()

.注意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()

.Google Search Toolbar

有非常详细的开发步骤在这里就不重复了本节的目的是实现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[] = LGoogle;

修改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_EditWndGetWindowTextLength())

{

WCHAR *bstr = NULL;

m_EditWndGetWindowText(&bstr);

UINT i= WideCharToMultiByte(CP_UTFbstrNULLNULLNULL); //双字节转换

char *strB=new char[i];

WideCharToMultiByte (CP_UTFbstrstrBiNULLNULL); //转换为ASCII

UINT len=i;

char* tmp=new char[len*];

tmp[]=\;

for(i=;i {

byte j= (unsigned char)strB[i]; sprintf(tmp,"%s%%%x",tmp,j); //转换为16进制。Tw.wINgWiT.coM

}

bsSite = L"-CNq=";

//Google Search字符串

bsSite += tmp;

bsSite += "rls=com.microsoft:en-USie=utf8oe=utf8";

SysFreeString(bstr);

delete[] strB;

}

else

bsSite = "";

// have the webrowser navigate to the site URL requested depending on user input.

m_pBrowser->Navigate(bsSite, &vEmpty, &vEmpty, &vEmpty, &vEmpty);

}

}

本文涉及到的所有知识请参照

上一篇:创建表头固定,表体可滚动的GridView

下一篇:初探DeepEarth控件