the problem of resize event Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
chenzhengxi
Earned a small fee
Earned a small fee
Posts: 22
Joined: Tue Jan 17, 2006 9:49 am

the problem of resize event

Post by chenzhengxi » Mon Feb 13, 2006 4:20 pm

I wrote a very simple program.one frame,one menu,one button
but the sentence SetMenuBar( menuBar ) cannot exist with the
EVT_SIZE(MyFrame::OnSize)
void MyFrame::OnSize(wxSizeEvent& event)
{
if(myButton)
{
wxSize size = GetClientSize();
myButton->SetSize(0,0,size.x,size.y);
}
event.Skip();
}
why?
when I run the application,it show a memory err.

phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 » Mon Feb 13, 2006 4:57 pm

Hm, is myButton a valid pointer ?
You might wanna use a sizer, and set wxEXPAND for
the sizeritem which contains the wxButton.

chenzhengxi
Earned a small fee
Earned a small fee
Posts: 22
Joined: Tue Jan 17, 2006 9:49 am

Post by chenzhengxi » Mon Feb 13, 2006 6:18 pm

oh,no
I do follow you,the problem continue
And i debug it,it break at the function SetMenuBar(...);
if I romove it ,the program run ok.

chenzhengxi
Earned a small fee
Earned a small fee
Posts: 22
Joined: Tue Jan 17, 2006 9:49 am

Post by chenzhengxi » Mon Feb 13, 2006 6:45 pm

:D
the problem is the button point invalidation.
I donot understand
My button point has been defined in the head file.
I change the construct function from
//////////////////////
myFrame::myFrame(wxWindow *pParent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxFrame(pParent, id, title, pos, size, style, name)
{
CreateGUIControls();
}
//////////////////////
to
//////////////////////
myFrame::myFrame(wxWindow *pParent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxFrame(pParent, id, title, pos, size, style, name),myButton(NULL)
{
CreateGUIControls();
}
//////////////////////
all is ok
what different between them?
and all the initializtion code is in CreateGUIControls()

phlox81
wxWorld Domination!
wxWorld Domination!
Posts: 1387
Joined: Thu Aug 18, 2005 7:49 pm
Location: Germany
Contact:

Post by phlox81 » Mon Feb 13, 2006 7:23 pm

chenzhengxi wrote: //////////////////////
all is ok
what different between them?
and all the initializtion code is in CreateGUIControls()
if myButton is NULL, if(myButton) fails.

chenzhengxi
Earned a small fee
Earned a small fee
Posts: 22
Joined: Tue Jan 17, 2006 9:49 am

Post by chenzhengxi » Mon Feb 13, 2006 9:36 pm

I forget the constructor function is a special function.
:D
thx very much.

Post Reply