1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/log.cpp
3 // Purpose: Assorted wxLogXXX functions, and wxLog (sink for logs)
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
33 #include "wx/arrstr.h"
35 #include "wx/string.h"
39 #include "wx/apptrait.h"
40 #include "wx/datetime.h"
42 #include "wx/msgout.h"
43 #include "wx/textfile.h"
44 #include "wx/thread.h"
45 #include "wx/private/threadinfo.h"
47 #include "wx/vector.h"
49 // other standard headers
60 #include "wx/msw/wince/time.h"
62 #endif /* ! __WXPALMOS5__ */
64 #if defined(__WINDOWS__)
65 #include "wx/msw/private.h" // includes windows.h
68 #undef wxLOG_COMPONENT
69 const char *wxLOG_COMPONENT
= "";
73 wxTLS_TYPE(wxThreadSpecificInfo
) wxThreadInfoVar
;
75 // this macro allows to define an object which will be initialized before any
76 // other function in this file is called: this is necessary to allow log
77 // functions to be used during static initialization (this is not advisable
78 // anyhow but we should at least try to not crash) and to also ensure that they
79 // are initialized by the time static initialization is done, i.e. before any
80 // threads are created hopefully
82 // the net effect of all this is that you can use Get##name() function to
83 // access the object without worrying about it being not initialized
85 // see also WX_DEFINE_GLOBAL_CONV2() in src/common/strconv.cpp
86 #define WX_DEFINE_GLOBAL_VAR(type, name) \
87 inline type& Get##name() \
89 static type s_##name; \
93 type *gs_##name##Ptr = &Get##name()
98 // contains messages logged by the other threads and waiting to be shown until
99 // Flush() is called in the main one
100 typedef wxVector
<wxLogRecord
> wxLogRecords
;
101 wxLogRecords gs_bufferedLogRecords
;
103 #define WX_DEFINE_LOG_CS(name) WX_DEFINE_GLOBAL_VAR(wxCriticalSection, name##CS)
105 // this critical section is used for buffering the messages from threads other
106 // than main, i.e. it protects all accesses to gs_bufferedLogRecords above
107 WX_DEFINE_LOG_CS(BackgroundLog
);
109 // this one is used for protecting ms_aTraceMasks from concurrent access
110 WX_DEFINE_LOG_CS(TraceMask
);
112 // and this one is used for GetComponentLevels()
113 WX_DEFINE_LOG_CS(Levels
);
115 } // anonymous namespace
117 #endif // wxUSE_THREADS
119 // ----------------------------------------------------------------------------
120 // non member functions
121 // ----------------------------------------------------------------------------
123 // define this to enable wrapping of log messages
124 //#define LOG_PRETTY_WRAP
126 #ifdef LOG_PRETTY_WRAP
127 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
);
130 // ----------------------------------------------------------------------------
132 // ----------------------------------------------------------------------------
137 // this struct is used to store information about the previous log message used
138 // by OnLog() to (optionally) avoid logging multiple copies of the same message
139 struct PreviousLogInfo
147 // previous message itself
153 // other information about it
154 wxLogRecordInfo info
;
156 // the number of times it was already repeated
157 unsigned numRepeated
;
160 PreviousLogInfo gs_prevLog
;
163 // map containing all components for which log level was explicitly set
165 // NB: all accesses to it must be protected by GetLevelsCS() critical section
166 WX_DEFINE_GLOBAL_VAR(wxStringToNumHashMap
, ComponentLevels
);
168 // ----------------------------------------------------------------------------
169 // wxLogOutputBest: wxLog wrapper around wxMessageOutputBest
170 // ----------------------------------------------------------------------------
172 class wxLogOutputBest
: public wxLog
175 wxLogOutputBest() { }
178 virtual void DoLogText(const wxString
& msg
)
180 wxMessageOutputBest().Output(msg
);
184 wxDECLARE_NO_COPY_CLASS(wxLogOutputBest
);
187 } // anonymous namespace
189 // ============================================================================
191 // ============================================================================
193 // ----------------------------------------------------------------------------
194 // helper global functions
195 // ----------------------------------------------------------------------------
197 void wxSafeShowMessage(const wxString
& title
, const wxString
& text
)
200 ::MessageBox(NULL
, text
.t_str(), title
.t_str(), MB_OK
| MB_ICONSTOP
);
202 wxFprintf(stderr
, wxS("%s: %s\n"), title
.c_str(), text
.c_str());
207 // ----------------------------------------------------------------------------
208 // wxLog class implementation
209 // ----------------------------------------------------------------------------
211 unsigned wxLog::LogLastRepeatIfNeeded()
213 const unsigned count
= gs_prevLog
.numRepeated
;
215 if ( gs_prevLog
.numRepeated
)
219 msg
.Printf(wxPLURAL("The previous message repeated once.",
220 "The previous message repeated %lu times.",
221 gs_prevLog
.numRepeated
),
222 gs_prevLog
.numRepeated
);
224 msg
.Printf(wxS("The previous message was repeated %lu times."),
225 gs_prevLog
.numRepeated
);
227 gs_prevLog
.numRepeated
= 0;
228 gs_prevLog
.msg
.clear();
229 DoLogRecord(gs_prevLog
.level
, msg
, gs_prevLog
.info
);
237 // Flush() must be called before destroying the object as otherwise some
238 // messages could be lost
239 if ( gs_prevLog
.numRepeated
)
241 wxMessageOutputDebug().Printf
243 wxS("Last repeated message (\"%s\", %lu times) wasn't output"),
245 gs_prevLog
.numRepeated
250 // ----------------------------------------------------------------------------
251 // wxLog logging functions
252 // ----------------------------------------------------------------------------
256 wxLog::OnLog(wxLogLevel level
, const wxString
& msg
, time_t t
)
258 wxLogRecordInfo info
;
261 info
.threadId
= wxThread::GetCurrentId();
262 #endif // wxUSE_THREADS
264 OnLog(level
, msg
, info
);
269 wxLog::OnLog(wxLogLevel level
,
271 const wxLogRecordInfo
& info
)
273 // fatal errors can't be suppressed nor handled by the custom log target
274 // and always terminate the program
275 if ( level
== wxLOG_FatalError
)
277 wxSafeShowMessage(wxS("Fatal Error"), msg
);
289 if ( !wxThread::IsMain() )
291 logger
= wxThreadInfo
.logger
;
296 // buffer the messages until they can be shown from the main
298 wxCriticalSectionLocker
lock(GetBackgroundLogCS());
300 gs_bufferedLogRecords
.push_back(wxLogRecord(level
, msg
, info
));
302 // ensure that our Flush() will be called soon
305 //else: we don't have any logger at all, there is no need to log
310 //else: we have a thread-specific logger, we can send messages to it
314 #endif // wxUSE_THREADS
316 logger
= GetMainThreadActiveTarget();
321 logger
->CallDoLogNow(level
, msg
, info
);
325 wxLog::CallDoLogNow(wxLogLevel level
,
327 const wxLogRecordInfo
& info
)
329 if ( GetRepetitionCounting() )
331 if ( msg
== gs_prevLog
.msg
)
333 gs_prevLog
.numRepeated
++;
335 // nothing else to do, in particular, don't log the
340 LogLastRepeatIfNeeded();
342 // reset repetition counter for a new message
343 gs_prevLog
.msg
= msg
;
344 gs_prevLog
.level
= level
;
345 gs_prevLog
.info
= info
;
348 // handle extra data which may be passed to us by wxLogXXX()
349 wxString prefix
, suffix
;
351 if ( info
.GetNumValue(wxLOG_KEY_SYS_ERROR_CODE
, &num
) )
353 const long err
= static_cast<long>(num
);
355 suffix
.Printf(_(" (error %ld: %s)"), err
, wxSysErrorMsg(err
));
360 if ( level
== wxLOG_Trace
&& info
.GetStrValue(wxLOG_KEY_TRACE_MASK
, &str
) )
362 prefix
= "(" + str
+ ") ";
364 #endif // wxUSE_LOG_TRACE
366 DoLogRecord(level
, prefix
+ msg
+ suffix
, info
);
369 void wxLog::DoLogRecord(wxLogLevel level
,
371 const wxLogRecordInfo
& info
)
373 #if WXWIN_COMPATIBILITY_2_8
374 // call the old DoLog() to ensure that existing custom log classes still
377 // as the user code could have defined it as either taking "const char *"
378 // (in ANSI build) or "const wxChar *" (in ANSI/Unicode), we have no choice
379 // but to call both of them
380 DoLog(level
, (const char*)msg
.mb_str(), info
.timestamp
);
381 DoLog(level
, (const wchar_t*)msg
.wc_str(), info
.timestamp
);
382 #else // !WXWIN_COMPATIBILITY_2_8
384 #endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8
387 // TODO: it would be better to extract message formatting in a separate
388 // wxLogFormatter class but for now we hard code formatting here
392 // don't time stamp debug messages under MSW as debug viewers usually
393 // already have an option to do it
395 if ( level
!= wxLOG_Debug
&& level
!= wxLOG_Trace
)
399 // TODO: use the other wxLogRecordInfo fields
404 prefix
+= _("Error: ");
408 prefix
+= _("Warning: ");
411 // don't prepend "debug/trace" prefix under MSW as it goes to the debug
412 // window anyhow and so can't be confused with something else
415 // this prefix (as well as the one below) is intentionally not
416 // translated as nobody translates debug messages anyhow
426 DoLogTextAtLevel(level
, prefix
+ msg
);
429 void wxLog::DoLogTextAtLevel(wxLogLevel level
, const wxString
& msg
)
431 // we know about debug messages (because using wxMessageOutputDebug is the
432 // right thing to do in 99% of all cases and also for compatibility) but
433 // anything else needs to be handled in the derived class
434 if ( level
== wxLOG_Debug
|| level
== wxLOG_Trace
)
436 wxMessageOutputDebug().Output(msg
+ wxS('\n'));
444 void wxLog::DoLogText(const wxString
& WXUNUSED(msg
))
446 // in 2.8-compatible build the derived class might override DoLog() or
447 // DoLogString() instead so we can't have this assert there
448 #if !WXWIN_COMPATIBILITY_2_8
449 wxFAIL_MSG( "must be overridden if it is called" );
450 #endif // WXWIN_COMPATIBILITY_2_8
453 #if WXWIN_COMPATIBILITY_2_8
455 void wxLog::DoLog(wxLogLevel
WXUNUSED(level
), const char *szString
, time_t t
)
457 DoLogString(szString
, t
);
460 void wxLog::DoLog(wxLogLevel
WXUNUSED(level
), const wchar_t *wzString
, time_t t
)
462 DoLogString(wzString
, t
);
465 #endif // WXWIN_COMPATIBILITY_2_8
467 // ----------------------------------------------------------------------------
468 // wxLog active target management
469 // ----------------------------------------------------------------------------
471 wxLog
*wxLog::GetActiveTarget()
474 if ( !wxThread::IsMain() )
476 // check if we have a thread-specific log target
477 wxLog
* const logger
= wxThreadInfo
.logger
;
479 // the code below should be only executed for the main thread as
480 // CreateLogTarget() is not meant for auto-creating log targets for
481 // worker threads so skip it in any case
482 return logger
? logger
: ms_pLogger
;
484 #endif // wxUSE_THREADS
486 return GetMainThreadActiveTarget();
490 wxLog
*wxLog::GetMainThreadActiveTarget()
492 if ( ms_bAutoCreate
&& ms_pLogger
== NULL
) {
493 // prevent infinite recursion if someone calls wxLogXXX() from
494 // wxApp::CreateLogTarget()
495 static bool s_bInGetActiveTarget
= false;
496 if ( !s_bInGetActiveTarget
) {
497 s_bInGetActiveTarget
= true;
499 // ask the application to create a log target for us
500 if ( wxTheApp
!= NULL
)
501 ms_pLogger
= wxTheApp
->GetTraits()->CreateLogTarget();
503 ms_pLogger
= new wxLogOutputBest
;
505 s_bInGetActiveTarget
= false;
507 // do nothing if it fails - what can we do?
514 wxLog
*wxLog::SetActiveTarget(wxLog
*pLogger
)
516 if ( ms_pLogger
!= NULL
) {
517 // flush the old messages before changing because otherwise they might
518 // get lost later if this target is not restored
522 wxLog
*pOldLogger
= ms_pLogger
;
523 ms_pLogger
= pLogger
;
530 wxLog
*wxLog::SetThreadActiveTarget(wxLog
*logger
)
532 wxASSERT_MSG( !wxThread::IsMain(), "use SetActiveTarget() for main thread" );
534 wxLog
* const oldLogger
= wxThreadInfo
.logger
;
538 wxThreadInfo
.logger
= logger
;
542 #endif // wxUSE_THREADS
544 void wxLog::DontCreateOnDemand()
546 ms_bAutoCreate
= false;
548 // this is usually called at the end of the program and we assume that it
549 // is *always* called at the end - so we free memory here to avoid false
550 // memory leak reports from wxWin memory tracking code
554 void wxLog::DoCreateOnDemand()
556 ms_bAutoCreate
= true;
559 // ----------------------------------------------------------------------------
560 // wxLog components levels
561 // ----------------------------------------------------------------------------
564 void wxLog::SetComponentLevel(const wxString
& component
, wxLogLevel level
)
566 if ( component
.empty() )
572 wxCRIT_SECT_LOCKER(lock
, GetLevelsCS());
574 GetComponentLevels()[component
] = level
;
579 wxLogLevel
wxLog::GetComponentLevel(wxString component
)
581 wxCRIT_SECT_LOCKER(lock
, GetLevelsCS());
583 const wxStringToNumHashMap
& componentLevels
= GetComponentLevels();
584 while ( !component
.empty() )
586 wxStringToNumHashMap::const_iterator
587 it
= componentLevels
.find(component
);
588 if ( it
!= componentLevels
.end() )
589 return static_cast<wxLogLevel
>(it
->second
);
591 component
= component
.BeforeLast('/');
594 return GetLogLevel();
597 // ----------------------------------------------------------------------------
599 // ----------------------------------------------------------------------------
601 void wxLog::AddTraceMask(const wxString
& str
)
603 wxCRIT_SECT_LOCKER(lock
, GetTraceMaskCS());
605 ms_aTraceMasks
.push_back(str
);
608 void wxLog::RemoveTraceMask(const wxString
& str
)
610 wxCRIT_SECT_LOCKER(lock
, GetTraceMaskCS());
612 int index
= ms_aTraceMasks
.Index(str
);
613 if ( index
!= wxNOT_FOUND
)
614 ms_aTraceMasks
.RemoveAt((size_t)index
);
617 void wxLog::ClearTraceMasks()
619 wxCRIT_SECT_LOCKER(lock
, GetTraceMaskCS());
621 ms_aTraceMasks
.Clear();
624 /*static*/ bool wxLog::IsAllowedTraceMask(const wxString
& mask
)
626 wxCRIT_SECT_LOCKER(lock
, GetTraceMaskCS());
628 for ( wxArrayString::iterator it
= ms_aTraceMasks
.begin(),
629 en
= ms_aTraceMasks
.end();
639 // ----------------------------------------------------------------------------
640 // wxLog miscellaneous other methods
641 // ----------------------------------------------------------------------------
643 void wxLog::TimeStamp(wxString
*str
)
646 if ( !ms_timestamp
.empty() )
650 (void)time(&timeNow
);
653 wxStrftime(buf
, WXSIZEOF(buf
),
654 ms_timestamp
, wxLocaltime_r(&timeNow
, &tm
));
657 *str
<< buf
<< wxS(": ");
659 #endif // wxUSE_DATETIME
664 void wxLog::FlushThreadMessages()
666 // check if we have queued messages from other threads
667 wxLogRecords bufferedLogRecords
;
670 wxCriticalSectionLocker
lock(GetBackgroundLogCS());
671 bufferedLogRecords
.swap(gs_bufferedLogRecords
);
673 // release the lock now to not keep it while we are logging the
674 // messages below, allowing background threads to run
677 if ( !bufferedLogRecords
.empty() )
679 for ( wxLogRecords::const_iterator it
= bufferedLogRecords
.begin();
680 it
!= bufferedLogRecords
.end();
683 CallDoLogNow(it
->level
, it
->msg
, it
->info
);
689 bool wxLog::IsThreadLoggingEnabled()
691 return !wxThreadInfo
.loggingDisabled
;
695 bool wxLog::EnableThreadLogging(bool enable
)
697 const bool wasEnabled
= !wxThreadInfo
.loggingDisabled
;
698 wxThreadInfo
.loggingDisabled
= !enable
;
702 #endif // wxUSE_THREADS
706 LogLastRepeatIfNeeded();
710 void wxLog::FlushActive()
712 if ( ms_suspendCount
)
715 wxLog
* const log
= GetActiveTarget();
719 if ( wxThread::IsMain() )
720 log
->FlushThreadMessages();
721 #endif // wxUSE_THREADS
727 // ----------------------------------------------------------------------------
728 // wxLogBuffer implementation
729 // ----------------------------------------------------------------------------
731 void wxLogBuffer::Flush()
735 if ( !m_str
.empty() )
737 wxMessageOutputBest out
;
738 out
.Printf(wxS("%s"), m_str
.c_str());
743 void wxLogBuffer::DoLogTextAtLevel(wxLogLevel level
, const wxString
& msg
)
745 // don't put debug messages in the buffer, we don't want to show
746 // them to the user in a msg box, log them immediately
751 wxLog::DoLogTextAtLevel(level
, msg
);
755 m_str
<< msg
<< wxS("\n");
759 // ----------------------------------------------------------------------------
760 // wxLogStderr class implementation
761 // ----------------------------------------------------------------------------
763 wxLogStderr::wxLogStderr(FILE *fp
)
771 void wxLogStderr::DoLogText(const wxString
& msg
)
773 wxFputs(msg
+ '\n', m_fp
);
776 // under GUI systems such as Windows or Mac, programs usually don't have
777 // stderr at all, so show the messages also somewhere else, typically in
778 // the debugger window so that they go at least somewhere instead of being
780 if ( m_fp
== stderr
)
782 wxAppTraits
*traits
= wxTheApp
? wxTheApp
->GetTraits() : NULL
;
783 if ( traits
&& !traits
->HasStderr() )
785 wxMessageOutputDebug().Output(msg
+ wxS('\n'));
790 // ----------------------------------------------------------------------------
791 // wxLogStream implementation
792 // ----------------------------------------------------------------------------
794 #if wxUSE_STD_IOSTREAM
795 #include "wx/ioswrap.h"
796 wxLogStream::wxLogStream(wxSTD ostream
*ostr
)
799 m_ostr
= &wxSTD cerr
;
804 void wxLogStream::DoLogText(const wxString
& msg
)
806 (*m_ostr
) << msg
<< wxSTD endl
;
808 #endif // wxUSE_STD_IOSTREAM
810 // ----------------------------------------------------------------------------
812 // ----------------------------------------------------------------------------
814 wxLogChain::wxLogChain(wxLog
*logger
)
816 m_bPassMessages
= true;
819 m_logOld
= wxLog::SetActiveTarget(this);
822 wxLogChain::~wxLogChain()
826 if ( m_logNew
!= this )
830 void wxLogChain::SetLog(wxLog
*logger
)
832 if ( m_logNew
!= this )
838 void wxLogChain::Flush()
843 // be careful to avoid infinite recursion
844 if ( m_logNew
&& m_logNew
!= this )
848 void wxLogChain::DoLogRecord(wxLogLevel level
,
850 const wxLogRecordInfo
& info
)
852 // let the previous logger show it
853 if ( m_logOld
&& IsPassingMessages() )
854 m_logOld
->LogRecord(level
, msg
, info
);
856 // and also send it to the new one
857 if ( m_logNew
&& m_logNew
!= this )
858 m_logNew
->LogRecord(level
, msg
, info
);
862 // "'this' : used in base member initializer list" - so what?
863 #pragma warning(disable:4355)
866 // ----------------------------------------------------------------------------
868 // ----------------------------------------------------------------------------
870 wxLogInterposer::wxLogInterposer()
875 // ----------------------------------------------------------------------------
876 // wxLogInterposerTemp
877 // ----------------------------------------------------------------------------
879 wxLogInterposerTemp::wxLogInterposerTemp()
886 #pragma warning(default:4355)
889 // ============================================================================
890 // Global functions/variables
891 // ============================================================================
893 // ----------------------------------------------------------------------------
895 // ----------------------------------------------------------------------------
897 bool wxLog::ms_bRepetCounting
= false;
899 wxLog
*wxLog::ms_pLogger
= NULL
;
900 bool wxLog::ms_doLog
= true;
901 bool wxLog::ms_bAutoCreate
= true;
902 bool wxLog::ms_bVerbose
= false;
904 wxLogLevel
wxLog::ms_logLevel
= wxLOG_Max
; // log everything by default
906 size_t wxLog::ms_suspendCount
= 0;
908 wxString
wxLog::ms_timestamp(wxS("%X")); // time only, no date
910 #if WXWIN_COMPATIBILITY_2_8
911 wxTraceMask
wxLog::ms_ulTraceMask
= (wxTraceMask
)0;
912 #endif // wxDEBUG_LEVEL
914 wxArrayString
wxLog::ms_aTraceMasks
;
916 // ----------------------------------------------------------------------------
917 // stdout error logging helper
918 // ----------------------------------------------------------------------------
920 // helper function: wraps the message and justifies it under given position
921 // (looks more pretty on the terminal). Also adds newline at the end.
923 // TODO this is now disabled until I find a portable way of determining the
924 // terminal window size (ok, I found it but does anybody really cares?)
925 #ifdef LOG_PRETTY_WRAP
926 static void wxLogWrap(FILE *f
, const char *pszPrefix
, const char *psz
)
928 size_t nMax
= 80; // FIXME
929 size_t nStart
= strlen(pszPrefix
);
933 while ( *psz
!= '\0' ) {
934 for ( n
= nStart
; (n
< nMax
) && (*psz
!= '\0'); n
++ )
938 if ( *psz
!= '\0' ) {
940 for ( n
= 0; n
< nStart
; n
++ )
943 // as we wrapped, squeeze all white space
944 while ( isspace(*psz
) )
951 #endif //LOG_PRETTY_WRAP
953 // ----------------------------------------------------------------------------
954 // error code/error message retrieval functions
955 // ----------------------------------------------------------------------------
957 // get error code from syste
958 unsigned long wxSysErrorCode()
960 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
961 return ::GetLastError();
967 // get error message from system
968 const wxChar
*wxSysErrorMsg(unsigned long nErrCode
)
971 nErrCode
= wxSysErrorCode();
973 #if defined(__WXMSW__) && !defined(__WXMICROWIN__)
974 static wxChar s_szBuf
[1024];
976 // get error message from system
980 FORMAT_MESSAGE_ALLOCATE_BUFFER
| FORMAT_MESSAGE_FROM_SYSTEM
,
983 MAKELANGID(LANG_NEUTRAL
, SUBLANG_DEFAULT
),
989 // if this happens, something is seriously wrong, so don't use _() here
991 wxSprintf(s_szBuf
, wxS("unknown error %lx"), nErrCode
);
996 // copy it to our buffer and free memory
997 // Crashes on SmartPhone (FIXME)
998 #if !defined(__SMARTPHONE__) /* of WinCE */
1001 wxStrlcpy(s_szBuf
, (const wxChar
*)lpMsgBuf
, WXSIZEOF(s_szBuf
));
1003 LocalFree(lpMsgBuf
);
1005 // returned string is capitalized and ended with '\r\n' - bad
1006 s_szBuf
[0] = (wxChar
)wxTolower(s_szBuf
[0]);
1007 size_t len
= wxStrlen(s_szBuf
);
1010 if ( s_szBuf
[len
- 2] == wxS('\r') )
1011 s_szBuf
[len
- 2] = wxS('\0');
1015 #endif // !__SMARTPHONE__
1017 s_szBuf
[0] = wxS('\0');
1023 static wchar_t s_wzBuf
[1024];
1024 wxConvCurrent
->MB2WC(s_wzBuf
, strerror((int)nErrCode
),
1025 WXSIZEOF(s_wzBuf
) - 1);
1028 return strerror((int)nErrCode
);
1030 #endif // __WXMSW__/!__WXMSW__