Reputation: 6638
I have a MainFrame which is derived from wxFrame
. The frame has a panel member m_panel
of a custom class, derived from wxPanel
.
I overloaded the OnPaint()
function of the MainFrame to set a background image.
From the background image I only see a 5 pixel boarder. The rest is blocked by the wxPanel. And for some reason I cannot make the panel transparent. I tried m_panel->Hide()
which had no effect at all and m_panel->SetBackgroundStyle(wxBG_STYLE_CUSTOM)
. The latter had the weird effect that I could see the desktop (however the background image was still visible in the 5px border).
I did add the wxTRANSPARENT_WINDOW
style in the constructor of the wxPanel
.
How can I have this panel and make it transparent?
Upvotes: 0
Views: 573
Reputation: 1806
Have a custom wxPanel
where you override OnPaint
to have your drawings. Then use this as the main panel of your wxFrame
. Example shown below:
class BackgroundPanel: public wxPanel
{
public:
BackgroundPanel(wxFrame* parent);
void OnPaint(wxPaintEvent & evt);
private:
wxBitmap backgroundBitmap;
DECLARE_EVENT_TABLE()
};
BackgroundPanel::BackgroundPanel(wxFrame* parent)
:wxPanel(parent)
{
//Set backgroundBitmap
}
void BackgroundPanel::OnPaint(wxPaintEvent& evt)
{
wxPaintDC dc(this);
int height = GetClientRect().GetHeight() - backgroundBitmap.GetHeight();
dc.DrawBitmap(backgroundBitmap,0,height,false);
}
Upvotes: 1