IEAssociateThreadWithTab function

Associates a UI thread with a tab in Windows Internet Explorer.

Syntax

HRESULT IEAssociateThreadWithTab(
   DWORD dwTabThreadID,
   DWORD dwAssociatedThreadID
);

Parameters

  • dwTabThreadID
    The tab thread ID.

  • dwAssociatedThreadID
    The ID of the UI thread to associate.

Return value

Returns S_OK if successful, or E_FAIL if the thread could not be associated.

Remarks

Windows Internet Explorer suppresses dialog boxes and other UI elements if they are not associated with the current tab thread. This function provides a way for add-ons to associate a UI thread with the current tab.

In Internet Explorer, an add-on DLL is loaded once for each tab thread; therefore, calling GetCurrentThreadId in the main thread of the add-on is sufficient to return the current tab thread ID.

Examples

This example shows how to use LoadLibrary and GetProcAddress to load and call IEAssociateThreadWithTab.

typedef HRESULT (WINAPI * PFNIEASSOCIATETHREADWITHTAB)
    (__in DWORD dwTabThreadID, __in DWORD dwAssociatedThreadID);

HRESULT CMyActiveXControl::CreateThreadedBrowser()
{
    HRESULT hr = E_FAIL;

    DWORD dwThreadId = 0;
    HANDLE hThread = CreateThread(NULL, 0, BrowserThreadProc, (void*)this, 0, &dwThreadId);
    if (hThread != NULL)
    {
        HMODULE hModule = LoadLibrary(L"ieframe.dll");
        if (hModule != NULL)
        {
            PFNIEASSOCIATETHREADWITHTAB pfnIEAssociateThreadWithTab = 
                (PFNIEASSOCIATETHREADWITHTAB)GetProcAddress(hModule, "IEAssociateThreadWithTab");
            if (pfnIEAssociateThreadWithTab != NULL)
            {
                hr = pfnIEAssociateThreadWithTab(GetCurrentThreadId(), dwThreadId);
            }
        }
    }

    return hr;
} 

Requirements

Minimum supported client

Windows XP with SP2

Minimum supported server

Windows Server 2003

Header

N/A

DLL

Ieframe.dll

See also

IEDisassociateThreadWithTab