Note that there are some explanatory texts on larger screens.

plurals
  1. POTabControl flickering when changing the tab's icon
    primarykey
    data
    text
    <p>About to lose my mind here. I've been googling for an hour trying to solve this minor, but incredibly aggravating problem.</p> <p>I have a <code>TabControl</code> on my form with two tabs. Each of those tabs has a 16x16 icon and some text. Nothing crazy going on here.</p> <p>I need to make one of the tab icons blink under certain circumstances. So I created two images, <img src="https://i.stack.imgur.com/q1E2Y.png" alt="light_on.png"> and <img src="https://i.stack.imgur.com/G8oNf.png" alt="light_off.png"> and added them to the <code>ImageList</code> used by the <code>TabControl</code>. I set up a background timer that toggles between the two images to simulate a blinking icon. Works fine. </p> <p>However, it's causing all of the tab headers to redraw, which is making them flicker. </p> <p>The <code>TabControl</code> does not support double-buffering, no matter what you try to do.</p> <p>I've found people have some success taming flickering using this code:</p> <pre><code> Protected Overrides ReadOnly Property CreateParams() As CreateParams Get Dim cp As CreateParams = MyBase.CreateParams cp.ExStyle = cp.ExStyle Or &amp;H2000000 Return cp End Get End Property </code></pre> <p>That works, as in, it doesn't flicker... but the icons also don't visually change anymore unless the mouse cursor hovers over something that causes a redraw. </p> <p>Does anyone have any alternate solutions or tricks that might work? This is actually a pretty essential feature to the software.</p> <p>Skeleton code:</p> <pre><code>Public Class Form1 Dim BlinkTimer As Windows.Forms.Timer Dim BlinkToggler As Boolean = False Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load InitBlinker() End Sub Private Sub InitBlinker() BlinkTimer = New Windows.Forms.Timer AddHandler BlinkTimer.Tick, AddressOf Blinker_Tick With BlinkTimer .Enabled = True .Interval = 250 End With StartBlinker() End Sub Public Sub StartBlinker() SomeTabPage.ImageKey = "light_off.png" BlinkToggler = False BlinkTimer.Start() End Sub Public Sub StopBlinker() SomeTabPage.ImageKey = "light_off.png" BlinkToggler = False BlinkTimer.Stop() End Sub Private Sub Blinker_Tick() If BlinkToggler Then SomeTabPage.ImageKey = "light_on.png" Else SomeTabPage.ImageKey = "light_off.png" End If BlinkToggler = Not BlinkToggler End Sub End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload