LRESULT CALLBACK gameOfLife3D::MainWnd::WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) { #ifdef DEBUG_MAINWND LOG_ENTER(SEVERITY_LEVEL_DEBUG); LOG(SEVERITY_LEVEL_DEBUG) << util::WMessage(util::WMessageArgs(hWnd, message, wParam, lParam)); #endif LRESULT result = 0; if (message == WM_CREATE) { LPCREATESTRUCT pcs = (LPCREATESTRUCT) lParam; MainWnd *pMainWnd = (MainWnd*) pcs->lpCreateParams; SetWindowLongPtr(hWnd, GWLP_USERDATA, PtrToUlong(pMainWnd)); result = 1; } else { MainWnd *pMainWnd = reinterpret_cast<MainWnd*>( static_cast<LONG_PTR>(GetWindowLongPtr(hWnd, GWLP_USERDATA))); bool wasHandled = false; if (pMainWnd) { switch (message) { case WM_COMMAND: { // Accelerator switch (LOWORD(wParam)) { case ID_ACCELERATOR_FPS: pMainWnd->SetFPSEnable(!pMainWnd->IsFPSEnabled()); } } result = 0; wasHandled = true; break; case WM_SIZE: if (pMainWnd->m_canvasPanel.get() != nullptr && pMainWnd->m_canvasPanel->IsInitialized()) { pMainWnd->m_canvasPanel->ResizeByParentResized(); } break; case WM_NCCREATE: result = 1; wasHandled = true; break; case WM_ACTIVATE: if (WA_INACTIVE == LOWORD(wParam)) { // do nothing break; } // do SetFocus case WM_SETFOCUS: ::SetFocus(pMainWnd->m_canvasPanel->GetHWnd()); result = 1; wasHandled = true; break; case WM_RIBBON_RESIZED: if (pMainWnd->m_canvasPanel.get() != nullptr && !pMainWnd->m_canvasPanel->IsInitialized()) { pMainWnd->OnCreate(hWnd, message, wParam, lParam); } else if (pMainWnd->m_canvasPanel->IsInitialized()) { pMainWnd->m_canvasPanel->ResizeByRibbonResized(static_cast < UINT >(wParam)); } result = 0; wasHandled = true; break; case WM_DESTROY: PostQuitMessage(0); result = 1; wasHandled = true; break; } } if (!wasHandled) { result = DefWindowProc(hWnd, message, wParam, lParam); } } #ifdef DEBUG_MAINWND LOG_LEAVE(SEVERITY_LEVEL_DEBUG); #endif return result; }