Introduction
I wrote the first online TV Toolbar in 1997 that plays TV Shows in Internet Explorer. There are a lot of cool projects I have seen posted on this site, and one, in particular, caught my interest, namely, "Adding a drop-down menu to an IE Toolbar button" by Igor Tolmachev.
I modified and enhanced the code for adding a button with a dropdown in Internet Explorer and added code to play video inside of Internet Explorer Tabs using Microsoft's DirectShow by getting the handle to the IE tab.
The new version of IEVideo in Visual Studio 2008 is called TV Button and can be found at IE Video in VS2008.
Requires DirectX to Compile
To compile the sample code, you must download and install DirectX and "Extras." The "Extras" download from Microsoft contains the DirectShow samples and you must compile the "BaseClasses" in DirectShow. Just put this project in the "Samples\C++" directory in the DirectShow Extras download to make it easier to set the correct pathway for "dshow.h" header file.
Getting the Handle to a Tab in Internet Explorer 7
The key to making this work was getting the handle to the tab in I.E. 7 and we can get the handle to the tab window in unmanaged C++ as follows:
BOOL bFound = FALSE;
IServiceProvider* pServiceProvider = NULL;
if (SUCCEEDED(m_pWebBrowser2->QueryInterface(IID_IServiceProvider,
(void**)&pServiceProvider)))
{
IOleWindow* pWindow = NULL;
if (SUCCEEDED(pServiceProvider->QueryService(SID_SShellBrowser,
IID_IOleWindow, (void**)&pWindow))) {
HWND hwndBrowser = NULL;
if (SUCCEEDED(pWindow->GetWindow(&hwndBrowser))) {
}
pWindow->Release();
}
pServiceProvider->Release();
}
if (bFound)
In either managed C# or unmanaged C++, once we have the handle to the tabbed IE browser window, we can play video.
Play Video in Parts of Web Pages by Getting a
Handle to an <APPLET> tag or Any Similar Tag
Many different types of HTML objects like "<APPLET>" tags have handles. This means that you can play video inside of parts of a web page by simply getting the handle to the HTML object like an <APPLET> tag. For example, you can add a web page with a tag like:
<APPLET class="videoapplet"> height="240" width="320"></APPLET>
Then just get the handle to this <APPLET> tag to play video inside of it using this button.
You can also create a non-rectangular region for the applet as well.
To do this, you need to get a handle to that object in the web page and the worst way to get a handle to any HTML object is to use the DOM and COM interfaces which are very slow and which fail occasionally. The fastest and most reliable way to get the handle to any HTML element such as an <applet> is to use EnumChildWindows to get the handles to all windows by their class attributes contained within a specified region of the WebBrowser control.
The COM interfaces do not give you a handle to the window holding the HTML object so even if you invoke any COM interface you still have to use an API function like EnumChildWindows to get the handles to the window, thus COM is a complete waste of time and gives you nothing. So I went directly to reading the window classes for a given point within a region of an HTML page.
If you have any questions about the toolbar, please feel free to contact me at:
Bill SerGio, The Infomercial King™
tvmogul1@yahoo.com