wxMDIParentFrame never has EVT_ERASE_BACKGROUND 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
bobmanc
Experienced Solver
Experienced Solver
Posts: 69
Joined: Mon Oct 04, 2004 9:27 pm

wxMDIParentFrame never has EVT_ERASE_BACKGROUND event

Post by bobmanc »

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
Filthy Rich wx Solver
Posts: 234
Joined: Mon May 08, 2006 12:31 pm
Location: Krakow, Poland

Post by illnatured »

You can paint a filled rectangle instead.
VC++ 2005 / Windows XP / wxWidgets 2.8.9
JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway »

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
Experienced Solver
Posts: 69
Joined: Mon Oct 04, 2004 9:27 pm

Post by bobmanc »

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!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway »

Hi,

Check this entry on the wiki:
http://wiki.wxwidgets.org/FAQ#Why_are_b ... alog_boxes.


Jim
OS: Vista SP1, wxWidgets 2.8.7.
bobmanc
Experienced Solver
Experienced Solver
Posts: 69
Joined: Mon Oct 04, 2004 9:27 pm

Post by bobmanc »

Sorry Jim,
That doesn't work either.
illnatured
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 234
Joined: Mon May 08, 2006 12:31 pm
Location: Krakow, Poland

Post by illnatured »

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
Experienced Solver
Posts: 69
Joined: Mon Oct 04, 2004 9:27 pm

Post by bobmanc »

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.
Post Reply