flickering Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Knows some wx things
Knows some wx things
Posts: 40
Joined: Fri Jul 05, 2019 3:58 pm


Post by bandali99 » Tue Aug 20, 2019 4:52 pm

I created a custom slider using wxPaintDC, then created a custom widget class where I created checkboxes, text and used sizers to format the widget. I used another class, test, as a frame to input multiple custom widgets. In the test class, I used refresh and update after setting all the sliders values the same and now it flickers non stop. How can I fix this?

Code: Select all

void test::onIdle(wxIdleEvent& evt)
	if (render) {

		int our_value = sliders[0]->GetcustomMainValue();
		if (our_value > 0) {
			for (int r = 0; r < sliders.size(); r++) {

User avatar
Posts: 15651
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: flickering

Post by doublemax » Tue Aug 20, 2019 6:26 pm

Redrawing permanently in an idle event is a bad idea. You should optimize it to refresh only when needed. Also calling Refresh() and Update() like you used them will refresh the whole frame, not only the slider. It would be better to call them inside the slider's SetcustomMainValue() method.

Regarding the flickering, replacing wxPaintDC with wxBufferedPaintDC should fix it.
Use the source, Luke!

Post Reply