From d3fd17db0457a5dedf85819434dcff8e9e5d96da Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 24 Dec 2017 18:24:05 -0600 Subject: [PATCH] Use wxAutoBufferedPaintDC to reduce flicker with wxMSW --- samples/event/gestures.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/event/gestures.cpp b/samples/event/gestures.cpp index 669d5972dc..711d702e83 100644 --- a/samples/event/gestures.cpp +++ b/samples/event/gestures.cpp @@ -1,5 +1,6 @@ #include "gestures.h" #include "wx/dcgraph.h" +#include "wx/dcbuffer.h" #include "../image/horse.xpm" @@ -40,6 +41,7 @@ MyGesturePanel::MyGesturePanel(MyGestureFrame *parent) : wxPanel(parent, wxID_ANY), m_bitmap(horse_xpm) { + SetBackgroundStyle(wxBG_STYLE_PAINT); Bind(wxEVT_PAINT, &MyGesturePanel::OnPaint, this); if ( !EnableTouchEvents(wxTOUCH_ALL_GESTURES) ) @@ -75,12 +77,10 @@ void MyGestureFrame::OnGesture(wxGestureEvent& event) void MyGesturePanel::OnPaint(wxPaintEvent& WXUNUSED(event)) { - wxPaintDC paintDC(this); + wxAutoBufferedPaintDC paintDC(this); + paintDC.Clear(); wxGCDC dc(paintDC); - - dc.Clear(); - dc.SetTransformMatrix(m_affineMatrix); dc.DrawBitmap(m_bitmap, wxRound(m_translateDistance.m_x), wxRound(m_translateDistance.m_y)); }