Hi,
I am using to UltraTabControl 6.3. I want to blink the tab when query executed sucessfully. Here is the code. Exception occurs when control backcolor changes. Due to this red X appears on tabconrol.
private void BlinkTab() { try { if (UltraTab != null) { Monitor.Enter(UltraTab); { bool blnIsOriginal = true; while (!UltraTab.Selected && !this.IsDisposed) { try { if (blnIsOriginal) { UltraTab.Appearance.BackColor = System.Drawing.SystemColors.ActiveCaption; UltraTab.Appearance.BackColor2 = System.Drawing.SystemColors.GradientInactiveCaption; blnIsOriginal = false; Thread.Sleep(500); } else { blnIsOriginal = true; UltraTab.Appearance.BackColor = Color.Empty; UltraTab.Appearance.BackColor2 = Color.Empty; Thread.Sleep(500); } } catch (Exception ex) { Console.Write("Exception in blinking."); } } UltraTab.Appearance.BackColor = Color.Empty; } } } catch (Exception ex) { BlinkTab(); } finally { Monitor.Exit(UltraTab); } } private void BlinkEvent(UltraTab pulUltraTab) { _mUltraTab = pulUltraTab; Thread objThreadBlinkTab = new Thread(new ThreadStart(BlinkTab)); objThreadBlinkTab.Start(); }
But when I run the multiple queries and wait for minutes it is giving error object reference is not instance of that object on changing the color backcolor. I am having each tab in seperate object and this function is private.
Here is exception it changes every time
System.NullReferenceException occurred Message="Object reference not set to an instance of an object." Source="Infragistics2.Win.v6.3" StackTrace: at Infragistics.Win.UIElement.GetDescendant(Type type, Object[] contexts) at Infragistics.Win.UIElement.GetDescendant(Type type, Object context) at Infragistics.Win.UltraWinTabs.TabManager.GetUIElement(ITabItem tab) at Infragistics.Win.UltraWinTabs.TabManager.DirtyTabItem(ITabItem tab, Boolean invalidate, Boolean dirtyTextMetrics, Boolean dirtyImageMetrics) at Infragistics.Win.UltraWinTabControl.UltraTabsCollection.OnSubObjectPropChanged(PropChangeInfo propChangeInfo) at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger) at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId, PropChangeInfo trigger) at Infragistics.Win.UltraWinTabControl.UltraTab.OnSubObjectPropChanged(PropChangeInfo propChangeInfo) at Infragistics.Win.AppearanceHolder.OnSubObjectPropChanged(PropChangeInfo propChange) at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger) at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId) at Infragistics.Win.AppearanceData.set_BackColor2(Color value) at Infragistics.Win.Appearance.set_BackColor2(Color value) at Thomson.Financial.Framework.Data.MarketQA.MarketQAClient.BlinkTab() in D:\SVN\Branches\.....\..\Client.cs:line 1273System.NullReferenceException occurred Message="Object reference not set to an instance of an object." Source="Infragistics2.Win.UltraWinTabControl.v6.3" StackTrace: at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.get_StyleResolved() at Infragistics.Win.UltraWinTabControl.UltraTabControlBase.TabControlTabProvider.Infragistics.Win.UltraWinTabs.ITabProvider.get_Style() at Infragistics.Win.UltraWinTabs.TabManager.get_StyleResolved() at Infragistics.Win.UltraWinTabs.TabManager.get_InterTabSpacingResolved() at Infragistics.Win.UltraWinTabs.TabManager.InitializeFirstDisplayedTabItem(ITabItem tab, ScrollType scrollType, Int32 scrollIncrement, Boolean fireScrollEvents) at Infragistics.Win.UltraWinTabs.TabManager.VerifyFirstDisplayedTabItem() at Infragistics.Win.UltraWinTabs.TabManager.get_FirstDisplayedTabItem() at Infragistics.Win.UltraWinTabs.TabManager.IsTabItemInView(ITabItem tab, Boolean excludePartiallyInView) at Infragistics.Win.UltraWinTabs.TabManager.GetUIElement(ITabItem tab) at Infragistics.Win.UltraWinTabs.TabManager.DirtyTabItem(ITabItem tab, Boolean invalidate, Boolean dirtyTextMetrics, Boolean dirtyImageMetrics) at Infragistics.Win.UltraWinTabControl.UltraTabsCollection.OnSubObjectPropChanged(PropChangeInfo propChangeInfo) at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger) at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId, PropChangeInfo trigger) at Infragistics.Win.UltraWinTabControl.UltraTab.OnSubObjectPropChanged(PropChangeInfo propChangeInfo) at Infragistics.Win.AppearanceHolder.OnSubObjectPropChanged(PropChangeInfo propChange) at Infragistics.Shared.SubObjectBase.NotifyPropChange(PropChangeInfo trigger) at Infragistics.Shared.SubObjectBase.NotifyPropChange(Enum propId) at Infragistics.Win.AppearanceData.set_BackColor2(Color value) at Infragistics.Win.Appearance.set_BackColor2(Color value) at Thomson.Financial.Framework.Data.MarketQA.MarketQAClient.BlinkTab() in D:\SVN\Branches\.....\..\Client.cs: line 1273
I don't have NetAdvantage 6.3 on my computer to test, but using version 7.3 and setting UseOSThemes to False on the tab control, all of the tabs continued to blink for me even if I started typing in the textbox. It's possible that the latest hotfix for your version might address something indirectly related to this issue. The only issue that I noticed in your application is that the blinking of the tabs becomes out-of-sync, likely due to the fact that you're using different threads for each tab and they will not end up executing at the same time. You might want to consider using a single thread to handle blinking all of the tabs at the same time.
Unfortunately, animated GIFs are not supported ; only the first frame will be displayed. You might be able to animate the image yourself using a timer and updating the current frame of the image (which may require invalidating the tab). Take a look at this article on handling animated GIFs in C#.
-Matt
Thanks Matt,
Here is the sample application. When you will run this application you will find out all tabs are blinking.
Now start typing in first tab where already text available you will notice that tab blinking puases.
In tab image animated gif don't animate instead only image shows. Tell me how to animate the gif in tab controll.
As a general .NET practice, you *must* update any aspect of the UI on the main thread. You can run timers, perform calculations, or do any other work that doesn't affect the UI on another thread, but any calls that will change any aspect of the UI (even indirectly) must be done on the main thread. There is an article, UI Thread Marshaling in the Model Layer, that might help point out some of these aspects.
I'm not really sure why your code isn't working, since I'm not really sure how you're triggering the blinking to occur. If you attach a simple sample, I could take a quick look at it. You could also submit the sample to Developer Support.
Thanks for quick reply.I have applied as you suggested. Like this .. backgroundWorker_WorkCompleted( { objThreadBlinkTab = new Thread(new ThreadStart(BlinkTab)); objThreadBlinkTab.Start(); } private void BlinkTab() { try { bool blnIsOriginal = true; if (UltraTab != null) { while (!UltraTab.Selected && !this.IsDisposed) { if (blnIsOriginal) { DelBlinkTab delegateApply = new DelBlinkTab(ChangeTabColor); this.Invoke(delegateApply); blnIsOriginal = false; Thread.Sleep(500); delegateApply = null; } else { blnIsOriginal = true; DelBlinkTab delegateRestore = new DelBlinkTab(RestoreTabColor); this.Invoke(delegateRestore); Thread.Sleep(500); delegateRestore = null; } UltraTab.Appearance.BackColor = Color.Empty; } } } private void ChangeTabColor() { UltraTab.Appearance.BackColor = System.Drawing.SystemColors.ActiveCaption; UltraTab.Appearance.BackColor2 = System.Drawing.SystemColors.GradientInactiveCaption; } private void RestoreTabColor() { UltraTab.Appearance.BackColor = Color.Empty; UltraTab.Appearance.BackColor2 = Color.Empty; }But now another problem I am using ultratabmousemove event whenever I move mouse on tab, it pauses blinking until mouse is in moving state. Because changing of color and mouse move event activity are on the Main UI's thread that's why it pauses tab blinking. Other than mouse move if I want to change any thing in application or try to repaint the control same is happening, that is it stops the blinking unless I stop using or doing something on the application.Is there anything we can do to blink the tabs (other than the selected tab) without using the main thread?
It seems like you're updating the tab on a thread outside of the UI thread. This is not a safe thing to do in .NET, since you could cause sync issues like the one here. What you should do is invoke the calls that update the Appearance back to the main UI Thread in order to perform the update.