wxWidgets第八课 wxControl自定义控件

发布时间:2020-07-18 09:39:09 作者:fengyuzaitu
来源:网络 阅读:1014

说明

    从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函数,并且留空,说明不再需要擦除背景


推荐阅读:
  1. python第八天学习总结
  2. 我的朗科运维第八课

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

控件 自定义 wxcontrol

上一篇:JavaWeb实现统一查询接口的方法

下一篇:如何给ubuntu18安装python3.7

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》