Page 1 of 1


Posted: Mon May 09, 2005 5:36 am
by KaReL
I have my own control (derived from wxControl).
(a menubar for a panel).

On this, I add a few wxString's. I calculate the total width/height of the control.

Now I got the following functions overridden:
- DoGetSize
- DoGetClientSize ( used by DC.GetSize() )
- DoGetBestSize ( used by sizer-calculations )

But now when I want to erase the background, I do like this:

Code: Select all

void MenuBar_Control::OnEraseBackground( wxEraseEvent& WXUNUSED(event) ) 
wxClientDC clientDC(this); 

   clientDC.SetBrush( wxBrush(wxColour(0xff,0,0)) ); 
   clientDC.DrawRectangle( 0,0, clientDC.GetSize().GetWidth(), clientDC.GetSize().GetHeight() ); 

This draws a background of 20x20 pixels. Although clientDC.GetSize() returns a wxSize(199, 52).

What am I missing here?

Thanks for any help.

Posted: Mon May 09, 2005 5:57 am
by Cursor
First, when you erase a background, you must not create a wxClient/PaintDC, you must use one provided by the wxEraseEvent param [1].

Secondly, if you want to erase the entire content of the client surface, wxDC::Clear is usefull [2].

[1] : ... eraseevent
[2] : ... #wxdcclear

Posted: Mon May 09, 2005 7:54 am
by Jorg
Karel, please do not xpost, wait a couple of days if your post does not get answered on the wx-users list .. the weekends is usually low activity on either forum or board ;-)

- Jorgen

Posted: Mon May 09, 2005 8:11 am
by KaReL
Jorg: :oops:

Cursor: This has the same reaction. The DC associated with the wxEraseEvent parameter is wxScreenDC (I mean, it has the same dimensions as my screen).
Cursor: Also this I know, but also this has no result... The painted area stays 20x20...

It seems like somewhere the clippingregion is set to 20x20, but the wxDC attached to the wxEraseEvent-param is 1280x1024 (and nowhere, there is a clipping region set, I followed every trace of it)... So I would suspect it to draw my complete screen, but it is not drawing on there. Only on a 20x20 restricted area.

I remember reading something about this 20x20 area, but I don't remember exactly where...

Posted: Mon May 09, 2005 8:21 am
by Jorg
At least it does me well to see that the forum has a very high succesrate in helping people.. that is one thing I disliked about the mailinglist. A lot of questions stay unanswered. I think the reason for that is when people are gone from their pc for a couple of days, the articles keep flowing in and get 'snowed under' when they are coming back.

- Jorgen