c++user-interfacebitmapwxwidgetswxtextctrl

How to add label / text to wxStaticBitmap?


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

Solution

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