说明
从wxControl中派生出一个控件,调用OnPaint函数对控件进行渲染
例子
头文件
#include "wx/bitmap.h"
#include "wx/control.h"
#include "wx/dcclient.h"
声明
class CFlightInstrumentCompass : public wxControl
{
private:
DECLARE_DYNAMIC_CLASS(CFlightInstrumentCompass)
DECLARE_EVENT_TABLE()
public:
CFlightInstrumentCompass() {Init();}
void Init() {}
CFlightInstrumentCompass(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator)
{
Init();
Create(parent, id, pos, size, style, validator);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator);
~CFlightInstrumentCompass(void);
protected:
void OnPaint(wxPaintEvent& event);
};
定义
BEGIN_EVENT_TABLE(CFlightInstrumentCompass, wxControl)
EVT_PAINT(CFlightInstrumentCompass::OnPaint)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(CFlightInstrumentCompass, wxControl)
void CFlightInstrumentCompass::OnPaint( wxPaintEvent& event )
{
}
提醒
为了减少闪烁,重写OnEraseBackground函数,并且留空,说明不再需要擦除背景
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。