熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

用VC開發IE浏覽器插件:IE Toolbar

2022-06-13   來源: .NET編程 
如果你下載了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);
}
}

本文涉及到的所有知識請參照
From:http://tw.wingwit.com/Article/program/net/201311/12538.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.