Avoid assert failure in shaped sample

wxBG_STYLE_TRANSPARENT cannot be changed after creation
This commit is contained in:
Paul Cornett
2021-04-07 09:07:42 -07:00
parent 26bc2c015b
commit 4faf7d45de

View File

@@ -138,7 +138,6 @@ public:
private: private:
// event handlers (these functions should _not_ be virtual) // event handlers (these functions should _not_ be virtual)
void OnDoubleClick(wxMouseEvent& evt);
void OnPaint(wxPaintEvent& evt); void OnPaint(wxPaintEvent& evt);
// any class wishing to process wxWidgets events must use this macro // any class wishing to process wxWidgets events must use this macro
@@ -472,14 +471,13 @@ void ShapedFrame::OnPaint(wxPaintEvent& WXUNUSED(evt))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxBEGIN_EVENT_TABLE(SeeThroughFrame, wxFrame) wxBEGIN_EVENT_TABLE(SeeThroughFrame, wxFrame)
EVT_LEFT_DCLICK(SeeThroughFrame::OnDoubleClick)
EVT_PAINT(SeeThroughFrame::OnPaint) EVT_PAINT(SeeThroughFrame::OnPaint)
wxEND_EVENT_TABLE() wxEND_EVENT_TABLE()
void SeeThroughFrame::Create() void SeeThroughFrame::Create()
{ {
SetBackgroundStyle(wxBG_STYLE_TRANSPARENT); SetBackgroundStyle(wxBG_STYLE_TRANSPARENT);
wxFrame::Create(NULL, wxID_ANY, "Transparency test: double click here", wxFrame::Create(NULL, wxID_ANY, "Transparency test",
wxPoint(100, 30), wxSize(300, 300), wxPoint(100, 30), wxSize(300, 300),
wxDEFAULT_FRAME_STYLE | wxDEFAULT_FRAME_STYLE |
wxFULL_REPAINT_ON_RESIZE | wxFULL_REPAINT_ON_RESIZE |
@@ -517,13 +515,3 @@ void SeeThroughFrame::OnPaint(wxPaintEvent& WXUNUSED(evt))
} }
} }
} }
void SeeThroughFrame::OnDoubleClick(wxMouseEvent& WXUNUSED(evt))
{
SetBackgroundStyle(wxBG_STYLE_PAINT);
SetTransparent(255);
SetTitle("Opaque");
Refresh();
}