STDMETHODIMP CPdnWnd::messageBox(BOOL modal, BSTR text, BSTR caption, DWORD type, DWORD* retval) { HasModalDialog(modal); *retval = ::MessageBoxW(modal ? m_hWnd : 0, text, caption, type); HasModalDialog(modal); return S_OK; }
STDMETHODIMP CPdnWnd::messageBox(BOOL modal, BSTR text, BSTR caption, DWORD type, DWORD* retval) { bool isWindowRTL = ::GetWindowLong(m_hWnd, GWL_EXSTYLE) & WS_EX_LAYOUTRTL; HasModalDialog(modal); *retval = ::MessageBoxW(modal ? m_hWnd : 0, text, caption, type | (isWindowRTL ? MB_RTLREADING : 0) ); HasModalDialog(false); return S_OK; }
//========================================================= // AlphaApp::OnSysCommand - Chapter X, page Y // // Handles the WM_SYSCOMMAND message // //========================================================= LRESULT AlphaApp::OnSysCommand(WPARAM wParam, LPARAM lParam) { switch (wParam) { case SC_MAXIMIZE : { // If windowed and ready... if ( m_bWindowedMode && IsRunning() ) { // Make maximize into FULLSCREEN toggle OnAltEnter(); } } return 0; case SC_CLOSE : { // The quit dialog confirmation would appear once for // every SC_CLOSE we get - which happens multiple times // if modal dialogs are up. This now uses the g_QuitNoPrompt // flag to only prompt when receiving a SC_CLOSE that isn't // generated by us (identified by g_QuitNoPrompt). // If closing, prompt to close if this isn't a forced quit if ( lParam != g_QuitNoPrompt ) { // ET - 05/21/01 - Bug #1916 - Begin // We were receiving multiple close dialogs // when closing again ALT-F4 while the close // confirmation dialog was up. // Eat if already servicing a close if ( m_bQuitRequested ) return true; // Wait for the application to be restored // before going any further with the new // screen. Flash until the person selects // that they want to restore the game, then // reinit the display if fullscreen. // The reinit is necessary otherwise the game // will switch to windowed mode. // Quit requested m_bQuitRequested = true; // Prompt TODO Fix pop up message //if ( MessageBox::Ask(QUESTION_QUIT_GAME) == IDNO ) //{ // // Bail - quit aborted // // // Reset quit requested flag // m_bQuitRequested = false; // // return true; //} } m_bQuitting = true; // Is there a game modal dialog up? if ( HasModalDialog() ) { // Close the modal // and keep posting close to the app //ForceModalExit(); TODO uncomment when the func is coded // Reissue the close to the app // Issue the new close after handling the current one, // but send in g_QuitNoPrompt to differentiate it from a // regular CLOSE issued by the system. PostMessage( GetHwnd(), WM_SYSCOMMAND, SC_CLOSE, g_QuitNoPrompt ); m_bQuitRequested = false; // Eat the close return true; } // Reset the quit after any other dialogs have popped up from this close m_bQuitRequested = false; } return 0; default: // return non-zero of we didn't process the SYSCOMMAND message return DefWindowProc(GetHwnd(), WM_SYSCOMMAND, wParam, lParam); } return 0; }
LRESULT CPdnWnd::WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if(uMsg == WM_FORWARDMSG) { return OnForwardMessage(hWnd, uMsg, wParam, lParam); } else if(uMsg == WM_CREATE) { m_hWnd = hWnd; return OnCreate(uMsg, wParam, lParam); } else if(uMsg == WM_CLOSE) { return OnClose(uMsg, wParam, lParam); } else if(uMsg == WM_DESTROY) { return OnDestroy(uMsg, wParam, lParam); } else if(uMsg == WM_JSINVOKE) { return OnJSInvoke(uMsg, wParam, lParam); } else if(uMsg == WM_GETMINMAXINFO) { return OnGetMinMaxInfo(uMsg, wParam, lParam); } else if(uMsg == WM_ACTIVATE) { return OnActivate(uMsg, wParam, lParam); } else if(uMsg == WM_SIZE) { return OnSize(uMsg, wParam, lParam); } else if(uMsg == WM_COMMAND) { return OnCommand(uMsg, wParam, lParam); } else if(uMsg == WM_ENDSESSION) { return OnEndSession(uMsg, wParam, lParam); } else if(uMsg == WM_NCDESTROY) { OnFinalMessage(m_hWnd, uMsg, wParam, lParam); return ::DefWindowProc(m_hWnd, uMsg, wParam, lParam); } else if(uMsg == m_TaskbarRestartMessage) { return OnTaskbarRestart(uMsg, wParam, lParam); } else if(uMsg == WM_COPYDATA) { return OnCopyData(uMsg, wParam, lParam); } else if(uMsg == WM_NOTIFYICON) { return OnNotifyIcon(uMsg, wParam, lParam); } else if(uMsg == WM_PARENTNOTIFY && wParam == WM_DESTROY) { if (::IsWindow(m_hWnd)) { ::DestroyWindow(m_hWnd); m_hWnd = NULL; } return 0L; } else if(uMsg == WM_SYSCOMMAND) { return OnSysCommand(uMsg, wParam, lParam); } else if(uMsg == 0x02B1 /*WM_WTSSESSION_CHANGE*/) { return OnWTSSessionChange(uMsg, wParam, lParam); } else if(uMsg == WM_ENTERMENULOOP) { HasModalDialog(true); return ::DefWindowProc(m_hWnd, uMsg, wParam, lParam); } else if(uMsg == WM_EXITMENULOOP) { HasModalDialog(false); return ::DefWindowProc(m_hWnd, uMsg, wParam, lParam); } else { return ::DefWindowProc(m_hWnd, uMsg, wParam, lParam); } }