Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

WxWidgets lesson 12 double cache DC in wxBufferedPaintDC OnPaint function

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

description

When using DC for graphics rendering process, there will be flickering problem, mainly graphics are rendered in real time, if rendering in a piece of memory first, and then rendering is completed, only one-time mapping to the screen, you can avoid flickering problem. Therefore wxBuffered PaintDC is introduced. wxBufferedPaintDC inherits from wxBufferedDC, wxPaintDC is its private member variable, so this class can only be used in wxPaintEvent events, that is, only in OnPaint( wxPaintEvent& event ) functions.

In order to use this class, you need to include the header file #include "wx/dcbuffer.h", which is not currently included in the wx/wx.h file. You can add it directly to avoid every handwriting.

example

#include "wx/dcbuffer.h"

void CDownLinkPlaybackSliderCtrl::OnPaint( wxPaintEvent& event )

{

wxBufferedPaintDC dc(this);

dc.SetBrush(*wxWHITE_BRUSH);

dc.Clear();

wxSize size = this->GetSize();

int width = size.GetWidth();

int height = size.GetHeight();

int middleHeight = height/2;

dc.SetPen(wxPen(*wxBLACK, 2));

// dc.DrawLine(0, middleHeight-1, width, middleHeight-1);

// dc.DrawLine(0, middleHeight+1, width, middleHeight+1);

dc.SetBrush(*wxBLACK_BRUSH);

dc.DrawRectangle(2, middleHeight-2, width-4, 4);

int topDialHeight = middleHeight-2;

int buttonDialHeight = middleHeight+2;

int averageGap = (width-4)/25;

int count = 0;

for (int i=2; i

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report