bool FBTestMathPlugin::draw( FB::RefreshEvent *evt, FB::PluginWindow* win ) { #if FB_WIN FB::Rect pos = win->getWindowPosition(); HDC hDC; FB::PluginWindowlessWin *wndLess = dynamic_cast<FB::PluginWindowlessWin*>(win); FB::PluginWindowWin *wnd = dynamic_cast<FB::PluginWindowWin*>(win); PAINTSTRUCT ps; if (wndLess) { hDC = wndLess->getHDC(); } else if (wnd) { hDC = BeginPaint(wnd->getHWND(), &ps); pos.right -= pos.left; pos.left = 0; pos.bottom -= pos.top; pos.top = 0; } ::SetTextAlign(hDC, TA_CENTER|TA_BASELINE); LPCTSTR pszText = _T("FireBreath Simple Plugin!"); ::TextOut(hDC, pos.left + (pos.right - pos.left) / 2, pos.top + (pos.bottom - pos.top) / 2, pszText, lstrlen(pszText)); if (wnd) { // Release the device context EndPaint(wnd->getHWND(), &ps); } #endif return true; }
bool PluginPlayer::onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow *win) { m_window = win; m_player->setWindow(win); FB::PluginWindowWin *wnd = dynamic_cast<FB::PluginWindowWin*>(win); m_hWnd=wnd->getHWND(); /*width=m_params["width"].convert_cast<int>(); height=m_params["height"].convert_cast<int>();*/ /*std::string allowFrame= m_params["allowframe"].convert_cast<std::string>(); if(allowFrame=="true") isAllowFrame=true; else isAllowFrame=false;*/ /*std::ostringstream oStr; oStr << "width:" << width<< ",height: " << height<<""<<endl; this->m_host->htmlLog(oStr.str());*/ /******************************设置窗口背景颜色*****************************/ HBRUSH brush; brush=CreateSolidBrush(RGB(125,125,125)); SetClassLong(m_hWnd,GCL_HBRBACKGROUND,(long)brush); /******************************设置窗口背景颜色*****************************/ return false; }
bool axWrapper::CreateAxWindow() { try { /* Now that we have the plugin window, create the ActiveX container window as a child of the plugin, then create the ActiveX control as a child of the container. */ FB::PluginWindowWin* pwnd = static_cast<FB::PluginWindowWin*>(GetWindow()); if(pwnd != NULL) { HWND hWnd = pwnd->getHWND(); if(hWnd) { // Create the ActiveX control container RECT rc; ::GetClientRect(hWnd, &rc); m_axwin.Create(hWnd, &rc, 0, WS_VISIBLE|WS_CHILD); // Create an instance of the ActiveX control in the container. If the ActiveX // control requires a license key, change CreateControlEx to CreateControlLicEx // and add one more parameter - CComBSTR(AXCTLLICKEY) - to the argument list. CComPtr<IUnknown> spControl; HRESULT hr = m_axwin.CreateControlEx(AXCTLPROGID, NULL, NULL, &spControl, GUID_NULL, NULL); if(SUCCEEDED(hr) && (spControl != NULL)) { // Get the control's default interface spControl.QueryInterface(&m_spaxctl); if(m_spaxctl) { // Connect the event sink hr = m_axwin.DispEventAdvise((IUnknown*)m_spaxctl); // Get the initialization parameters std::string caption; int theme = 0; try { caption = m_params["caption"].convert_cast<std::string>(); set_Caption(caption); } catch(...) {} // ignore missing param try { theme = m_params["theme"].convert_cast<long>(); set_Theme(theme); } catch(...) {} // ignore missing param return true; } } } } } catch(...) { //TODO: should we throw a FB exception here? } return false; }
bool osgWeb::onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow *win) { FB::PluginWindowWin* window = reinterpret_cast<FB::PluginWindowWin*>(win); if ( window ) { osg::ref_ptr<osg::Referenced> windata = new osgViewer::GraphicsWindowWin32::WindowData( window->getHWND() ); osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits; traits->x = 0; traits->y = 0; traits->width = 800; traits->height = 600; traits->windowDecoration = false; traits->doubleBuffer = true; traits->inheritedWindowData = windata; osg::ref_ptr<osg::GraphicsContext> gc = osg::GraphicsContext::createGraphicsContext( traits.get() ); osg::ref_ptr<osg::Camera> camera = new osg::Camera; camera->setGraphicsContext( gc ); camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) ); camera->setClearMask( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT ); camera->setClearColor( osg::Vec4f(0.2f, 0.2f, 0.6f, 1.0f) ); camera->setProjectionMatrixAsPerspective( 30.0f, (double)traits->width/(double)traits->height, 1.0, 1000.0 ); osg::ref_ptr<osg::Group> root = new osg::Group; root->addChild( osgDB::readNodeFile("cessna.osg") ); _commandHandler = new CommandHandler; _viewer.addEventHandler( _commandHandler.get() ); _viewer.setCamera( camera.get() ); _viewer.setSceneData( root.get() ); _viewer.setKeyEventSetsDone( 0 ); _viewer.setCameraManipulator( new osgGA::TrackballManipulator ); _thread = new RenderingThread; _thread->viewerPtr = &_viewer; _thread->start(); } return false; }
void MediaPlayer::setWindow(FB::PluginWindow* pluginWindow) { HRESULT hr; HWND hwnd = 0; if(pluginWindow) { FB::PluginWindowWin* wnd = reinterpret_cast<FB::PluginWindowWin*>(pluginWindow); hwnd = wnd->getHWND(); } if(m_context->hwnd) { hr = m_context->spVideoWindow->put_Owner((OAHWND)hwnd); if(FAILED(hr)) { m_context->error = vfwErrorString("IVideoWindow::put_Owner() failed", hr); } } m_context->hwnd = hwnd; }
bool OSGQtBrowser::onWindowAttached(FB::AttachedEvent *evt, FB::PluginWindow * win) { //This process should wait until FB::PluginWindowWin* window = reinterpret_cast<FB::PluginWindowWin*>(win); if ( window ) { HWND hWnd= window->getHWND(); QString strArguments = QString::number((unsigned long)hWnd); m_pProcess = new QProcess(0); QString strFPExeEditor = "C:/Projekti/VRShop/Dev/CorePlatform/Build/ShopScene/Test_libShopEditor/Debug/Test_libShopEditor.exe"; QString strFPExeClient = "C:/Projekti/VRShop/Dev/CorePlatform/Build/ShopScene/Test_libShoppingPlace/Debug/Test_libShoppingPlace.exe"; QString strFPExeWebsite = "C:/Projekti/VRShop/Dev/CorePlatform/Build/EmbeddedWidget/Test_libEmbeddedWidget/Debug/Test_libEmbeddedWidget.exe"; m_pProcess->start(strFPExeWebsite, QStringList() << strArguments); return true; } // The window is attached; act appropriately return false; }
void PluginPlayer::PlayerTipsPro(char* tips) { LOG4CPLUS_WARN(m_rtspClient.pTestLogger,"PlayerTipsPro1"); HDC hDC; FB::PluginWindowWin *wnd = dynamic_cast<FB::PluginWindowWin*>(m_window); HWND hWnd=wnd->getHWND(); hDC=GetDC(hWnd); //int i=1; // //while (true) //{ // HDC hMemDC = CreateCompatibleDC(hDC); // // CImage img; // i++; // if(i>13) // i=i%13; // char ssss[200]={0}; // //string ssss="c\:\\PlayerPlugin\\progress\\1.png"; // sprintf(ssss,"c\:\\PlayerPlugin\\progress\\%d.png",i); // std::wstring wstr; // StringToWString(ssss,wstr); // LPCTSTR pszText1 =wstr.c_str(); // //char str[]="c\:\\PlayerPlugin\\progress\\1.png"; // //img.Load(L"c\:\\PlayerPlugin\\progress\\1.png"); // //LPCTSTR lps=(LPCTSTR)(LPTSTR)str; // img.Load(pszText1); // int wid=1000; // int hei=800; // if(img){ // wid = img.GetWidth(); // hei = img.GetHeight(); // } // hDC=GetDC(hWnd); // int height=wnd->getWindowHeight(); // int width=wnd->getWindowWidth(); // wnd->getWindowPosition(); // /*HBITMAP hBmp = img.Detach(); // HBITMAP hBmpOld = (HBITMAP)::SelectObject(hMemDC, hBmp); // SetStretchBltMode(hDC,STRETCH_HALFTONE);*/ // ////StretchBlt(hDC,(width-100)/2, (height-100)/2, 100, 100, hMemDC,0,0,wid,hei,SRCCOPY);//缩放 // //TransparentBlt(hDC, (width-100)/2, (height-100)/2, 32, 32, hMemDC, 0, 0, 32, 32, RGB(0xff,0xff,0xff)); // ////hBmpOld.SelectObject(hBmpOld); // //SelectObject(hMemDC, hBmpOld); // //DeleteObject(hBmpOld); // //DeleteObject(hBmp); // // // //DeleteObject(hMemDC); // //ReleaseDC(hWnd,hDC); // Sleep(100); //} HPEN m_hPenGreen=::CreatePen(PS_SOLID, 2, RGB(128, 128, 128)); HGDIOBJ hOldPen = SelectObject(hDC, (HGDIOBJ)m_hPenGreen); HGDIOBJ hOldBrush = SelectObject(hDC, GetStockObject(GRAY_BRUSH)); Rectangle(hDC, 0, 0, 20000, 20000); SelectObject(hDC, hOldBrush); SelectObject(hDC, hOldPen); DeleteObject(m_hPenGreen); std::wstring wstr; StringToWString(tips,wstr); LPCTSTR pszText1 =wstr.c_str(); SetBkMode(hDC, TRANSPARENT); ::SetTextColor(hDC, RGB(0, 0, 255)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ReleaseDC(hWnd,hDC); LOG4CPLUS_WARN(m_rtspClient.pTestLogger,"PlayerTipsPro2"); }
bool PluginPlayer::draw(FB::RefreshEvent *evt, FB::PluginWindow* win ) { //HDC hDC; //FB::PluginWindowWin *wnd = dynamic_cast<FB::PluginWindowWin*>(win); //HWND hWnd=wnd->getHWND(); //hDC=GetDC(hWnd); ///*PAINTSTRUCT ps; //hDC = BeginPaint(hWnd, &ps); */ //int nOldMode = SetBkMode(hDC, TRANSPARENT); //HPEN m_hPenGreen=::CreatePen(PS_SOLID, 2, RGB(0, 128, 128)); //HGDIOBJ hOldPen = SelectObject(hDC, (HGDIOBJ)m_hPenGreen); //HGDIOBJ hOldBrush = SelectObject(hDC, GetStockObject(GRAY_BRUSH)); ////**********灰色背景************* ////Rectangle(hDC, 0, 0, 20000, 20000); ///*SelectObject(hDC, hOldBrush); //SelectObject(hDC, hOldPen); //SetBkMode(hDC, nOldMode); */ //DeleteObject(m_hPenGreen); // // ////********************************************************显示在左下角的文字 ////hDC=GetDC(hWnd); //std::wstring wstr; //StringToWString(deviceStatus,wstr); //LPCTSTR pszText =wstr.c_str(); //SetBkMode(hDC, TRANSPARENT); //::SetTextAlign(hDC, TA_LEFT|TA_BOTTOM); //::SetTextColor(hDC, RGB(0, 0, 0)); //::TextOut(hDC,4, height-4, pszText, lstrlen(pszText)); //::TextOut(hDC,4, height-4, pszText, lstrlen(pszText)); //::TextOut(hDC,4, height-4, pszText, lstrlen(pszText)); //::TextOut(hDC,4, height-4, pszText, lstrlen(pszText)); ////********************************************************显示在左下角的文字 //********************************************************显示在左上角的文字 if(m_rtspClient.m_xt_connectSuccess!=2) { /*std::ostringstream oStr; oStr << "draw() is invoking!"<<endl; this->m_host->htmlLog(oStr.str());*/ HDC hDC; FB::PluginWindowWin *wnd = dynamic_cast<FB::PluginWindowWin*>(win); HWND hWnd=wnd->getHWND(); hDC=GetDC(hWnd); HPEN m_hPenGreen=::CreatePen(PS_SOLID, 2, RGB(128, 128, 128)); HGDIOBJ hOldPen = SelectObject(hDC, (HGDIOBJ)m_hPenGreen); HGDIOBJ hOldBrush = SelectObject(hDC, GetStockObject(GRAY_BRUSH)); Rectangle(hDC, 0, 0, 20000, 20000); SelectObject(hDC, hOldBrush); SelectObject(hDC, hOldPen); DeleteObject(m_hPenGreen); std::wstring wstr; StringToWString(playerTips,wstr); LPCTSTR pszText1 =wstr.c_str(); SetBkMode(hDC, TRANSPARENT); ::SetTextColor(hDC, RGB(0, 0, 255)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); /*::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); ::TextOut(hDC,8, 20, pszText1, lstrlen(pszText1)); */ ReleaseDC(hWnd,hDC); } //********************************************************显示在左上角的文字 ////CImage img; ////img.Load(L"D\:\\1.png"); ////int wid=1000; ////int hei=800; ////if(img){ //// wid = img.GetWidth(); //// hei = img.GetHeight(); ////} ////hDC=GetDC(hWnd); ////int height=win->getWindowHeight(); ////int width=win->getWindowWidth(); ////win->getWindowPosition(); ////HBITMAP hBmp = img.Detach(); ////HDC hMemDC = CreateCompatibleDC(hDC); ////HBITMAP hBmpOld = (HBITMAP)::SelectObject(hMemDC, hBmp); //// ////SetStretchBltMode(hDC,STRETCH_HALFTONE); ////StretchBlt(hDC,(width-100)/2, (height-100)/2, 100, 100, hMemDC,0,0,wid,hei,SRCCOPY);//缩放 ////SelectObject(hMemDC, hBmpOld); ////DeleteObject(hBmp); ////DeleteObject(hMemDC); ////ReleaseDC(hWnd,hDC); // return true; }
void VRShopPlugin::runApplicationThread() { string strLocation = m_host->getDOMWindow()->getLocation(); string strOperatingSystem = getOS(); string strBrowser = getBrowser(); ofstream out; string strLog = AppData::getFPathLog() + "errors.txt"; out.open(strLog,ios::app); out << "strLocation: " << strLocation << "; OS: " << strOperatingSystem << "; Browser: " << strBrowser << "; " << endl; //If exists, skip installer operation and run the application string strInstallDir = AppData::getFPathVRShop() + "VRShop_Virtual"; bool bClientPlatformExist = AppData::checkIfExists(strInstallDir + "\\VRShop\\VRShop.exe"); if (bClientPlatformExist == false) { //Struct for setting Installer download param values Download::DownloadParams dP; string strWebServer = AppData::getFPathServer(); string strInstaller = "VRShop.exe"; dP.m_strURL = strWebServer+"/"+strInstaller; //GOOGLE AS WEB SERVER // string strWebServer = "https://0c446f69db3816158c2da15fa6f0faceb2a6fff1-www.googledrive.com/host/0B2PTBoEUslueYzRHT3ZyZUxMUG8/"; // dP.m_strURL = strWebServer; //GOOGLE AS WEB SERVER //Installer download location dP.m_strDestinationFolder = AppData::getFPathVRShop(); dP.m_bReload = false; try { Download::download(dP); } catch(DLExc exc) { string strError = exc.getError(); out << "Download installer: " << strError << endl; } int nRes = EXIT_SUCCESS; if (nRes != 0) { out << "Downloading failed" << endl; exit(-1); } string strInstallerFile = AppData::getFPathVRShop() + "VRShop.exe"; string strInstallDirSystem = replaceAll(strInstallDir,"/","\\"); system((strInstallerFile + " -Server=" + strWebServer + " -InstallDir=" + strInstallDirSystem).c_str()); if (remove(strInstallerFile.c_str()) != 0) out << "Error deleting file: " + strInstallerFile << endl; else out << "Successfully deleted file: " + strInstallerFile << endl; } FB::PluginWindow * pWin = GetWindow(); FB::PluginWindowWin * pWindow = reinterpret_cast<FB::PluginWindowWin*>(pWin); if (pWindow) { HWND hWnd = pWindow->getHWND(); //Create pipe server string strPipeName = "\\\\.\\pipe\\VRShopPluginPipe"; m_pPipe->initializeAndRunServer(strPipeName); // string strArguments = tostr(hWnd) + " 1 " + strPipeName; string strArguments = "127.0.0.1 10000 " + tostr(hWnd) + " " + strPipeName; //Create process ghJob = CreateJobObject( NULL, NULL); if( ghJob == NULL) { out << "Could not create job object" << endl; } else { JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 }; // Configure all child processes associated with the job to terminate when the jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; if( 0 == SetInformationJobObject( ghJob, JobObjectExtendedLimitInformation, &jeli, sizeof(jeli))) { out << "Could not SetInformationJobObject" << endl; } } m_pProcess->newProcess(replaceAll(strInstallDir,"/","\\") + "\\VRShop\\VRShop.exe", strArguments); } out.close(); }
unsigned int ambient::grabFrame(unsigned int webBrowser, unsigned int scwidth, unsigned int scheight, unsigned int width, unsigned int height) { FB::PluginWindow *plgwin = this->GetWindow(); FB::PluginWindowWin *plgwindows = (FB::PluginWindowWin *)plgwin; HWND parent=NULL,child=NULL; WINDOWINFO inf; inf.cbSize = sizeof(WINDOWINFO); flashPlugin = NULL; if(webBrowser != AUTO_FETCH) { if(webBrowser == MOZILLA_FIREFOX) { parent = plgwindows->getBrowserHWND(); // <-- GeckoPluginWindow parent = ::GetParent(parent); // <--- MozillaWindowClass (intermediate window) parent = ::GetParent(parent); // <--- MozillaWindowClass (main window) child = ::GetWindow(parent,GW_CHILD); // <--- The first MozillaWindowClass GetWindowInfo(child, &inf); while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); GetWindowInfo(child,&inf); }; if(child == NULL) return 3; // no such window child = ::GetWindow(child,GW_CHILD); flashPlugin = child; }else if(webBrowser == OPERA) { parent = plgwindows->getBrowserHWND(); //<--- OperaWindowClass //parent = GetParent(parent); child = ::GetWindow(parent,GW_CHILD); // <--- The first aPluginWindowClass GetWindowInfo(child, &inf); while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); ::GetWindowInfo(child,&inf); }; if(child == NULL) return 3; // no such window flashPlugin = child; }else if(webBrowser == MICROSOFT_IE) { parent = ::GetParent(plgwindows->getHWND()); child = ::GetWindow(parent,GW_CHILD); ::GetWindowInfo(child,&inf); while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); ::GetWindowInfo(child,&inf); }; if(child == NULL) return 3; // no such window flashPlugin = child; }else if(webBrowser == GOOGLE_CHROME) { parent = plgwindows->getBrowserHWND(); // <-- NativeWindowClass parent = ::GetParent(parent); // <-- WrapperNativeWindowClass parent = ::GetParent(parent); // <-- Chrome_RenderWidgetHost child = ::GetWindow(parent,GW_CHILD); // <-- The first NativeWindowClass(Plugin) of this page GetWindowInfo(child,&inf); // try to find the window with the given resolution while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); GetWindowInfo(child,&inf); }; if(child == NULL) return 3; // no such window //child = GetWindow(child,GW_CHILD); flashPlugin = child; // we have our HWND }else if(webBrowser == SAFARI) { unsigned int winOrder; parent = plgwindows->getBrowserHWND(); // because of the content script the plugin is always the last window so just step backwards and grep the flash plugin // TODO: if we are not the last one if(::GetNextWindow(parent,GW_HWNDPREV) == NULL) winOrder = GW_HWNDNEXT; else { // step back while (::GetNextWindow(parent,GW_HWNDPREV) != NULL) parent = ::GetNextWindow(parent,GW_HWNDPREV); winOrder = GW_HWNDNEXT; } while(parent != NULL) { // we have to get the child of every window child = ::GetWindow(parent,GW_CHILD); if(child != NULL) { GetWindowInfo(child,&inf); if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; } parent = ::GetNextWindow(parent,winOrder); } if(parent == NULL || child == NULL) return 3; flashPlugin = child; }else{ return 2; //not supported } }else{ // try to fetch the window automatically ... test each browser strategy // if the browser hwnd is NULL, then we are in the internet explorer ... if(plgwindows->getBrowserHWND() == NULL) { parent = GetParent(plgwindows->getHWND()); child = ::GetWindow(parent,GW_CHILD); GetWindowInfo(child,&inf); while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); GetWindowInfo(child,&inf); }; if(child != NULL) flashPlugin = child; } if(child == NULL) { // mozilla parent = plgwindows->getBrowserHWND(); // <-- GeckoPluginWindow parent = GetParent(parent); // <--- MozillaWindowClass (intermediate window) parent = GetParent(parent); // <--- MozillaWindowClass (main window) child = ::GetWindow(parent,GW_CHILD); // <--- The first MozillaWindowClass GetWindowInfo(child, &inf); while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); ::GetWindowInfo(child,&inf); }; if(child != NULL) { child = ::GetWindow(child,GW_CHILD); flashPlugin = child; } } if(child == NULL) // no such window, next strategy { parent = plgwindows->getBrowserHWND(); //<--- OperaWindowClass //parent = GetParent(parent); child = ::GetWindow(parent,GW_CHILD); // <--- The first aPluginWindowClass GetWindowInfo(child, &inf); while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); GetWindowInfo(child,&inf); }; if(child != NULL) flashPlugin = child; } if(child == NULL) // and again { parent = plgwindows->getBrowserHWND(); // <-- NativeWindowClass parent = GetParent(parent); // <-- WrapperNativeWindowClass parent = GetParent(parent); // <-- Chrome_RenderWidgetHost child = ::GetWindow(parent,GW_CHILD); // <-- The first NativeWindowClass(Plugin) of this page GetWindowInfo(child,&inf); // try to find the window with the given resolution while(child != NULL) { if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; child = ::GetNextWindow(child,GW_HWNDNEXT); GetWindowInfo(child,&inf); }; if(child != NULL) flashPlugin = child; // no such window //child = GetWindow(child,GW_CHILD); // we have our HWND } if(child == NULL) { unsigned int winOrder; parent = plgwindows->getBrowserHWND(); // because of the content script the plugin is always the last window so just step backwards and grep the flash plugin // TODO: if we are not the last one if(::GetNextWindow(parent,GW_HWNDPREV) == NULL) winOrder = GW_HWNDNEXT; else { // setp back while (::GetNextWindow(parent,GW_HWNDPREV) != NULL) parent = ::GetNextWindow(parent,GW_HWNDPREV); winOrder = GW_HWNDNEXT; } while(parent != NULL) { // we have to get the child of every window child = ::GetWindow(parent,GW_CHILD); if(child != NULL) { GetWindowInfo(child,&inf); if((inf.rcClient.right - inf.rcClient.left) == width && (inf.rcClient.bottom - inf.rcClient.top)==height) break; } parent = ::GetNextWindow(parent,winOrder); } if(parent != NULL && child != NULL) flashPlugin = child; } if(flashPlugin == NULL) return 3; //hmm... } GetWindowRect(flashPlugin,&winrect); // we may have the window handle but, since we are calling this on a timer it may happen that we enter this section twice // prevent this behavior with a mutex if(WaitForSingleObject(this->calcMutex,1) == WAIT_TIMEOUT) return 4; // grab a frame from the flash plugin embedded in the active page HDC flashHDC = GetWindowDC(flashPlugin); HDC Memory = CreateCompatibleDC(flashHDC); HBITMAP bmMemory = CreateCompatibleBitmap(flashHDC,winrect.right-winrect.left,winrect.bottom-winrect.top); HBITMAP Old = (HBITMAP) SelectObject(Memory, bmMemory); //BitBlt(Memory,0,30,winrect.right-winrect.left,winrect.bottom-winrect.top,flashHDC,0,0,SRCCOPY); // mirror the image vertical and scale it StretchBlt(Memory,0,0,scwidth,scheight,flashHDC,0,0,winrect.right-winrect.left,winrect.bottom-winrect.top,SRCCOPY); BITMAPINFO Info; ZeroMemory(&Info, sizeof(BITMAPINFO)); Info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); Info.bmiHeader.biWidth = scwidth; Info.bmiHeader.biHeight = -scheight; Info.bmiHeader.biBitCount = 32; Info.bmiHeader.biCompression = BI_RGB; Info.bmiHeader.biPlanes = 1; GetDIBits(Memory,bmMemory,0,scheight,NULL,&Info,DIB_RGB_COLORS); // now copy the image to our buffer // NOTE: it's a BGR frame ... if(Info.bmiHeader.biSizeImage == 0) { SelectObject(Memory, Old); ReleaseDC(flashPlugin,Memory); ReleaseDC(flashPlugin,flashHDC); DeleteObject(bmMemory); DeleteDC(Memory); ReleaseMutex(this->calcMutex); return 4; } unsigned char *data = (unsigned char *)malloc(Info.bmiHeader.biSizeImage); ZeroMemory(data,Info.bmiHeader.biSizeImage); GetDIBits(Memory,bmMemory,0,scheight,data,&Info,DIB_RGB_COLORS); SelectObject(Memory, Old); ReleaseDC(flashPlugin,Memory); ReleaseDC(flashPlugin,flashHDC); DeleteDC(Memory); DeleteObject(bmMemory); ambientLib->lightFromPicture(data,IMAGE_FORMAT_BGRA); free(data); ReleaseMutex(this->calcMutex); return 0; }