BOOL COXScreenGrabber::GrabClientWindow(CWnd* pWnd /* = NULL */) { CRect ClientRect(0, 0, 0, 0); if (!PrepareWindow(TRUE, ClientRect, pWnd)) return FALSE; return GrabRectangle(ClientRect); }
BOOL COXScreenGrabber::GrabFullWindow(CWnd* pWnd /* = NULL */) { CRect WndRect(0, 0, 0, 0); if (!PrepareWindow(FALSE, WndRect, pWnd)) return FALSE; return GrabRectangle(WndRect); }
void DXApp::Run() { MSG msg = { 0 }; BOOL bRet = 1; float dt = 0; PreInit(); InitGame(); LateInit(); while (msg.message != WM_QUIT) { if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } else { m_gameTimer->Tick(); if (!m_appPaused) { CalculateFrameStats(); dt += m_gameTimer->DeltaTime(); if (dt >= 1.f / TICKS_PER_SECOND) { OnTickUpdate(m_gameTimer->DeltaTime()); LateTickUpdate(m_gameTimer->DeltaTime()); dt = 0; tick++; } if (tick == TICKS_PER_SECOND) { std::wstringstream ss; ss << "DirectX title - FPS: "; ss << fps; BOOL b = SetWindowText(m_mainHandle, LPCWSTR(ss.str().c_str())); DWORD d = GetLastError(); fps = 0; tick = 0; } PrepareWindow(); RenderUpdate(); RenderWindow(); fps++; } else { Sleep(100); } } } }
// // Constructor // // Derived class handling window interactions. We did have the main renderer // object inheriting from CBaseControlWindow so that we didn't have to have // a separate class but that means there are two many classes derived from // CUnknown, so when in the final text out filter class you call something // like GetOwner it gets really confusing to know who is actually going to // be called. So in the end we made it a separate class for the window. We // have to specialise the base class to provide the PURE virtual method that // returns the class and window information (GetClassWindowStyles). We are // also interested in certain window messages like WM_PAINT and WM_NCHITTEST // CTextOutWindow::CTextOutWindow(TCHAR *pName, // Object string LPUNKNOWN pUnk, // COM ownership HRESULT *phr, // OLE code CCritSec *pLock, // Interface lock CTextOutFilter *pRenderer) : // Main filter CBaseControlWindow(pRenderer,pLock,pName,pUnk,phr), m_pRenderer(pRenderer) { PrepareWindow(); } // Constructor
// // Constructor // CVideoText::CVideoText(TCHAR *pName, // Object description LPUNKNOWN pUnk, // Normal COM ownership HRESULT *phr, // OLE failure code CCritSec *pInterfaceLock, // Main critical section CVideoRenderer *pRenderer) : // Delegates locking to CBaseControlVideo(pRenderer,pInterfaceLock,pName,pUnk,phr), CBaseControlWindow(pRenderer,pInterfaceLock,pName,pUnk,phr), m_pRenderer(pRenderer) { PrepareWindow(); InitWindowRegion(VideoString); } // (Constructor)
// // Switch System Class Window Proc. // LRESULT WINAPI SwitchWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL unicode ) { PWND pWnd; PALTTABINFO ati; pWnd = ValidateHwnd(hWnd); if (pWnd) { if (!pWnd->fnid) { NtUserSetWindowFNID(hWnd, FNID_SWITCH); } } switch (uMsg) { case WM_NCCREATE: if (!(ati = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ati)))) return 0; SetWindowLongPtrW( hWnd, 0, (LONG_PTR)ati ); return TRUE; case WM_SHOWWINDOW: if (wParam) { PrepareWindow(); ati = (PALTTABINFO)GetWindowLongPtrW(hWnd, 0); ati->cbSize = sizeof(ALTTABINFO); ati->cItems = nItems; ati->cColumns = nCols; ati->cRows = nRows; if (nCols) { ati->iColFocus = (selectedWindow - nShift) % nCols; ati->iRowFocus = (selectedWindow - nShift) / nCols; } else { ati->iColFocus = 0; ati->iRowFocus = 0; } ati->cxItem = CX_ITEM_SPACE; ati->cyItem = CY_ITEM_SPACE; ati->ptStart = ptStart; } return 0; case WM_MOUSEMOVE: ProcessMouseMessage(uMsg, lParam); return 0; case WM_ACTIVATE: if (wParam == WA_INACTIVE) { CompleteSwitch(FALSE); } return 0; case WM_PAINT: OnPaint(hWnd); return 0; case WM_DESTROY: isOpen = FALSE; ati = (PALTTABINFO)GetWindowLongPtrW(hWnd, 0); HeapFree( GetProcessHeap(), 0, ati ); SetWindowLongPtrW( hWnd, 0, 0 ); DestroyAppWindows(); NtUserSetWindowFNID(hWnd, FNID_DESTROY); return 0; } return DefWindowProcW(hWnd, uMsg, wParam, lParam); }