How to add label / text to wxStaticBitmap?

208 views Asked by At

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));
2

There are 2 answers

2
VZ. On BEST ANSWER

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.
0
Igor On

@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.