以下に、使用しているフレームワークのコードを示します。私が抱えている問題は、コメントされたコードが含まれていない限り、アイコンがシステムトレイに表示されないことです。最も奇妙な部分は、notifyicon1プロパティの他のコード行が機能することです。誰かが私が何が起こっているのか理解するのを手伝ってもらえますか?
Public Class Main
Public WithEvents notifyicon1 As New NotifyIcon
Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Width = 1200
Height = 850
ShowIcon = True
Me.Text = "V1.0.0.0"
' icon
Icon = My.Resources.icon_4
'set the form properties
BackColor = Color.White
Dim start As New startup()
End Sub
Private Sub Main_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
If Me.WindowState = FormWindowState.Minimized Then
notifyicon1.Visible = True
Me.Hide()
Icon = My.Resources.icon_4
notifyicon1.Visible = True
notifyicon1.BalloonTipText = "Hi from right system tray"
notifyicon1.ShowBalloonTip(500)
'With notifyicon1
' .Icon = My.Resources.icon_4
' .Visible = True
' .ShowBalloonTip(500)
'End With
End If
End Sub
Private Sub NotifyIcon1_DoubleClick(sender As Object, e As MouseEventArgs) Handles notifyicon1.DoubleClick
Me.Show()
Me.WindowState = FormWindowState.Normal
notifyicon1.Visible = False
End Sub
End Class
ハンスが指摘したように、notifyicon1のIconプロパティを設定する必要があります。これは、Withステートメントで行いますが、上記のコードでは行いません。
Iconプロパティをどこでも使用していないように見えるので、Icon = My.Resources.icon_4
withを変更notifyicon1.Icon = My.Resources.icon_4
します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加