Page 1 of 1

How to draw a image in wxStatusBar?

Posted: Fri Apr 17, 2009 12:47 am
by eastbear
How to draw a image in wxStatusBar?

Posted: Fri Apr 17, 2009 4:32 am
by protocol
Find the position of the wxStatusBar.

Then use wxDC on the wxWindow.

Or override the paint event of the window and draw the wxImage to the graphic context.

regards.

Posted: Fri Apr 17, 2009 6:40 am
by tan
Hi,
another way - use wxStaticBitmap inside status bar. Anything like this:

Code: Select all

// in the frame ctor
    m_bitmap_status = 0;
...
    wxStatusBar *sbar = CreateStatusBar(3, wxST_SIZEGRIP);
    int widths[] = {-1, 200, 220};
    sbar->SetStatusWidths(3, widths);
    m_bitmap_status = new wxStaticBitmap(sbar, -1, wxBITMAP(IDC_BMP_ERROR));
...

// OnSize event handler
{
    wxStatusBar* sbar = GetStatusBar();
    if( sbar && m_bitmap_status )
    {
        wxRect r;
        sbar->GetFieldRect(2, r);
        m_bitmap_status->Move(r.x+r.width, r.y+(r.height-16)/2);
    }
    ev.Skip();
}

Posted: Fri Apr 17, 2009 10:19 am
by eastbear
Great! thank you very much!