Playing an AVI file in the status bar

Sample Image

Environment: VC6 SP2, NT4, 9x

During some long data processing, it is useful to let the user know that "something is happening, honest!" Many programs (such as Outlook Express) do this by the neat trick of showing an animation within one of the status bar panes. This article shows how this can be achieved by embedding an animation control.

The demo program allows a simple animation to be switched on or off from the View menu.

To add status bar animation takes the following steps:

1. Add the files RJLStatusBar.cpp and .h and StatusbarAnimate.cpp and .h to your project.

2. Add a CStatusbarAnimate* member in your CMainFrame class; change the CStatusBar member to be of the class CRJLStatusBar.

3. Add a suitable AVI resource to your resource file (you need some form of AVI editor to create this--I used Corel Photo-Paint 8). The AVI is drawn transparently, with the upper left pixel being the transparency color. Make sure that the status bar pane that will display this is large enough (controlled by the length of the text associated with the pane ID).

4. Add the following code to CMainFrame:



CMainFrame::CMainFrame()
{
	m_pAnimate = NULL;
}

CMainFrame::~CMainFrame()
{
	StopAnimation();
}

void CMainFrame::StartAnimation( UINT id, int nPane /*=1*/ )
{
	StopAnimation();

	m_pAnimate = new CStatusbarAnimate;
	m_pAnimate->Create(id, nPane);
}

void CMainFrame::StopAnimation()
{
	delete m_pAnimate;
	m_pAnimate = NULL;
}

bool CMainFrame::IsAnimationActive()
{
	return (m_pAnimate != NULL);
}

// needed to ensure original text not visible
void CMainFrame::OnUpdateAnimate(CCmdUI* pCmdUI) 
{
	pCmdUI->SetText(_T(""));
}

Now to start the animation just call StartAnimation and to stop it call StopAnimation.

Downloads

Download demo project - 34 Kb


Comments

  • Compile under Visual C 5

    Posted by Legacy on 09/08/2003 12:00am

    Originally posted by: Skippy

    Get this to compile under visual c 5, replace the following:

    if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1; // fail to create
    }

    With:

    if (!m_wndToolBar.Create(this) ||
    !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
    {
    TRACE0("Failed to create toolbar\n");
    return -1;
    }

    If you need to compile on both, use:
    #if _MSC_VER > 1100
    // version 5
    #else
    // version 6
    #endif

    Reply
  • Solution for disappearance the animate control when window is Iconic

    Posted by Legacy on 03/05/2003 12:00am

    Originally posted by: Karthikeyan


    The reason for disappearance of the Animation when we minimize the window is that when we minimize the window, the status bar also changes in its size. but, we loaded the animate control on the status bar. So, its position also changes. So that it disappears. To avoid that we have to write the code in the status bar class's OnSize event like the following.

    CRect rc;
    this->GetItemRect(1,&rc);
    rc.InflateRect (-1,-1);
    m_CtrlAnimate.MoveWindow (&rc,TRUE);

    Reply
  • Download .AVI files

    Posted by Legacy on 08/27/2000 12:00am

    Originally posted by: Alex Marbus

    Hi,
    First of all, thanks for this great code you've written..!
    I was wondering if anyone knows a good resource where I can download AVI files, for example the ones that MS uses in Word while printing/loading/saving. I've searched almost the entire web, I think, but found none..
    So, if anyone knows a good resource, and wish to share it.. maybe he/she can post it here?

    Thx,
    Alex

    Reply
  • Thankyou immensely

    Posted by Legacy on 04/24/2000 12:00am

    Originally posted by: Vince Buttigieg

    Your code is invaluablscofrpioe ;-)
    I created an amination of my company's logo which I wanted to put in every program I write, but couldn't find a good spot to place it... the status bar is perfect and your code works great. You're a legend

    Reply
  • AVI got lost when the frame window is resized to a smaller size

    Posted by Legacy on 04/07/2000 12:00am

    Originally posted by: deT

    Drag the lower right conner of the frame and move it to the upper left. You will see that the animation disappears.

    Reply
  • AVI animation in Status Window

    Posted by Legacy on 01/18/2000 12:00am

    Originally posted by: Johnny

    That was slick. Where can a developer find an application (free) that could produce an animated file? I looked for Microsoft's AVIEdit at their site, but only found a simple "sample editor" which I could not understand.

    Thanks all.
    Johnny

    Reply
  • Thanks

    Posted by Legacy on 12/22/1999 12:00am

    Originally posted by: Billy-Bob-Joe

    Thanks a lot. I really needed that code.

    Reply
  • Thanks

    Posted by Legacy on 12/22/1999 12:00am

    Originally posted by: Billy-Bob-Joe

    Thanks a lot. I really needed that code.

    Reply
  • How to play MPEG I / MPEG II file

    Posted by Legacy on 08/29/1999 12:00am

    Originally posted by: wfs

    How to play MPEG I / MPEG II file

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • On-demand Event Event Date: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • As mobile devices have pushed their way into the enterprise, they have brought cloud apps along with them. This app explosion means account passwords are multiplying, which exposes corporate data and leads to help desk calls from frustrated users. This paper will discover how IT can improve user productivity, gain visibility and control over SaaS and mobile apps, and stop password sprawl. Download this white paper to learn: How you can leverage your existing AD to manage app access. Key capabilities to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds