How to draw a image in wxStatusBar? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
eastbear
Knows some wx things
Knows some wx things
Posts: 38
Joined: Sat Dec 13, 2008 6:46 am

How to draw a image in wxStatusBar?

Post by eastbear » Fri Apr 17, 2009 12:47 am

How to draw a image in wxStatusBar?

protocol
Moderator
Moderator
Posts: 680
Joined: Wed Jan 18, 2006 6:13 pm
Location: Dallas, TX
Contact:

Post by protocol » Fri Apr 17, 2009 4:32 am

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.
/* UIKit && wxWidgets 2.8 && Cocoa && .Net */
QuRegExmm
wxPCRE & ObjPCRE - Regex It!

tan
Moderator
Moderator
Posts: 1471
Joined: Tue Nov 14, 2006 7:58 am
Location: Saint-Petersburg, Russia

Post by tan » Fri Apr 17, 2009 6:40 am

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();
}
OS: Windows XP Pro
Compiler: MSVC++ 7.1
wxWidgets: 2.8.10

eastbear
Knows some wx things
Knows some wx things
Posts: 38
Joined: Sat Dec 13, 2008 6:46 am

Post by eastbear » Fri Apr 17, 2009 10:19 am

Great! thank you very much!

Post Reply