方法一:
转自: https://forums.wxwidgets.org/viewtopic.php?t=1610
创建一个 wxTextCtrl来显示日志:
In a Frames constructor I have
MyFrame::MyFrame( ...){ ... m_log_textctrl = new wxTextCtrl (this, -1, wxEmptyString, wxPoint (0, 250), wxSize (700, 100), wxTE_MULTILINE); m_logger = new wxLogTextCtrl (m_log_textctrl); wxLog::SetActiveTarget (m_logger); ... } Now u can use e.g. wxLogMessage() everywhere in your Application, it s output will be written to the above wxTextCtrl ...
方法二:
转自: http://wxwidgets.10942.n7.nabble.com/wxLogWindow-not-get-focus-with-top-level-dialog-does-with-top-level-frame-td88465.html
创建一个 wxLogWindow来显示日志:
bool MyApp::OnInit() { //Init wxLogWindow wxString LogTitle(wxString::Format("'%s' Status Window", wxTheApp->GetAppName().c_str())); wxLogWindow *log_window_m = new wxLogWindow(NULL, LogTitle, false, false);// Don't show at start up, don't process outside of frame wxLogMessage(wxT("[%s/%s/%u] '%s' is starting"), __TFILE__,wxString::FromAscii(__WXFUNCTION__).c_str(), __LINE__,wxTheApp->GetAppName().c_str()); log_window_m->SetVerbose(true); // Normally from wxConfig force it for example wxLogVerbose(wxT("[%s/%s/%u] Verbose Logging Enabled"),__TFILE__, wxString::FromAscii(__WXFUNCTION__).c_str(), __LINE__);// Won't show if not enabled log_window_m->Show(true); // Normally from wxConfig force it for example //MyFrame *frame = new MyFrame("Hello World", wxDefaultPosition, wxDefaultSize); //frame->Show(true); return true; }
