window handle for active tab

hi folks,

when a document completes loading in a new tab,

my bho gets notified viaDISPID_DOCUMENTCOMPLETE.

how can i get the window handle for the tab window?

i've tried theEnumChildWindows/IsWindowVisible combo but it's not always reliable. it would seem IE7 has the handle but how to get it?

any ideas?

[465 byte] By [gchippie] at [2008-1-29]
# 1

From where are you trying to access the tab information? You shoudl be able to make use of accessibility interfaces to access the tabs.

Thanks
-Dave

DaveMassy at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 2

Does the following code help? This is a general-use replacement for the IWebBrowser2::get_HWND method that is supposed to work the same in IE6 and IE7.

IServiceProvider* psp;

HRESULT hr = pwb2->QueryInterface( IID_IServiceProvider, (void**)&psp );

if( SUCCEEDED(hr) && psp )

{

IOleWindow* pow;

psp->QueryService( SID_SShellBrowser, IID_IOleWindow, (void**)&pow );

if( SUCCEEDED(hr) && pow)

{

HWND hWnd = NULL;

hr = pow->GetWindow( &hWnd );

if( SUCCEEDED(hr) && hWnd )

{

//hWnd is the handle of TabWindowClass

}

pow->Release();

}

psp->Release();

}

JohnSudds at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 3

from inside my event handler:

STDMETHOD(Invoke)(DISPID, REFIID, LCID, WORD, DISPPARAMS*,

VARIANT*, EXCEPINFO*, UINT*);

and when the document completes loading,

i need to get the window handle of the tab.

thanks...

gchippie at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 4

thanks for your response.

yes, that code does work but i need the window handle to the Tab window (specifically
class of "Internet Explorer_Server").
as you point out, the code returns TabWindowClass.

i guess the question is: what is the relationship between the two classes?

thanks for your input...

gchippie at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 5

answering myself as well as to john...

Internet Explorer_Server class is the child of Shell DocObject View,
which itself is a child of TabWindowClass. So tracking down this is not bad,
but the my real problem is this....

when i receive DISPID_DOCUMENTCOMPLETE event as i open new tabs,
once in a while, the Internet Explorer_Server window does not exist yet.
i determine this via the EnumChildWindows.

it looks to me like a timing issue but within this event callback thread,
what can i do?

thanks for any thoughts...
g

gchippie at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 6

here's what i had to do:
using the TabWindowClass handle, find its child ShellDocObjectView
via EnumChildWindows. then, get its child via GetWindow.
for some reason, EnumChildWindows to locate the tab window class
Internet Explorer_Server is not completely reliable.
about 20% of the time, the tab window does not exist.

so i'm guessing it's a timing issue between IE7 thread creating the window and
its DocumentComplete callback into bho's routine.

gchippie at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 7

Hey gchippie >>

It seems like you know how to locate the active IE tab?
I just want to be able to do that and get the urllocation of it.

Can you help me?
If you are not up to writing a complete workin code it's okay, but maby some lines of code?

I am not used to this type of programming:(

thanks in advanced!

Qawi at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 8

per my previous comments,
i'm using john's code above to get the tab window handle,
find its child window via EnumChildWindows for the handle to
the docObjView, and finally get its child window which is the tab.

for what it's worth, here's my code snippet:
::EnumChildWindows(htabwnd, cTabWndEnumProc, reinterpret_cast<LPARAM>(&hsdovwnd));
if (hsdovwnd) {
hbwnd = ::GetWindow(hsdovwnd, GW_CHILD);
if (hbwnd != 0) {// but make sure the window is proper class
TCHAR wclass[MAX_PATH];
wclass[0] = 0;
::GetClassName(hbwnd, wclass, MAX_PATH-1);
if (_tcscmp(wclass, _T("Internet Explorer_Server")))
hbwnd = 0;
}
}

gchippie at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 9
I would like to find the tab id as well and was wondering if you could post your code and John's code (and any other code necessary to get this to work). Greatly appreciated!
JohnBoy456 at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...
# 10
Not a coder yet into this domain but I'm a programmer still.

1) What language are you using to create these BHOs?
2) Extending the code on this page is there a possibility of changing the color for each tab separately?

Regards

Varun21 at 2007-8-31 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Extension Development...