Page 1 of 1

Little Help with PaintDC needed

Posted: Sun Nov 17, 2019 6:56 pm
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

Re: Little Help with PaintDC needed

Posted: Sun Nov 17, 2019 9:13 pm
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())

Re: Little Help with PaintDC needed

Posted: Sun Nov 17, 2019 9:53 pm
by Mungo1981
Thanks,
I will try it tomorrow,
Just it is 22:52 in Germany, So I have to sleep a little bit.

Re: Little Help with PaintDC needed

Posted: Wed Nov 20, 2019 3:45 pm
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.

Re: Little Help with PaintDC needed

Posted: Wed Nov 20, 2019 5:24 pm
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.

Re: Little Help with PaintDC needed

Posted: Thu Nov 21, 2019 1:38 pm
by Mungo1981
Thank you,
then I would take the way you suggest

A happy,
Mungo1981