+ return (WXHRGN)hrgn;
+}
+
+// helper for OnPaint()
+void wxStaticBox::PaintBackground(wxDC& dc, const RECT& rc)
+{
+ HBRUSH hbr = (HBRUSH)DoMSWControlColor(GetHdcOf(dc), wxNullColour);
+ if ( !hbr )
+ {
+ wxBrush *
+ brush = wxTheBrushList->FindOrCreateBrush(GetBackgroundColour());
+ if ( brush )
+ hbr = GetHbrushOf(*brush);
+ }
+
+ if ( hbr )
+ ::FillRect(GetHdcOf(dc), &rc, hbr);
+}
+
+void wxStaticBox::OnPaint(wxPaintEvent& WXUNUSED(event))
+{
+ wxPaintDC dc(this);
+ RECT rc;
+ ::GetClientRect(GetHwnd(), &rc);
+
+ // draw the entire box in a memory DC, but only blit the bits not redrawn
+ // either by our children windows nor by FillRect() painting the background
+ // below
+ wxMemoryDC memdc;
+ wxBitmap bitmap(rc.right, rc.bottom);
+ memdc.SelectObject(bitmap);
+
+ PaintBackground(memdc, rc);
+ MSWDefWindowProc(WM_PAINT, (WPARAM)GetHdcOf(memdc), 0);
+
+ int borderTop, border;
+ GetBordersForSizer(&borderTop, &border);
+
+ // top
+ dc.Blit(border, 0, rc.right - border, borderTop,
+ &memdc, border, 0);
+ // bottom
+ dc.Blit(border, rc.bottom - border, rc.right - border, rc.bottom,
+ &memdc, border, rc.bottom - border);
+ // left
+ dc.Blit(0, 0, border, rc.bottom,
+ &memdc, 0, 0);
+ // right
+ dc.Blit(rc.right - border, 0, rc.right, rc.bottom,
+ &memdc, rc.right - border, 0);
+
+ AutoHRGN hrgn((HRGN)MSWGetRegionWithoutChildren());
+ RECT rcWin;
+ ::GetWindowRect(GetHwnd(), &rcWin);
+ ::OffsetRgn(hrgn, -rcWin.left, -rcWin.top);
+
+
+ // now remove the box itself
+ MSWGetRegionWithoutSelf((WXHRGN) hrgn, rc.right, rc.bottom);
+
+ // and paint the inside of the box (excluding child controls)
+ ::SelectClipRgn(GetHdcOf(dc), hrgn);
+ PaintBackground(dc, rc);
+ ::SelectClipRgn(GetHdcOf(dc), NULL);