Solved

Add a button to IE's Toolbar to navigate http://somewhere?

Posted on 2002-07-22
8
290 Views
Last Modified: 2013-12-03
After i installed some software,it can add a button to IE's standard button bar.Once i click the button ,my IE would go to the software's homepage.

I searched in Regedit,i found this key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Extensions

Now i can add a button to run a EXE file,but how to let it navigate a specified URL,such as http://www.yahoo.com?

Thanks!
0
Comment
Question by:Conwood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 2

Expert Comment

by:SChertkov
ID: 7171028
You must create small COM object that implements
interface  IOleCommandTarget (and optionally IObjectWithSite for access to DHTML) and register
it in HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Extensions\

For details referer to MSDN for additional details

http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/ext/tutorials/button.asp

0
 
LVL 9

Accepted Solution

by:
BeyondWu earned 100 total points
ID: 7173604
To do this, you need to implement IObjectWithSite interface. In the IObjectWithSite::SetSite(IUnknown* pUnkSite), IE will input an interface, you can get IWebBrowser2 from this interface, then call IWebBrowser2::Navigate(URL,...
#include <atlbase.h>
CYourExplorerButton::SetSite(IUnknown* punkSite)
{
   CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> spWebBrowser2;
   // Query pUnkSite for the IWebBrowser2 interface.
   m_spWebBrowser2 = pUnkSite;

   // navigate to any URL
   CComBSTR bstrURL(szURL);
   CComVariant vtEmpty;

   spWebBrowser2->Navigate(bstrURL, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);
   // ...
}
0
 
LVL 2

Expert Comment

by:SChertkov
ID: 7173639
You code will navigate to URL every time when call
IObjectWithSite::SetSite from browser. I think every time
when browser open.

spWebBrowser2->Navigate must calling in
IOleCommandTarget::Exec
0
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
LVL 1

Expert Comment

by:Jenn050402
ID: 7174381
Conwood,
See if this helps...

See this site for how IE's toolbar buttons are constructed and behave:
http://msdn.microsoft.com/workshop/browser/ext/tutorials/button.asp
http://msdn.microsoft.com/workshop/browser/ext/overview/toolbar_style.asp

Jenn

0
 
LVL 9

Expert Comment

by:BeyondWu
ID: 7176016
SChertkov, you are right,
Conwood, I made a mistake.
At the CYourExplorerButton::SetSite(IUnknown* punkSite), you should save the IWebBrowser2 interface, and in IOleCommandTarget::Exec, you can call spWebBrowser2->Navigate(bstrURL, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);

#include <atlbase.h>
// please add the spWebBrowser2 into your class as a data member.
// so just as a global variable.
CComQIPtr<IWebBrowser2, &IID_IWebBrowser2> spWebBrowser2;

CYourExplorerButton::SetSite(IUnknown* punkSite)
{
  // Query pUnkSite for the IWebBrowser2 interface.
  // and save it.
  m_spWebBrowser2 = pUnkSite;
  // ...
}

CYourExplorerButton::Exec(...)
{
  // navigate to any URL
  CComBSTR bstrURL(szURL);
  CComVariant vtEmpty;

  spWebBrowser2->Navigate(bstrURL, &vtEmpty, &vtEmpty, &vtEmpty, &vtEmpty);
  // ...
}


0
 

Author Comment

by:Conwood
ID: 7176039
Thanks all.
I'm busy with exams these days , so perhaps I have to try your method some days later.

Another question:how I can i give 200 marks to you three?
I mean , for example : give one 100 , another 50 , another 50.
0
 
LVL 1

Expert Comment

by:Jenn050402
ID: 7177585
You can post a message in community support saying you want your points refunded because you want to split them.
Then post a "points for ..." question in the Windows Programming area for the users you want the points to go to worth how many points you want to give each. When the user posts an answer (just something saying "thanks for the points..." you accept answer.

 
0
 
LVL 1

Expert Comment

by:Computer101
ID: 7183369
Points have been reduced to 100 and the remaining 100 refunded to you.  Now you can accept a comment from one expert.  After that, make another question in this topic area for the other expert.

Compmuter101
E-E Moderator
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question