+class ControlWithTransparency : public wxWindow
+{
+public:
+ ControlWithTransparency(wxWindow *parent,
+ const wxPoint& pos,
+ const wxSize& size)
+ : wxWindow(parent, wxID_ANY, pos, size, wxBORDER_NONE)
+ {
+ Connect(wxEVT_PAINT,
+ wxPaintEventHandler(ControlWithTransparency::OnPaint));
+ }
+
+ virtual bool HasTransparentBackground() { return true; }
+
+private:
+ void OnPaint( wxPaintEvent& WXUNUSED(event) )
+ {
+ wxPaintDC dc(this);
+
+ dc.SetPen(*wxRED_PEN);
+ dc.SetBrush(*wxTRANSPARENT_BRUSH);
+ dc.DrawRectangle(GetClientSize());
+
+ dc.SetTextForeground(*wxBLUE);
+ dc.SetBackgroundMode(wxTRANSPARENT);
+ dc.DrawText("This is custom control with transparency", 0, 2);
+ }
+};