Page 1 of 1

wxBitmapButton with text

Posted: Wed May 09, 2007 5:01 am
by jkbagain
How could I load a text in the wxBitmapButton for i am having a problem on how to put a text value like "enter" or "submit" on top of the image in the button...

Thanks in advanced..............

Posted: Wed May 09, 2007 5:06 am
by Lloyd
There is no control for this. You have to make your own!

see these threads

http://forums.wxwidgets.org/viewtopic.php?t=5172

http://forums.wxwidgets.org/viewtopic.php?t=13137

Posted: Wed May 09, 2007 5:08 am
by megabyte
Draw your text on a bitmap using wxMemoryDC. In the controls sample you will find a complete code. It looks like

Code: Select all

    wxBitmap bitmap( 100, 100 );
    wxMemoryDC dc;
    dc.SelectObject( bitmap );
    dc.SetBackground(*wxGREEN);
    dc.SetPen(*wxRED_PEN);
    dc.Clear();
    dc.DrawEllipse(5, 5, 90, 90);
    dc.DrawText(_T("Bitmap"), 30, 40);
    dc.SelectObject( wxNullBitmap );

    (void)new wxBitmapButton(panel, ID_BITMAP_BTN, bitmap, wxPoint(100, 20));
Edit: Use wxDC::DrawBitmap to draw your own bitmap on the wxMemoryDC's bitmap.

Posted: Wed May 09, 2007 9:19 am
by lowjoel
You should never be using Bitmap Buttons with labels, especially if they do not add meaning to the buttons.

See the Vista UX guidelines: http://msdn.microsoft.com/library/defau ... e/home.asp

Joel

thanks...

Posted: Thu May 10, 2007 3:12 am
by jkbagain
thanks to both of u.....thank so much.....