User forums > Using Code::Blocks
Issue with Display of wxFrame
Englishuk:
--- Quote from: seb_seb0 on May 01, 2010, 11:16:42 am ---Well, your topic will be locked because it is a wxWidgets question, and not a CodeBlocks question
Your problem comes certainly from the panel paint handler
--- Code: ---void MainFrame::OnPanel1Paint(wxPaintEvent& event)
--- End code ---
and from the event connector:
--- Code: ---Panel1->Connect(ID_PANEL1,wxEVT_PAINT,(wxObjectEventFunction)&MainFrame::OnPanel1Paint,0,this);
--- End code ---
There are 2 mistakes in these 2 lines:
1 - the wxEVT_PAINT handling is not needed - wxPanel manages it internally
2 - you are doing nothing in the event handler (empty function). On windows (I assume you are on Windows, seeing your screenshots), you MUST create a wxPaintDC object in the paint handler, even if you do not use it. Otherwise, Windows will keep asking to update the panel, making an infinite loop. I bet that when you run your program, your CPU usage is near 100%
this infinite loop prevents the child window from the panel being repainted - hence you have 4 nice black rectangles on your window.
Everything is in the wxWidgets doc. You should read them.
Regards,
Sebastien
--- End quote ---
You Sir are a star!
I installed code::blocks on Ubuntu, got a helloworld app going with wxsmith. Setup code::blocks for cross compile for win32 using mingw32 (which I must say is not easy to do for a newbie).
Compiled my program for win32, and was seeing 100% cpu usage using wine and also on native Windows.
For anyone else who is using the wxsmith helloworld tutorial, I commented out the following line:
//Panel1->Connect(wxEVT_PAINT,(wxObjectEventFunction)&HelloApp2Frame::OnPanel1Paint,0,this);
Located in Main.cpp
Further down, I commented out the following block of code:
//void HelloApp2Frame::OnPanel1Paint(wxPaintEvent& event)
//{
// wxPaintDC dc(this);
//}
Many thanks to the original poster for asking the question and for Sebastien who correctly identified how this issue presents itsself in Windows.
The only issue now is every time I change by frame/panel, the first line above is uncommented and I have to re-comment it before compiling.
Why am I posting? Just in case it helps someone else resolve the same issue...........
Navigation
[0] Message Index
[*] Previous page
Go to full version