UINT CMessageBox::Show(HWND hWnd, LPCTSTR lpMessage, LPCTSTR lpCaption, UINT uType, LPCTSTR sHelpPath) { CMessageBox box; if (!IsWindow(hWnd)) hWnd = NULL; if (sHelpPath) box.SetHelpPath(sHelpPath); return box.GoModal(CWnd::FromHandle(hWnd), lpCaption, lpMessage, box.FillBoxStandard(uType)); }
UINT CMessageBox::Show(HWND hWnd, UINT nMessage, UINT nCaption, UINT uType, UINT nHelpID) { CMessageBox box; CString sMessage; CString sCaption; sMessage.LoadString(nMessage); sCaption.LoadString(nCaption); if (!IsWindow(hWnd)) hWnd = NULL; box.SetHelpID(nHelpID); return box.GoModal(CWnd::FromHandle(hWnd), sCaption, sMessage, box.FillBoxStandard(uType)); }
UINT CMessageBox::ShowCheck(HWND hWnd, LPCTSTR lpMessage, LPCTSTR lpCaption, UINT uType, LPCTSTR lpRegistry, LPCTSTR lpCheckMessage) { //check the registry if we have to show the box or just return with the last used return value //this would be the case if the user pressed "do not show again". DWORD dwRetVal; HKEY hKey; CString path; #ifdef XMESSAGEBOX_APPREGPATH path = XMESSAGEBOX_APPREGPATH; #else path = "Software\\TortoiseGit\\"; path += AfxGetAppName(); #endif if (RegOpenKeyEx(HKEY_CURRENT_USER, path, 0, KEY_EXECUTE, &hKey)==ERROR_SUCCESS) { int size = sizeof(dwRetVal); DWORD type; if (RegQueryValueEx(hKey, lpRegistry, NULL, &type, (BYTE*) &dwRetVal,(LPDWORD) &size)==ERROR_SUCCESS) { ASSERT(type==REG_DWORD); RegCloseKey(hKey); return (UINT)dwRetVal; //return with the last saved value } else { RegCloseKey(hKey); } } CMessageBox box; box.m_bShowCheck = TRUE; box.m_sRegistryValue = lpRegistry; if (lpCheckMessage == NULL) { #ifndef IDS_MSGBOX_DONOTSHOWAGAIN box.m_sCheckbox = _T("do not show again"); #else CString m_i18l; m_i18l.LoadString(IDS_MSGBOX_DONOTSHOWAGAIN); box.m_sCheckbox = m_i18l; #endif } else box.m_sCheckbox = lpCheckMessage; if (!IsWindow(hWnd)) hWnd = NULL; return box.GoModal(CWnd::FromHandle(hWnd), lpCaption, lpMessage, box.FillBoxStandard(uType)); }