0

I am trying to add label to wxStaticBitmap, but it is not appearing in the panel. Here is my code.

bitmap_file_name = _U("numbertwo.png");
wxBitmap Featurebitmap((bitmap_path + bitmap_file_name), wxBITMAP_TYPE_PNG);
wxStaticBitmap *pFeature = new wxStaticBitmap(this, -1, Featurebitmap, wxDefaultPosition, wxDefaultSize, wxALIGN_BOTTOM, wxT("Feature Label - text"));
pFeature->SetCursor(wxCursor(wxCURSOR_HAND));
badai shaibaz
  • 47
  • 1
  • 7

2 Answers2

0

wxStaticBitmap shows only a bitmap, it doesn't support text label. You have many choices to show a label if you need it:

  1. Simplest: use a separate wxStaticText control.
  2. Modify the bitmap itself to draw a label over it.
  3. What you probably need as it looks like your control is supposed to be used, and not just be "static": use wxButton, which can show both a label and a bitmap.
VZ.
  • 21,740
  • 3
  • 39
  • 42
  • I tried to use wxButton, but it is not transparent like in the bitmap. I used the wxTRANSPARENT_WINDOW | wxBORDER_NONE flags but still button is not transparent. – badai shaibaz Apr 16 '21 at 13:39
  • Yes, buttons are not transparent. They are like all the other buttons on the system you're using right now, which are not transparent neither. – VZ. Apr 16 '21 at 15:42
0

@badaishaibaz

You didn't mention you want the transparent bitmap.

Anyway, what you can do is to create a transparent wxPanel, put both wxBitmap and wxStaticText on it and use that panel.

As Vadim pointed out - you can't do what you want the way you want it.

Igor
  • 5,620
  • 11
  • 51
  • 103