1、main函数启动http服务
QLocalHttpServer localHttpServer;
localHttpServer.setHttpServer("127.0.0.1",nHttpServerPort);
localHttpServer.startHttpServer("127.0.0.1",nHttpServerPort);
QWebWindowManage:strSessionId管理,兼容多个tab页面的打开
MainWindow:显示窗口
2、获取浏览器中页面的窗体ID
//获取本程序的窗体
HWND windId=(HWND)pWebWindow->winId();
qDebug()<<"windId:"<<windId;
//获取最上面的窗体---浏览器窗体ID
HWND topWindId=GetForegroundWindow();
qDebug()<<"topWindId:"<<topWindId;
//获取下一级的页面窗体---浏览器中页面的窗体ID
HWND childWindId=GetNextWindow(topWindId,GW_CHILD);
qDebug()<<"childWindId:"<<childWindId;
if(childWindId != 0){
HWND pParent=SetParent(windId,childWindId);
if(pParent!=NULL){
pWebWindow->setWebBrowserHwnd(topWindId,childWindId);
}else{
DWORD ErrorNo=GetLastError();
qDebug()<<"GetLastError ErrorNo:"<<ErrorNo;
}
qDebug()<<"pParent:"<<pParent;
}
3、设置为父窗体
void MainWindow::onHandleVideoFullScreen(bool bIsFullScreen)
{
if(pVideoFrame){
if(bIsFullScreen){
qDebug()<<"showFullScreen:"<<bIsFullScreen;
//设置为父窗体---全屏时桌面窗口为父窗体
SetParent((HWND)this->winId(),GetDesktopWindow());
this->showFullScreen();
}else{
qDebug()<<"showNormal:"<<bIsFullScreen;
//设置为父窗体---非全屏时浏览器中页面窗口为父窗体
SetParent((HWND)this->winId(),mWebBrowserDocumentHwnd);
this->showNormal();
}
}
}