4 #include "VersionInfo.h"
9 // Get user language description of error, if available
10 String GetSysError(int nerr /* =-1 */)
13 nerr = GetLastError();
17 FORMAT_MESSAGE_ALLOCATE_BUFFER |
18 FORMAT_MESSAGE_FROM_SYSTEM |
19 FORMAT_MESSAGE_IGNORE_INSERTS,
22 0, // Default language
28 str = (LPCTSTR)lpMsgBuf;
30 LocalFree( lpMsgBuf );
36 * @brief Get Options Manager.
37 * @return Pointer to OptionsMgr.
39 COptionsMgr * GetOptionsMgr()
41 CMergeApp *pApp = static_cast<CMergeApp *>(AfxGetApp());
42 return pApp->GetMergeOptionsMgr();
45 // Send message to log and debug window
46 void LogErrorString(const String& sz)
48 if (sz.empty()) return;
49 CString now = COleDateTime::GetCurrentTime().Format();
50 TRACE(_T("%s: %s\n"), (LPCTSTR)now, sz.c_str());
53 // Send message to log and debug window
54 void LogErrorStringUTF8(const std::string& sz)
56 if (sz.empty()) return;
57 String str = ucr::toTString(sz);
58 CString now = COleDateTime::GetCurrentTime().Format();
59 TRACE(_T("%s: %s\n"), (LPCTSTR)now, str.c_str());
63 * @brief Load string resource and return as CString.
64 * @param [in] id Resource string ID.
65 * @return Resource string as CString.
67 String LoadResString(unsigned id)
69 return theApp.LoadString(id);
72 String tr(const std::string &str)
74 String translated_str;
75 theApp.TranslateString(str, translated_str);
76 return translated_str;
79 String tr(const char *msgctxt, const std::string &str)
81 String translated_str;
83 theApp.TranslateString("\x01\"" + std::string(msgctxt) + "\"" + str, translated_str);
85 theApp.TranslateString(str, translated_str);
86 return translated_str;
89 void AppErrorMessageBox(const String& msg)
91 AppMsgBox::error(msg);
99 int convert_to_winflags(int flags)
103 if ((flags & (YES | NO | CANCEL)) == (YES | NO | CANCEL)) newflags |= MB_YESNOCANCEL;
104 else if ((flags & (YES | NO)) == (YES | NO)) newflags |= MB_YESNO;
105 else if ((flags & (OK | CANCEL)) == (OK | CANCEL)) newflags |= MB_OKCANCEL;
106 else if ((flags & OK) == OK) newflags |= MB_OK;
108 if (flags & YES_TO_ALL) newflags |= MB_YES_TO_ALL;
109 if (flags & DONT_DISPLAY_AGAIN) newflags |= MB_DONT_DISPLAY_AGAIN;
114 int convert_resp(int resp)
134 int error(const String& msg, int type)
136 return detail::convert_resp(AfxMessageBox(msg.c_str(), detail::convert_to_winflags(type) | MB_ICONSTOP));
139 int warning(const String& msg, int type)
141 return detail::convert_resp(AfxMessageBox(msg.c_str(), detail::convert_to_winflags(type) | MB_ICONWARNING));
144 int information(const String& msg, int type)
146 return detail::convert_resp(AfxMessageBox(msg.c_str(), detail::convert_to_winflags(type) | MB_ICONINFORMATION));
151 AboutInfo::AboutInfo()
153 CVersionInfo verinfo;
154 version = strutils::format_string1(_("Version %1"), verinfo.GetProductVersion());
155 private_build = verinfo.GetPrivateBuild();
156 if (!private_build.empty())
158 version += _T(" + ") + private_build;
161 if (version.find(_T(" - ")) != String::npos)
163 strutils::replace(version, _T(" - "), _T("\n"));
173 version += _T("x86");
174 #elif defined _M_IA64
175 version += _T(" IA64");
180 version += _T(" ARM");
181 #elif defined _M_ARM64
182 version += _T(" ARM64");
187 version += _T("Debug");
191 copyright = _("WinMerge comes with ABSOLUTELY NO WARRANTY. This is free software and you are welcome to redistribute it under certain circumstances; see the GNU General Public License in the Help menu for details.");
192 copyright += _T("\n");
193 copyright += verinfo.GetLegalCopyright();
194 copyright += _T(" - All rights reserved.");
196 website = WinMergeURL;