说明
OnIdle CPU空闲的情况下处理消息,如果需要定时功能,就需要使用定时器wxTimer
例子
#include "wx/timer.h"
private:
wxTimer *m_timer;
#define TIMER_ID 1000
EVT_TIMER(TIMER_ID, CFlightInstrumentPanel::OnTimer)
m_timer = new wxTimer(this, TIMER_ID);
m_timer->Start(1000);
void CFlightInstrumentPanel::OnTimer( wxTimerEvent& event )
{
static int x = 0;
if (x<1000)
{
wxClientDC dc(this);
wxPen pen(*wxRED,1);
dc.SetPen(pen);
dc.DrawRectangle(x, 0, 200, 300);
dc.SetPen(wxNullPen);
x=x+100;
}
}
时间: 2024-11-03 03:43:03