Code::Blocks

Developer forums (C::B DEVELOPMENT STRICTLY!) => Plugins development => Topic started by: nanyu on February 19, 2010, 04:36:56 am

Title: wxSmith maybe have a bug on "event code"
Post by: nanyu on February 19, 2010, 04:36:56 am
step1: I create a new wx GUI(frame) project. and it use wxsmith.

step2: I place a wxPanel on the frame, and named it PanelGame

step3: I custom the panel's onpaint event by  wxSmith. now , I got this code:
 
   PanelGame->Connect(wxEVT_PAINT,(wxObjectEventFunction)&wxTerisFrame::OnPanelGamePaint,0,this);
   
... strange thing happen now... compile..link..and run this program... NOW, I can't close this program's main window. I click the close button which on the window's caption, It do nothing .

     AND: the OnPanel event didn't been called.

step4 : I modify the code:
      //PanelGame->Connect(wxEVT_PAINT,(wxObjectEventFunction)&wxTerisFrame::OnPanelGamePaint,0,this);
        PanelGame->Connect(wxEVT_PAINT,(wxObjectEventFunction)&wxTerisFrame::OnPanelGamePaint,0, 0);

now everything ok!

Is It a bug of wxWidgets (2.8.10/ wxMSW, compiled by mingw gcc 4.4.0)? or a bug of wxSmith?

------------
sorry for my poor Engilsh.
code::blocks svn6088. mingw gcc 4.4.0. windows xp.

Title: Re: wxSmith maybe have a bug on "event code"
Post by: rcoll on February 19, 2010, 07:33:10 am
step4 : I modify the code:
      //PanelGame->Connect(wxEVT_PAINT,(wxObjectEventFunction)&wxTerisFrame::OnPanelGamePaint,0,this);
        PanelGame->Connect(wxEVT_PAINT,(wxObjectEventFunction)&wxTerisFrame::OnPanelGamePaint,0, 0);

now everything ok!

No, it isn't, not really.  If you want it to work properly, put the code back the way that it was originally.
In addition, the wxPaintEvent event requires that you create a wxPaintDC for the target window (component) within the paint event code.  If you do not create this DC, then the code stack may become corrupted, and you might see things such as the program not closing correctly.

Get a copy of the wxWidgets documentation and read about the wxPaintEvent.

Ringo
Title: Re: wxSmith maybe have a bug on "event code"
Post by: nanyu on February 19, 2010, 10:56:54 am
step4 : I modify the code:
      //PanelGame->Connect(wxEVT_PAINT,(wxObjectEventFunction)&wxTerisFrame::OnPanelGamePaint,0,this);
        PanelGame->Connect(wxEVT_PAINT,(wxObjectEventFunction)&wxTerisFrame::OnPanelGamePaint,0, 0);

now everything ok!

No, it isn't, not really.  If you want it to work properly, put the code back the way that it was originally.
In addition, the wxPaintEvent event requires that you create a wxPaintDC for the target window (component) within the paint event code.  If you do not create this DC, then the code stack may become corrupted, and you might see things such as the program not closing correctly.

Get a copy of the wxWidgets documentation and read about the wxPaintEvent.

Ringo


Thank you, you are right.
Title: Re: wxSmith maybe have a bug on "event code"
Post by: ppv on February 19, 2010, 10:11:41 pm
I have the same problem and I have the DC:

see:
http://forums.codeblocks.org/index.php/topic,12018.0.html
Title: Re: wxSmith maybe have a bug on "event code"
Post by: ppv on February 20, 2010, 01:40:05 am
I had tried a lot of things but I don't understand why putting the (wxPaintDC dc(this);) doesn't work for me.

I'll apreciate any suggestion.

best regard

ppv
Title: Re: wxSmith maybe have a bug on "event code"
Post by: rcoll on February 20, 2010, 05:59:30 am
I had tried a lot of things but I don't understand why putting the (wxPaintDC dc(this);) doesn't work for me.

I'll apreciate any suggestion.

best regard

ppv

The "this" in wxPaintDC(this) refers to the wrong object; it normally refers to the parent frame or dialog of yur project, not to the particular panel (or other object) that you want to paint.  Therefore your are creating the wrong wxPaintDC.  You MUST create a wxPaintDC for the individual component that called the paint event.

Ringo
Title: Re: wxSmith maybe have a bug on "event code"
Post by: ppv on February 20, 2010, 07:58:08 am
THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!! that's fix it.