Little Help with PaintDC needed

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
Mungo1981
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Jan 30, 2019 5:42 pm

Little Help with PaintDC needed

Post by Mungo1981 »

Dear Community,
I swore to come back with a stupid question....
... And I'm back.

Little Problem with Draw Events.
What is to do to have a Drawing on a Panel permanent.
What I have is, a Algorithm with PaintDC to paint simple my Picture.
But what I want is:
It so that even I rescale the main Window or I drawn a MessageBox above this,
it should not been removed.
So the simplest Solution is needed.

In thanks of coming Help.
Mungo1981
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Little Help with PaintDC needed

Post by doublemax »

You need to catch and handle the wxEVT_PAINT event of the window.

https://wiki.wxwidgets.org/Drawing_on_a_panel_with_a_DC
(Ignore the Render() and PaintNow() methods, put everything in the paint event handler BasicDrawPane::paintEvent())
Use the source, Luke!
Mungo1981
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Jan 30, 2019 5:42 pm

Re: Little Help with PaintDC needed

Post by Mungo1981 »

Thanks,
I will try it tomorrow,
Just it is 22:52 in Germany, So I have to sleep a little bit.
Mungo1981
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Jan 30, 2019 5:42 pm

Re: Little Help with PaintDC needed

Post by Mungo1981 »

Ok, I try to do it now.

But a set of stupid Questions:
1.) must I build a new Class for every as Custom-Widget used Panel.
1a.) Or can I realise the Function to paint this Panel in a superset Panel which holds this Panel as Member in his Class.

Ok.:) Ok, News:
I Get the Error that above should not run.
So it's the only Solution to make a special Class to the Panels on which I will draw
or there easier Solutions.
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Little Help with PaintDC needed

Post by doublemax »

Mungo1981 wrote: Wed Nov 20, 2019 3:45 pm 1.) must I build a new Class for every as Custom-Widget used Panel.
1a.) Or can I realise the Function to paint this Panel in a superset Panel which holds this Panel as Member in his Class.
It's possible with Bind() to connect the event of one object to an event handler in a different class. It's just a little tricky, because you need to the the "EventHandler *handler" parameter correctly. But the compiler will throw an error if you did it wrong :)

However, i would do this only for a quick-and-dirty test. In order to keep your code clean, i would suggest to subclass wxWindow/wxPanel.
Use the source, Luke!
Mungo1981
Experienced Solver
Experienced Solver
Posts: 86
Joined: Wed Jan 30, 2019 5:42 pm

Re: Little Help with PaintDC needed

Post by Mungo1981 »

Thank you,
then I would take the way you suggest

A happy,
Mungo1981
Post Reply