Guidance Forums / wxWidgets (wxWindows) in C++ / windows refreshing

Search 搜索
Home Home

Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. windows refreshing
Posted by: 2004-07-16 22:16:10
Hi everyone.
I just have to solve this problem:
I created a frame in which I have to draw something. It's simply a frame, and I draw on it by creating a wxClientDC linked at it and by using a wxPen.
The problem is : when I drag a window over the frame, all the drawn things disappear; also a resize event make all disappear.
I thought that the solution is to specify something to do to react to a wxEraseEvent, but I'm not sure about it.
Is anyone able to help me?
Thank you all.
Marco Benvenuto
Message2. Re: windows refreshing
Posted by: upCASE 2004-07-17 22:48:30
Would painting on the windows during an OnPaint() event (wxPaintEvent) be a solution?
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: windows refreshing
Posted by: 2004-07-18 19:18:52
It is a possible alternative solution, yes.
But how does it work? Have I to manually generate a PAINT event and then my window has to react to it? Or are there any other ways to do it?
Message4. Re: windows refreshing
Posted by: upCASE 2004-07-18 21:36:30
No, you wouldn't have to "generate" a paint event. wxPaintEvent is automatically triggered when there is need to refresh the contents of a window, like when the window has been resized.
Quoting from the docs:
"A paint event is sent when a window's contents needs to be repainted"

Do it like this:
Let your wxFrame handle the paint event ( EVT_PAINT(func) ). In the OnPaint method create a wxPaintDC and set the wxBrush and wxPen for it as you like. Draw your stuff on this DC. Skip the wxPaintEvent.

Now, everytime you move, resize, maximize etc. the wxFrame, it's content will be redrawn.
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message5. Re: windows refreshing
Posted by: 2004-07-20 00:55:14
Thank you very much upCASE.
Your solution was really good!
Best regards,
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
© Thu 2024-5-30  Guidance Laboratory Inc. Hits:0