Home > MFC > Embedding progressbar in a statusbar!

Embedding progressbar in a statusbar!

Recently one user asked in a forum about how to embed a progress bar in a status bar! So basically what everybody should realize is that these are after all just windows! This means one window can go into another window, there is no limitation on this feature! Limitation is how you code and what are your requirements!

Is there a ready made function, yes there is as always with me! This is taken from my process viewer application…

void CProcessViewerDlg::SetUpProgressBar( CStatusBar* pStatusBar, CProgressBar* pPrgCtrl )
{
    // Validate parameter
    if( !pStatusBar||
        !pPrgCtrl ||
        !pStatusBar.GetSafeHwnd() ||
        !pPrgCtrl.GetSafeHwnd() )
    {
        return;
    }

    // Change parent of progress bar to status bar
    pPrgCtrl->SetParent( pStatusBar );

    // Set up progressbar in the first pane
    CRect crPaneRect;
    pStatusBar->GetStatusBarCtrl().GetRect( 1, &crPaneRect );

    // Adjust rectangle, deflate a bit
    crPaneRect.DeflateRect( 0, 2, 2, 2 );

    // Move progress rectangle into position, i.e. into first pane of statusbar
    pPrgCtrl->MoveWindow( crPaneRect );
}// End SetUpProgressBar
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: