Search code examples
vb.nettaskbar

Taskbar icon won't show when I have a fade in feature in my form


I've created a notification bar on a form and basically have it exactly how I need it... Except, when I put a fade in feature, the taskbar icon doesn't show up. To my application, it's necessary, because the taskbar icon flashes orange when a notification is shown. I've checked the obvious such as: my ShowInTaskbar property = true, and the correct icon is selected in the application properties.

I wanted to know if anyone knows why this would happen, and if there is a way around this where I can keep the fade in effect of the form.

I've included the form code. It's lines 13, 20 and 27-31 that activate the fade in.

Imports System.Data.SqlClient
Imports system.runtime.interopservices

public class form10

<DllImport("user32.dll", EntryPoint:="FlashWindow")>
Public Shared Function FlashWindow(ByVal hwnd As Integer, ByVal bInvert As Integer) As Integer
End Function

Private Sub Form10_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    ' sets form to bottom right of page 
    Me.Location = New Point(Screen.PrimaryScreen.WorkingArea.Width - 381, Screen.PrimaryScreen.WorkingArea.Height - 131)
    Me.Opacity = 0.1

    With Timer1
        .Interval = 300
        .Enabled = True
        .Start()
    End With

    Timer2.Start()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    FlashWindow(Me.Handle, 1)
End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
    If Me.Opacity < 1.0 Then
        Me.Opacity = Me.Opacity + 0.1
    End If
End Sub

Solution

  • I've fixed it by stopping the timer and adding this code to the Private sub Timer2_Tick

    If Me.Opacity = 1 Then Timer2.Stop() End If
    

    Also taking off the TopMost property and adding me.TopMost = True code to the load sub fully corrected my issue.