본문 바로가기

프로그램/Vb.net

Vb.net - NotifyIcon

 

NotifyIcon

 
NotifyIcon은 Windows 작업 표시줄의 알림 영역에 아이콘을 표시하는 방법을 제공하는 Windows Forms(WinForms) 응용 프로그램의 컨트롤입니다. 
NotifyIcon을 사용하면 알림, 상태 업데이트 또는 상황에 맞는 정보를 사용자에게 표시할 수 있습니다.
 
 
이 예제에서는 NotifyIcon 컨트롤을 만들고 양식의 Load 이벤트에서 해당 Icon, Text 및 Visible 속성을 설정합니다. 양식이 닫히면 Visible을 False로 설정하여 알림 영역에서 아이콘을 제거합니다. 마지막으로 Click 이벤트를 처리하여 사용자가 알림 영역의 아이콘을 한 번 클릭할 때 Form을 정상 상태로 복원합니다.
 

Source code

  
Imports System.Windows.Forms

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        NotifyIcon1.Icon = Me.Icon
        NotifyIcon1.Text = "NotifyIcon 예제"
        NotifyIcon1.Visible = True
    End Sub

    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        e.Cancel = True
        Me.Visible = False
    End Sub

    Private Sub NotifyIcon1_Click_1(sender As Object, e As EventArgs) Handles NotifyIcon1.Click
        Me.WindowState = FormWindowState.Normal
        Me.Visible = True
    End Sub
End Class