EVT_ERASE_BACKGROUND,
wxEraseEvent::GetDC()->GetSize() and "no way to retrieve the size of
generic DC" [wxMSW 2.7.0]
Volker Bartheld
dr_versaeg at freenet.de
Tue Sep 26 09:18:53 PDT 2006
Hi!
I use the EVT_ERASE_BACKGROUND to draw a custom background (a tiled
wxBitmap, see below [1]) for my dialog. With wxMSW2.6.3, this worked
fine, now I get the "no way to retrieve the size of generic DC"
assertion in the DEBUG build.
Is that the intended behaviour, should I rather use
EVT_PAINT/wxPaintEvent for drawing a background and will this also work
on wxLIN/wxMAC if I want transparent wxPanels ontop of a wxDialog with
custom backgound [2]? Especially wxLIN with GTK+ seemed to have problems
with those, so I needed a work-around.
Thanks for insights,
Volker
[1]
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
EVT_ERASE_BACKGROUND(MyDialog::OnEraseBackground)
END_EVENT_TABLE()
void MyDialog::OnEraseBackground(wxEraseEvent& event)
{
wxDC* pDc=event.GetDC();
if(!m_pBackgroundBitmap->Ok()) return;
const wxSize DcSize=pDc->GetSize();
wxSize BmpSize(m_pBackgroundBitmap->GetWidth(), m_pBackgroundBitmap->GetHeight());
for(wxCoord x=0x; x<DcSize.x; x+=BmpSize.x)
for(wxCoord y=0; y<DcSize.y; y+=BmpSize.y)
pDc->DrawBitmap(*m_pBackgroundBitmap, x, y, true);
}
[2] I was implementing EVT_ERASE_BACKGROUND in my panel featuring the
transparent background which was calling a custom DrawBackground()
function in it's parent class, passing wxEraseEvent::GetDC(). The parent
class' (has wxBG_STYLE_CUSTOM set) DrawBackground() function is more or
less drawing wxBitmap tiles into the wxDC extracted from the event.
__
Mail replies to/an V B A R T H E L D at G M X dot D E
More information about the wx-users
mailing list