Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / windows refreshing

Register 
新用户注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. windows refreshing
#4838
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
#4841
Posted by: upCASE 2004-07-17 22:48:30
Hi!
Would painting on the windows during an OnPaint() event (wxPaintEvent) be a solution?
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: windows refreshing
#4844
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
#4845
Posted by: upCASE 2004-07-18 21:36:30
Hi!
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.
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message5. Re: windows refreshing
#4855
Posted by: 2004-07-20 00:55:14
Thank you very much upCASE.
Your solution was really good!
Best regards,
Marco
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Wed 2021-7-28  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0