Anna Danekina
Posts: 2
Joined: 2010-03-26
|
Dear colleagues!
Please help me understand what I?Â?Ð?ém doing wrong!
I have a problem when I programmatically activate my IE toolbar from other program.
Making it following the instruction given at Microsoft support site (http://support.microsoft.com/kb/q255920/):
SHDocVw::IWebBrowser2Ptr pIE;
HRESULT hr = ::CoCreateInstance(CLSID_InternetExplorer, NULL,
CLSCTX_LOCAL_SERVER, IID_IWebBrowser2, (LPVOID*)&pIE);
if(FAILED(hr)) return;
try {
_variant_t vClsID;
_variant_t vVis;
_variant_t vNotUsed;
vClsID.vt = VT_BSTR;
vClsID.bstrVal = SysAllocString(OLESTR("{MY_TOOLBAR_GUID}"));
vVis.vt = VT_BOOL;
vVis.boolVal = VARIANT_TRUE;
vNotUsed.vt = VT_INT;
vNotUsed.intVal = 1;
hr = pIE->ShowBrowserBar()(&vClsID, &vVis, &vNotUsed);
SysFreeString(vClsID.bstrVal);
if(FAILED(hr)) return;
}catch(...) {return;}
pIE->Navigate2(&Url);
pIE->Visible = TRUE;
This code works correctly in IE7, but doesn't work in IE8. In both cases ShowBrowserBar() returns S_OK, but in IE8 toolbar.dll is not loaded into the browser, i.e. the toolbar is not activated and therefore not displayed.
I also tried to launch IE8 with three tabs and check if ShowBrowserBar() attempts to open the toolbar in the tabs, not the manager process.
It is log file:
Handle url 'outlook:'
ShowBrowserBar() FAILED!
Handle url 'http://www.handypassword.com'
ShowBrowserBar() SUCCESSED!
Handle url 'http://www.google.ru/'
ShowBrowserBar() SUCCESSED!
Handle url 'http://vkontakte.ru/'
ShowBrowserBar() SUCCESSED!
Everything works as expected in IE7, but not in IE8, and I can't understand why the ShowBrowserBar() method returns S_OK in both of them.
Has anybody got any clues?
Warm regards,
Anna. |
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Anna.
As far as I remember, there is a bug in the IE object model. You need to hide the toolbar before you show it via the ShowBrowserBar method. Please look at the following C# code:
internal void ShowBrowserBar(Guid g, bool bShow)
{
if (this.ieObj != null)
{
try
{
if (bShow)
{
this.ieObj.GetType().InvokeMember("ShowBrowserBar", BindingFlags.InvokeMethod,
null, this.ieObj, new object[] { g.ToString("B"), false, null });
}
this.ieObj.GetType().InvokeMember("ShowBrowserBar", BindingFlags.InvokeMethod,
null, this.ieObj, new object[] { g.ToString("B"), bShow, null });
}
catch
{
}
}
} |
|
Anna Danekina
Posts: 2
Joined: 2010-03-26
|
Thanks for your advice, Sergey!
I tried this. The result is the same. If the toolbar is inactive, then ShowBrowserBar() returns S_OK for both hide and show, but the toolbar itself doesn't do anything. |
|
Sergey Grischenko
Add-in Express team
Posts: 7233
Joined: 2004-07-05
|
Hi Anna.
Sorry, I don't have another solution. Please try to google this issue. |
|