Following article explains how to use inbuilt VS animated icon in the status bar.
https://msdn.microsoft.com/en-us/library/bb166795.aspx
I would like to know, is there a way to include custom gif animation inside the status bar.
Bitmap image can be included like following.
When I point a gif image according to above example, animation is not happening. Please help.
There isn't any way to use a gif animation image directly as far as I know.
Just as the IVsStatusbar.Animation method mentioned:
[in] If the VARIANT is a VT_I2, it refers to the SBAI_Index of predefined animated icons. If this parameter is a VT_I4, it refers to an HBITMAP containing the filmstrip image for animation, whose width should be a multiple of its height.
You can convert your gif file to a BMP image whose width is a multiple of its height by copy and paste every frame of the gif image in the BMP file and then use the code provided in the second link you referred to.
For example, here is a BMP image I created which contains 5 frames for animation:
Save this image as a BMP file, use the code in the second link and debug it:
private void MenuItemCallback(object sender, EventArgs e)
{
IVsStatusbar statusBar = (IVsStatusbar)ServiceProvider.GetService(typeof(SVsStatusbar));
Bitmap b = new Bitmap(@"D:\ani.bmp");
IntPtr hdc = IntPtr.Zero;
hdc = b.GetHbitmap();
object hdcObject = (object)hdc;
statusBar.Animation(1, ref hdcObject);
System.Windows.Forms.MessageBox.Show("Click OK to end status bar animation.");
statusBar.Animation(0, ref hdcObject);
DeleteObject(hdc);
}
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);