본문 바로가기
IT-개발,DB

[개발/MFC] 탭브라우저에서 ActiveX가 포함된 웹페이지 핸들 찾기

by SB리치퍼슨 2011. 8. 10.
// 탭브라우저에서 ActiveX가 포함된 웹페이지 핸들 찾기

BOOL CALLBACK EnumIEServer(HWND hwnd, LPARAM lParam)
{
    char szClassName[MAX_PATH];
    GetClassName(hwnd, szClassName, MAX_PATH-1);
    HWND *phWnd = (HWND *)lParam;

    if(strcmp(szClassName, "Internet Explorer_Server") == 0)
    {
        *phWnd = hwnd;
        return FALSE;
 }

 return TRUE;
}

HWND GetIEPage()
{
HWND hIEServer = NULL;
IServiceProvider* psp;
hr = m_pWeb->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 
  EnumChildWindows(hWnd, EnumIEServer, (LPARAM)&hIEServer);
   }
   pow->Release();  
 }
 psp->Release();                           
}
return hIEServer;
 }
반응형

댓글