LRESULT __stdcall COverlappedWindow::MsgRouter(HWND handle, UINT uMsg, WPARAM wParam, LPARAM lParam) { COverlappedWindow *thisWindow = NULL; if (uMsg == WM_GETMINMAXINFO) { return ::DefWindowProc(handle, uMsg, wParam, lParam); } if (uMsg == WM_NCCREATE) { LPCREATESTRUCT createStruct = reinterpret_cast<LPCREATESTRUCT>(lParam); void *lpCreateParam = createStruct->lpCreateParams; thisWindow = reinterpret_cast<COverlappedWindow *>(lpCreateParam); ::SetWindowLongPtr(handle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(thisWindow)); thisWindow->storeHandle(handle); } else { thisWindow = reinterpret_cast<COverlappedWindow *>(::GetWindowLongPtr(handle, GWLP_USERDATA)); } return thisWindow->wndProc(uMsg, wParam, lParam); }
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR commandLine, int cmdShow) { if( !COverlappedWindow::RegisterClass() ) { return -1; } COverlappedWindow window; if( !window.Create() ) { return -1; } window.Show(cmdShow); HACCEL acceleratorHandle = ::LoadAccelerators(GetModuleHandle(0), MAKEINTRESOURCE(IDR_ACCELERATOR1)); MSG message; BOOL getMessageResult = 0; while( getMessageResult = ::GetMessage(&message, 0, 0, 0) ) { if( getMessageResult == -1 ) { return -1; } else { if( !TranslateAccelerator(window.Handle(), acceleratorHandle, &message) ) { ::TranslateMessage(&message); ::DispatchMessage(&message); } } } return 0; }
int _stdcall wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR commandLine, int nCmdShow ) { if ( !COverlappedWindow::RegisterClass(hInstance) ) { return 1; } COverlappedWindow myWin; if ( !myWin.Create(hInstance) ) { return 1; } myWin.Show(nCmdShow); HACCEL haccel = ::LoadAccelerators( hInstance, MAKEINTRESOURCE( IDR_ACCELERATOR1 ) ); MSG message; BOOL getMessageResult = 0; while( ( getMessageResult = ::GetMessage( &message, NULL, 0, 0 ) ) != 0 ) { if ( getMessageResult == -1 ) { return -1; } if( !::TranslateAccelerator( myWin.GetHandle(), haccel, &message ) ) { ::TranslateMessage( &message ); ::DispatchMessage( &message ); } } return message.wParam; }
LRESULT __stdcall COverlappedWindow::windowProc( HWND _handle, UINT message, WPARAM wParam, LPARAM lParam ) { RECT clientRect; COverlappedWindow* ptr; ptr = reinterpret_cast<COverlappedWindow*>( ::GetWindowLong( _handle, GWL_USERDATA ) ); switch ( message ) { case WM_NCCREATE: { COverlappedWindow* that = reinterpret_cast<COverlappedWindow*>( reinterpret_cast<LPCREATESTRUCT>( lParam )->lpCreateParams ); ::SetWindowLong(_handle, GWL_USERDATA, reinterpret_cast<LONG>( that ) ); ::DefWindowProc( _handle, message, wParam, lParam ); ::SetTimer( _handle, TIMER_ID, 0.01, NULL ); break; } case WM_TIMER: ptr->OnTimer(); break; case WM_DESTROY: ptr->OnDestroy(); break; case WM_PAINT: ptr->OnPaint(); break; default: return ::DefWindowProc( _handle, message, wParam, lParam ); } return ::DefWindowProc( _handle, message, wParam, lParam ); }
void CDialogWindow::ApplySettings(CSettings settings) { COverlappedWindow* parentWindow = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(parentHandle, GWLP_USERDATA)); drawer->SetFontSize(settings.font.lfHeight); drawer->SetOpacity(parentWindow->Handle(), settings.opacity); drawer->SetColor("Background", settings.backgroundColor, false, true); drawer->SetColor("NumbersUnsatisfied", settings.fontColorUnsat, false, false); drawer->SetColor("NumbersSatisfied", settings.fontColorSat, false, false); drawer->SetColor("BorderInactive", settings.lineColorGrid, true, false); drawer->SetColor("BorderActive", settings.lineColorCorr, true, false); drawer->SetColor("BorderWrong", settings.lineColorWrong, true, false); parentWindow->Repaint(); }
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR szCmdLine, int cmdShow) { const wchar_t className[] = L"myPrettyParentClass"; COverlappedWindow myWindow; myWindow.RegisterClass(hInstance, className); myWindow.Create(hInstance, className); myWindow.Show(cmdShow); return 0; }
LRESULT COverlappedWindow::windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_NCCREATE: { COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>((reinterpret_cast<CREATESTRUCT*>(lParam))->lpCreateParams); SetLastError(0); SetWindowLongPtr(handle, GWLP_USERDATA, (LONG)window); if( GetLastError() != 0 ) { return GetLastError(); } window->OnNCCreate(handle); return DefWindowProc(handle, message, wParam, lParam); } case WM_CREATE: { COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); window->OnCreate(); return DefWindowProc(handle, message, wParam, lParam); } case WM_DESTROY: { COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); window->OnDestroy(); return 0; } case WM_PAINT: { COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); window->OnPaint(); return 0; } case WM_SIZE: { COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); window->OnResize(); return 0; } default: return DefWindowProc(handle, message, wParam, lParam); } }
LRESULT __stdcall COverlappedWindow::windowProc( HWND handle, UINT message, WPARAM wParam, LPARAM lParam ) { COverlappedWindow* ptr = reinterpret_cast<COverlappedWindow*>( ::GetWindowLong( handle, GWL_USERDATA ) ); switch ( message ) { case WM_NCCREATE: { COverlappedWindow* that = reinterpret_cast<COverlappedWindow*>( reinterpret_cast<LPCREATESTRUCT>( lParam )->lpCreateParams ); ::SetWindowLong( handle, GWL_USERDATA, reinterpret_cast<LONG>( that ) ); //that->handle = handle; return ::DefWindowProc( handle, message, wParam, lParam ); } case WM_DESTROY: ptr->OnDestroy(); break; default: return ::DefWindowProc( handle, message, wParam, lParam ); } }
int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPWSTR commandLine, int cmdShow) { if (!COverlappedWindow::RegisterClass()) { return -1; } COverlappedWindow window; if (!window.Create()) { return -1; } window.Show(cmdShow); MSG message; BOOL getMessageResultCode = 0; while ((getMessageResultCode = ::GetMessage(&message, 0, 0, 0)) != 0) { if (getMessageResultCode == -1) { return -1; } ::TranslateMessage(&message); ::DispatchMessage(&message); } return 0; }
LRESULT __stdcall COverlappedWindow::windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) { if (message == WM_ERASEBKGND) { return true; } if (message == WM_NCCREATE) { COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(reinterpret_cast<CREATESTRUCT*>(lParam)->lpCreateParams); ::SetWindowLongPtr(handle, GWLP_USERDATA, reinterpret_cast<LONG>(window)); } else { COverlappedWindow* window = reinterpret_cast<COverlappedWindow*>(::GetWindowLongPtr(handle, GWLP_USERDATA)); switch (message) { case WM_CREATE: window->OnCreate(handle); break; case WM_PAINT: window->OnPaint(); break; case WM_COMMAND: window->OnCommand(wParam, lParam); break; case WM_LBUTTONDOWN: window->OnLButtonDown(wParam, lParam); break; case WM_CLOSE: if (!window->OnClose()) { return 0; } break; case WM_DESTROY: window->OnDestroy(); break; default: break; } } return DefWindowProc(handle, message, wParam, lParam); }
LRESULT COverlappedWindow::windowProc(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) { switch( message ) { case WM_NCCREATE: { CREATESTRUCT* pCreate = reinterpret_cast<CREATESTRUCT*>(lParam); COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(pCreate->lpCreateParams); SetWindowLongPtr(handle, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(windowPtr)); windowPtr->OnNCCreate(handle); return true; } case WM_CREATE: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->OnCreate(); break; } case WM_SIZE: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->OnSize(); break; } case WM_CTLCOLOREDIT: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); HDC hdc = reinterpret_cast<HDC>(wParam); return windowPtr->OnControlColorEdit(hdc); } case WM_COMMAND: { if( HIWORD(wParam) == EN_CHANGE ) { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->OnTextChange(); break; } switch( LOWORD(wParam) ) { case ID_FILE_SAVE: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->saveFile(); break; } case ID_FILE_EXIT: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->OnClose(); break; } case ID_VIEW_SETTINGS: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->showSettings(); break; } case ID_KILL: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->OnDestroy(); break; } } break; } case WM_CLOSE: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->OnClose(); break; } case WM_DESTROY: { COverlappedWindow* windowPtr = reinterpret_cast<COverlappedWindow*>(GetWindowLongPtr(handle, GWLP_USERDATA)); windowPtr->OnDestroy(); break; } default: return DefWindowProc(handle, message, wParam, lParam); } return false; }