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.
bobmanc
Experienced Solver
Posts: 69 Joined: Mon Oct 04, 2004 9:27 pm
Post
by bobmanc » Sat Nov 14, 2009 8:48 pm
I am trying to change the background color of the parent frame by iverriding the EVT_ERASE_BACKGROUND event but it never gets triggered. Any ideas why?
I am using wx 2.8.10 on Win7.
Code: Select all
BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
EVT_ERASE_BACKGROUND(MyFrame::OnEraseBackground)
END_EVENT_TABLE()
...
void MyFrame::OnEraseBackground( wxEraseEvent& event )
{
//never called
}
illnatured
Filthy Rich wx Solver
Posts: 234 Joined: Mon May 08, 2006 12:31 pm
Location: Krakow, Poland
Post
by illnatured » Sat Nov 14, 2009 9:39 pm
You can paint a filled rectangle instead.
VC++ 2005 / Windows XP / wxWidgets 2.8.9
JimFairway
wxWorld Domination!
Posts: 1059 Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada
Post
by JimFairway » Sat Nov 14, 2009 10:34 pm
Hi,
Not sure either, but you could just use wxMDIParentFrame::SetBackgroundColour
Hope that helps,
Jim
OS: Vista SP1, wxWidgets 2.8.7.
bobmanc
Experienced Solver
Posts: 69 Joined: Mon Oct 04, 2004 9:27 pm
Post
by bobmanc » Sat Nov 14, 2009 10:49 pm
How can I paint a rectangle if i can't get the erase event to fire?
setBackground doesn't do anything that is why i was trying to override the erase event.
JimFairway
wxWorld Domination!
Posts: 1059 Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada
Post
by JimFairway » Sun Nov 15, 2009 12:15 am
OS: Vista SP1, wxWidgets 2.8.7.
bobmanc
Experienced Solver
Posts: 69 Joined: Mon Oct 04, 2004 9:27 pm
Post
by bobmanc » Sun Nov 15, 2009 5:13 am
Sorry Jim,
That doesn't work either.
illnatured
Filthy Rich wx Solver
Posts: 234 Joined: Mon May 08, 2006 12:31 pm
Location: Krakow, Poland
Post
by illnatured » Sun Nov 15, 2009 9:29 am
bobmanc wrote: How can I paint a rectangle if i can't get the erase event to fire?
Okay, this won't work, but there's another solution. You can create an empty panel and resize it to whole client area of the MDI parent frame.
VC++ 2005 / Windows XP / wxWidgets 2.8.9
bobmanc
Experienced Solver
Posts: 69 Joined: Mon Oct 04, 2004 9:27 pm
Post
by bobmanc » Sun Nov 15, 2009 2:11 pm
I think I have the solution.
You need to override the OnCreateClient call on your version of wxMDIParentFrame. You then have to override wxMDIClientWindow that has its own OnEraseBackground method. This will get called.