Introduction to toolbar development of IE Toolbar plug-in

Source: Internet
Author: User
Http://www.codeproject.com/KB/shell/ietoolbartutorial.aspx
This tutorial assumes that you already know how to program in C ++ and know
Some information about ATL and COM. To work through this tutorial, you will need
The following installed on your development machine:
1. Visual C ++ 6 installed

2. rbdeskband ATL object wizard (Version
2.0): http://www.codeproject.com/KB/atl/rbdeskband.aspx
3. csf-wimpl ATL
Object Wizard: http://www.codeproject.com/KB/atl/rbcwindowimpl.aspx

Http://www.pcworld.com.cn/how_to_use/1/2006/0915/7923.shtml
Reference: articles that teach you how to develop IE Plug-In toolbar for free are rare. Fortunately, I found an article in codeproject. However, it took a day to write a Google
Search toolbar.

Articles that teach you how to develop IE Plug-In toolbar for free are rare. Fortunately, I found an article in codeproject. However, it took a day to write a Google
Search toolbar.

If you download the Internet Explorer Toolbar (bandwidth band)
The source code of tutorial cannot be compiled, so it is not surprising that I am stuck in these places. Let's talk about the compilation problems.

1. compilation problems
 

If you encounter the following problems, the version of commctrl. H is low. We can use tbstyle_ex_mixedbuttons instead.
Tbstyle_ex_drawddarrows. Delete the other three items and change them to tbstyle_button | tbstyle_autosize. This problem is solved.

Error c2065: 'tbstyle _ ex_mixedbuttons ': Undeclared identifier
Error
C2065: 'btns _ click': Undeclared identifier
Error c2065: 'btns _ autosize ':
Undeclared identifier
Error c2065: 'btns _ showtext': Undeclared identifier

If you encounter the following problems, delete the/D _ atl_min_crt in the project file (DSP.

Linking...
Creating
Library releaseumindependency/motleyfool. lib and Object
Releaseumindependency/motleyfool. Exp
Libcmt. Lib (crt0.obj): Error lnk2001:
Unresolved external symbol _ main
Releaseumindependency/motleyfool. dll:
Fatal error lnk1120: 1 unresolved externals
Error executing link.exe.

Motleyfool. dll-2 error (s), 0 warning (s)
If you re-compile a new project to Implement IE
If toolbar is used, pay attention to the following two points.

1. Pay attention to the Message ing sequence of cmftoolbar. Chain_msg_map_member must be in front of wm_create.

Begin_msg_map (ctoolbarwnd)
Chain_msg_map_member (m_editwnd)

Message_handler (wm_create, oncreate)
...
End_msg_map ()

2. Pay attention to the Message ing sequence of creflectionwnd. Wm_create must be prior to 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 has very detailed development steps, which will not be repeated here. The purpose of this section is to implement
Search function. Create a colimasbar project and a ccolimasbar class. The IE plugin interface is as follows:

Public
Ccomobjectrootex <ccomsinglethreadmodel>,
Public
Ccomcoclass <ccolimasbar, & clsid_colimasbar>,
Public ideskband,

Public iinputobject,
Public iobjectwithsite,
Public
Idispatchimpl <icolimasbar, & iid_icolimasbar, & libid_iebaselib>

Create ceditwnd class, input bar control, inherit

Public cwindowimpl <ceditwnd>

Create the creflectwnd class, transfer the message space, and inherit

Public cwindowimpl <ceditwnd>

Create ctoolbarwnd class, Toolbar Control, inherit

Public cwindowimpl <ceditwnd>

Modify the title of a toolbar:

Const wchar title_ccolimasbar [] = l "google ";

Modify the title of a button:

Tchar * pcaption = _ T ("search! ");

Added the Google search processing function getvalue for the button click event.

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); // double-byte Conversion
Char
* Strb = new char [I];
Widechartomultibyte
(Cp_utf8, 0, BSTR,-1, strb, I, null, null); // convert to ASCII
Uint Len = I;
Char *
TMP = new char [Len * 3];
TMP [0] = '/0 ';

For (I = 0; I <len-1; I ++)

{
Byte J = (unsigned char) strb [I]; sprintf (TMP, "% S % x", TMP, J );
// Convert to hexadecimal.

}

Bssite =
L "http://www.google.com/search? Hl = ZH-CN & Q = ";
// Google search string

Bssite + = TMP;
Bssite + =
"& RLS = com. Microsoft: En-US & Ie = utf8 & OE = utf8 ";

Sysfreestring (BSTR );
Delete [] strb;
}
Else

Bssite = "http://www.google.com /";
// Have the webrowser navigate
To the site URL requested depending on user input.

M_pbrowser-> navigate (bssite, & vempty,
& Vempty );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.