Context::Context( HINSTANCE p_hInstance, const string& p_title, int p_width, int p_height ) { m_closeFlag=false; m_sizeDirty=false; m_hInstance = p_hInstance; m_title = p_title; m_origTitle= p_title; setToUpdateOnResize(true); // Register class WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC) WndProc; // Callback function wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = m_hInstance; wcex.hIcon = 0; wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = m_title.c_str(); wcex.hIconSm = 0; if( !RegisterClassEx(&wcex) ) { throw ContextException("Could not register Context class", __FILE__,__FUNCTION__,__LINE__); } // Create the window RECT rc = { 0, 0, p_width, p_height}; AdjustWindowRect( &rc, WS_OVERLAPPEDWINDOW, FALSE ); if(!(m_hWnd = CreateWindow( m_title.c_str(), m_title.c_str(), WS_OVERLAPPEDWINDOW, 0,0, rc.right - rc.left, rc.bottom - rc.top, NULL,NULL, m_hInstance, NULL))) { throw ContextException("Could not create window", __FILE__,__FUNCTION__,__LINE__); } ShowWindow( m_hWnd, true ); UpdateWindow(m_hWnd); ShowCursor(true); //ShowCursor(true); m_instance=this; }
void Context::start() { if (!isStart) { isStart = true; if (!timer.isSupportPerf()) throw ContextException("Perfomance counter isn't supported"); timer.start(); threadHandle = (HANDLE)_beginthreadex(0, 0, threadProcess, reinterpret_cast<void*>(this), 0, NULL); if (!threadHandle) throw ContextException("Cannot create thread"); } }