Playing an AVI file in the status bar

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.

Comments
Compile under Visual C 5
Posted by Legacy on 09/08/2003 12:00amOriginally 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
ReplySolution for disappearance the animate control when window is Iconic
Posted by Legacy on 03/05/2003 12:00amOriginally 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;
Replythis->GetItemRect(1,&rc);
rc.InflateRect (-1,-1);
m_CtrlAnimate.MoveWindow (&rc,TRUE);
Download .AVI files
Posted by Legacy on 08/27/2000 12:00amOriginally 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,
ReplyAlex
Thankyou immensely
Posted by Legacy on 04/24/2000 12:00amOriginally posted by: Vince Buttigieg
Your code is invaluablscofrpioe ;-)
ReplyI 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
AVI got lost when the frame window is resized to a smaller size
Posted by Legacy on 04/07/2000 12:00amOriginally 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.
ReplyAVI animation in Status Window
Posted by Legacy on 01/18/2000 12:00amOriginally 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.
ReplyJohnny
Thanks
Posted by Legacy on 12/22/1999 12:00amOriginally posted by: Billy-Bob-Joe
Thanks a lot. I really needed that code.
ReplyThanks
Posted by Legacy on 12/22/1999 12:00amOriginally posted by: Billy-Bob-Joe
Thanks a lot. I really needed that code.
ReplyHow to play MPEG I / MPEG II file
Posted by Legacy on 08/29/1999 12:00amOriginally posted by: wfs
How to play MPEG I / MPEG II file
Reply