News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

wxSmith maybe have a bug on "event code"

Started by nanyu, February 19, 2010, 04:36:56 AM

Previous topic - Next topic

nanyu

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.


rcoll

Quote from: nanyu on February 19, 2010, 04:36:56 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

nanyu

Quote from: rcoll on February 19, 2010, 07:33:10 AM
Quote from: nanyu on February 19, 2010, 04:36:56 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.

ppv


ppv

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

rcoll

Quote from: 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

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

ppv

THANK YOU!!!!!!!!!!!!!!!!!!!!!!!!!!!! that's fix it.