I’m trying to create a simple wxButton
button which do have semi-transparent background. There is thy code I’m using:
...
m_sizer = new wxBoxSizer(wxVERTICAL);
m_pngLoader = new wxPNGHandler();
wxImage::AddHandler(m_pngLoader);
m_BgBitmap = wxBitmap("...\img1.png", wxBITMAP_TYPE_PNG);
/*wxStaticBitmap* image = new wxStaticBitmap(this, wxID_ANY,
m_BgBitmap,
wxPoint(100, 100),
wxSize(m_BgBitmap.GetWidth(), m_BgBitmap.GetHeight()));
image->SetSize(wxSize(20, 20));*/
theBtn = new wxButton(this, 788, "wxEmptyString", wxPoint(200, 90), wxSize(200,200), wxTRANSPARENT_WINDOW | wxBORDER_NONE);
theBtn->SetBackgroundColour(wxColor(40, 0, 0));
theBtn->SetSize(wxSize(20, 20));
theBtn->SetBitmap(m_BgBitmap);
m_sizer->Add(theBtn);
this->SetSizer(m_sizer);
...
The problem is that the alpha channel seems to be totally ignored because the transparent background is still rendered like on the:
.
What I’m doing wrong? How can I make it to get it to work?
P.S.
When i use the wxStaticBitmap:
...
m_sizer = new wxBoxSizer(wxVERTICAL);
m_pngLoader = new wxPNGHandler();
wxImage::AddHandler(m_pngLoader);
m_BgBitmap = wxBitmap("D:\Pobrane_2\img1.png", wxBITMAP_TYPE_PNG);
wxStaticBitmap* image = new wxStaticBitmap(this, wxID_ANY,
m_BgBitmap,
wxPoint(100, 100),
wxSize(m_BgBitmap.GetWidth(), m_BgBitmap.GetHeight()));
image->SetSize(wxSize(20, 20));
/*theBtn = new wxButton(this, 788, "wxEmptyString", wxPoint(200, 90), wxSize(200,200), wxTRANSPARENT_WINDOW | wxBORDER_NONE);
theBtn->SetBackgroundColour(wxColor(40, 0, 0));
theBtn->SetSize(wxSize(20, 20));
theBtn->SetBitmap(m_BgBitmap);*/
m_sizer->Add(theBtn);
this->SetSizer(m_sizer);
...
everything do work:
i can see the frame background color through the transparent background image (there is only THE “S”, not THIS ******* background!).
1