MSDN的列子 获得的是Internet Explorer_Server窗口 的父窗口的父窗口的句柄 不是我想要的。
IServiceProvider* pServiceProvider = NULL;
if (SUCCEEDED(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)))
{
// hwndBrowser is the handle of TabWindowClass
} pWindow->Release();
}
pServiceProvider->Release();
}
通过CDHtmlDialog成员变量m_pBrowserApp->get_HWND()结果失败。
到底该如何做呢?
IServiceProvider* pServiceProvider = NULL;
if (SUCCEEDED(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)))
{
// hwndBrowser is the handle of TabWindowClass
} pWindow->Release();
}
pServiceProvider->Release();
}
通过CDHtmlDialog成员变量m_pBrowserApp->get_HWND()结果失败。
到底该如何做呢?
解决方案 »
- VC制作的对话框会弹出容器,对话框左上角在屏幕左上角,请问该怎么解决?
- 请问各种熟悉CSDN论坛的程序员:增加自己在CSDN上的剩余可用分的方法有哪些
- 老报这个错误,帮我看看是怎么回事?在线等!!!!!!!!!!!!!!!!!!!!!!!!
- 通用工具条设计的问题
- GDI绘图问题
- 菜鸟的问题,,如何制作带有图片跟文字的按扭,谢谢!
- 如何探测到一个局域网内的另一台机子是否连接在网上?
- 绘制网格,像win2000任务管理器。
- 如何控制编辑框里不能输入数字和小数点之外的东东?
- 请问.pdg文件是什么文件,需要什么浏览器浏览
- 没有找到MFC80UD.DLL,因此这个应用程序未能启动。重新安装应用程序可能会修复此问题
- VS2010上不能用DevComponents.DotNetBar2第三方控件吗?
BOOL CALLBACK EnumChildProc( HWND hwnd,
LPARAM lParam
)
{
TCHAR buffer[128];
GetClassName(hwnd,buffer,sizeof(buffer)/sizeof(TCHAR));
if(0 == strcmp(buffer,_T("Internet Explorer_Server")))
{
g_pWebDlg->m_hWBCWnd = hwnd;
return FALSE;
}
return TRUE;
{
TCHAR lpBuf[128];
GetClassName(hwnd,lpBuf,sizeof(lpBuf)/sizeof(TCHAR));
if(_tcscmp(lpBuf,_T("Internet Explorer_Server")) == 0)
{
*((LONG*)lParam) = (LPARAM)hwnd;
return FALSE;
}
return TRUE;
}
IServiceProvider* pServiceProvider = NULL;
if (SUCCEEDED(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)))
{
LONG lParam = 0;
EnumChildWindows(hwndBrowser,EnumChildProc,(LPARAM)&lParam);
HWND hwndss = (HWND)lParam; // hwndss就是了
int a = 0;
a++;
// hwndBrowser is the handle of TabWindowClass
} pWindow->Release();
} pServiceProvider->Release();
}
直接在用CDHtmlDialog的句柄FindWindow就可以了
HWND m_ieHwnd = ::FindWindowEx(GetSafeHwnd(), 0, "Shell Embedding", NULL);
if (m_ieHwnd)
{
m_ieHwnd = ::FindWindowEx(m_ieHwnd, 0, "Shell DocObject View", NULL);
if (m_ieHwnd)
{
m_ieHwnd = ::FindWindowEx(m_ieHwnd, 0, "Internet Explorer_Server", NULL);
}else
m_ieHwnd = NULL;
}