\helpref{wxResourceRegisterBitmapData}{registerbitmapdata}\\
\helpref{wxResourceRegisterIconData}{wxresourceregistericondata}\\
\helpref{wxRmdir}{wxrmdir}\\
+\helpref{wxSafeShowMessage}{wxsafeshowmessage}\\
\helpref{wxSafeYield}{wxsafeyield}\\
\helpref{wxSetClipboardData}{wxsetclipboarddata}\\
\helpref{wxSetCursor}{wxsetcursor}\\
\item wxTraceOleCalls: trace OLE method calls (Win32 only)
\end{itemize}
+\membersection{::wxSafeShowMessage}\label{wxsafeshowmessage}
+
+\func{void}{wxSafeShowMessage}{\param{const wxString\& }{title}, \param{const wxString\& }{text}}
+
+This function shows a message to the user in a safe way and should be safe to
+call even before the application has been initialized or if it is currently in
+some other strange state (for example, about to crash). Under Windows this
+function shows a message box using a native dialog instead of
+\helpref{wxMessageBox}{wxmessagebox} (which might be unsafe to call), elsewhere
+it simply prints the message to the standard output using the title as prefix.
+
+\wxheading{Parameters}
+
+\docparam{title}{The title of the message box shown to the user or the prefix
+of the message string}
+
+\docparam{text}{The text to show to the user}
+
+\wxheading{See also}
+
+\helpref{wxLogFatalError}{wxlogfatalerror}
+
+\wxheading{Include files}
+
+<wx/log.h>
+
\membersection{::wxSysErrorCode}\label{wxsyserrorcode}
\func{unsigned long}{wxSysErrorCode}{\void}
// return the last system error code
WXDLLEXPORT unsigned long wxSysErrorCode();
+
// return the error message for given (or last if 0) error code
WXDLLEXPORT const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
+// ----------------------------------------------------------------------------
// define wxLog<level>
-// -------------------
+// ----------------------------------------------------------------------------
#define DECLARE_LOG_FUNCTION(level) \
extern void WXDLLEXPORT wxVLog##level(const wxChar *szFormat, \
inline void wxLogTrace(const wxChar *, const wxChar *, ...) { }
#endif // debug/!debug
+// wxLogFatalError helper: show the (fatal) error to the user in a safe way,
+// i.e. without using wxMessageBox() for example because it could crash
+extern void wxSafeShowMessage(const wxString& title, const wxString& text);
+
// ----------------------------------------------------------------------------
// debug only logging functions: use them with API name and error code
// ----------------------------------------------------------------------------
#endif // _WX_LOG_H_
-// vi:sts=4:sw=4:et
IMPLEMENT_LOG_FUNCTION(Info)
IMPLEMENT_LOG_FUNCTION(Status)
+void wxSafeShowMessage(const wxString& title, const wxString& text)
+{
+#ifdef __WINDOWS__
+ ::MessageBox(NULL, text, title, MB_OK | MB_ICONSTOP);
+#else
+ wxFprintf(stderr, _T("%s: %s\n"), title.c_str(), text.c_str());
+#endif
+}
+
// fatal errors can't be suppressed nor handled by the custom log target and
// always terminate the program
void wxVLogFatalError(const wxChar *szFormat, va_list argptr)
{
wxVsnprintf(s_szBuf, s_szBufSize, szFormat, argptr);
-#if wxUSE_GUI
- wxMessageBox(s_szBuf, _("Fatal Error"), wxID_OK | wxICON_STOP);
-#else
- wxFprintf(stderr, _("Fatal error: %s\n"), s_szBuf);
-#endif
+ wxSafeShowMessage(_T("Fatal Error"), s_szBuf);
abort();
}