Hi there I've seen (and used) this workaround to display animated icons in the ultra tab control http://news.infragistics.com/forums/p/7655/31087.aspx#31087 Works fine. I'm now trying to do the same thing but for TABS (forms) displayed in a WinTabbedMdi control. I tried porting the method, the image (gif) displays well but I cannot animate it; problem is that there is no such thing as a PAINT event on the MDI Tab manager. When I try to updateframes on the paint event of the underlying form, I works only when I hover my mouse over the TAB (i.e. each time I hover with my mouse of the tab, it updates one frame). Any idea how I could achieve this?? Thanks
It is actually not the Form which paints the tabs. There are controls added to the Form by teh UltraTabbedMdiManager of type MdiTabGroupControl which display the tabs. These are the controls whose Paint events must be handled. However, it appears the MdiTabGroupControl prevents the Paint event from being fired. I'm not sure whether this was intentional or not. It look like it may be a bug. The good news is we can still animate the gifs and usng another approach turns out to be easier than trying to hook the Paint events of those controls. We basically have to provide derived MdiTabGroupControl instances to display the tabs and this can be done by using a derived UltraTabbedMdiManager. The following code will work in a new Form with an UltraTabbedMdiManager. Make sure to hook up the event handlers for TabClosed on the Manager and Load on the Form. Then go into the designer code and change the type of the ultraTabbedMdiManager1 member variable to be of type MyTabbedMdiManager. You will also have to change the call to the contructor on the manager in the InitializeComponet code.
public partial class Form1 : Form{ public Form1() { InitializeComponent(); }
private void OnAnimateImage( object sender, EventArgs args ) { if ( this.IsHandleCreated && this.InvokeRequired ) { this.BeginInvoke( new EventHandler( this.OnAnimateImage ), (Image)sender ); } else { foreach ( Form childForm in this.MdiChildren ) { MdiTab tab = this.ultraTabbedMdiManager1.TabFromForm( childForm );
if ( tab.Settings.TabAppearance.Image != sender ) continue;
UIElement element = tab.UIElement;
if ( element != null ) element.Invalidate();
break; } } }
private void Form1_Load( object sender, EventArgs e ) { Form childForm = new Form(); childForm.Text = "Hello"; childForm.MdiParent = this; childForm.Show();
MdiTab tab = this.ultraTabbedMdiManager1.TabFromForm( childForm ); tab.Settings.TabAppearance.Image = Image.FromFile( "C:\\image.gif" );
ImageAnimator.Animate( (Image)tab.Settings.TabAppearance.Image, new EventHandler( this.OnAnimateImage ) ); }
private void ultraTabbedMdiManager1_TabClosed( object sender, MdiTabEventArgs e ) { ImageAnimator.StopAnimate( (Image)e.Tab.Settings.TabAppearance.Image, new EventHandler( this.OnAnimateImage ) ); }}
public class MyTabbedMdiManager : UltraTabbedMdiManager{ public MyTabbedMdiManager( IContainer container ) : base( container ) { }
protected override MdiTabGroupControl CreateMdiTabGroupControl( MdiTabGroup tabGroup ) { return new MyMdiTabGroupControl( tabGroup, this ); }
private class MyMdiTabGroupControl : MdiTabGroupControl { public MyMdiTabGroupControl( MdiTabGroup tabGroup, IUltraControl control ) : base( tabGroup, control ) { }
protected override void OnPaint( PaintEventArgs pe ) { base.OnPaint( pe ); ImageAnimator.UpdateFrames(); } }}
hi, how do you remove the animation when the child form finished loading?
thanks