Drawing a centered aligned image 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
nkwinder
Experienced Solver
Experienced Solver
Posts: 70
Joined: Sun Nov 23, 2008 2:32 pm

Drawing a centered aligned image

Post by nkwinder » Fri Dec 05, 2008 2:36 pm

hello all

i managed to setup a code that displays a dynamically created image. Now the thing is that i want it to always be centered. I tried the style wxFULL_REPAINT_ON_RESIZE, with the correct result but with much flicker. So, whats the best approach to this trivial (i suppose) problem?

thanks in advance!

catalin
Moderator
Moderator
Posts: 1594
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Post by catalin » Fri Dec 05, 2008 2:50 pm

Hi,
To reduce flicker you can add an empty event handler for EraseBackground event in your class.
e.g.

Code: Select all

Connect(wxID_ANY,wxEVT_ERASE_BACKGROUND,(wxObjectEventFunction)&YourClass::OnEraseBackground);

Code: Select all

void YourClass::OnEraseBackground( wxEraseEvent& event )
{}
You can also use buffered painting ! :wink:

nkwinder
Experienced Solver
Experienced Solver
Posts: 70
Joined: Sun Nov 23, 2008 2:32 pm

Post by nkwinder » Fri Dec 05, 2008 3:10 pm

wow this really reduced the flickering a lot! Although there is some noticeable flicker when maximizing.

I already use wxBufferedPaintDC.

thanks a lot for your help.

Any other suggestions would be appreciated.

catalin
Moderator
Moderator
Posts: 1594
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Post by catalin » Fri Dec 05, 2008 4:07 pm

What happens when maximizing? The window containing the drawing is moved? Or the drawing inside the window (panel, whatever..)? Or resized? Try to describe a little more what is going on there...

This is also very good: http://wiki.wxwidgets.org/Flicker-Free_Drawing
And this one (from Cross-Platform GUI Programming with WxWidgets , I hope the link works): http://books.google.ro/books?id=CyMsvtg ... #PPA512,M1

Post Reply