Drawing on a transparent Fullscreen Dialog

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
Sickboy
Experienced Solver
Experienced Solver
Posts: 91
Joined: Wed Mar 16, 2005 10:30 pm
Location: Germany

Drawing on a transparent Fullscreen Dialog

Post by Sickboy » Wed Mar 05, 2008 8:58 am

I have created a wxDialog and use SetFullscreen(true) and SetTransparent(0), to make a transparent fullscreen window.
Now i try to draw a rectangle on it.

<code>
void myClass::OnPaint(wxPaintEvent &event)
{
wxPaintDC dc(this);
wxBrush brush(255,0,0),
dc.SetBrush(brush);
dc.DrawRectangle(0,0,400,400);
}
</code>

But i can't see the rectangle. If i delete SetTransparent(0) the rectangle will be drawn correct but the background isn't transparent :-/

Any idea how to solve this problem ?

JimFairway
wxWorld Domination!
wxWorld Domination!
Posts: 1059
Joined: Sun Dec 30, 2007 6:40 pm
Location: Canada

Post by JimFairway » Wed Mar 05, 2008 10:24 am

If you're using Windows, you can catch the wxEraseEvent with an empty function( thanks to lvdlinden teaching me that one).

Code: Select all

void OnErase( wxEraseEvent &e )
{
    // do not clear background
}
Jim
OS: Vista SP1, wxWidgets 2.8.7.

Post Reply