코드 및 디자이너는 아래와 같습니다.. 디자이너에서 트레이 아이콘 설정을 해주면 완료!
+) 추가적으로 보이지 않지만 특정 위치에 파일 다이얼로그, 프린트 등 기능을 보여주기 위해서
위치 값을 조정할 때가 있습니다. WindowState 와 Visible 처리를 통해 해당 위치 제어가 가능!
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Tray : Form
{
public Tray()
{
InitializeComponent();
this.ShowInTaskbar = false; //하단 테스트바에서 보이지 않도록 설정
this.Visible = false; //화면에 보이지 않도록 설정
this.WindowState = FormWindowState.Minimized; //최소화
this.Opacity = 0; //투명하게 하여 타이틀도 안보이게 설정
this.FormBorderStyle = FormBorderStyle.FixedToolWindow; //Alt + Tab 에서도 보이지 않도록
//this.종료ToolStripMenuItem.Click += new System.EventHandler(this.종료ToolStripMenuItem_Click);
//잠시 특정 위치 활성화
this.WindowState = FormWindowState.Normal;
this.Visible = true;
//new OpenFileDialog().ShowDialog();
//다시 특정 위치 해제
this.WindowState = FormWindowState.Minimized;
this.Visible = false;
}
private void 종료ToolStripMenuItem_Click(object sender, System.EventArgs e)
{
Close();
}
}
}
notifyIcon 및 contextMenuStrip 을 설정해줍니다.
'C# > Windows Form' 카테고리의 다른 글
[C# Windows Form] Tray 아이콘 잔상 제거하기 (Win32 API 사용) (3) | 2025.07.29 |
---|---|
[C# Windows Form] Win32 API EnumWindows 를 사용한 프로그램 타이틀 가져오기 (웹 브라우저 따라다니기) (1) | 2025.07.28 |
[C# Window Forms] App.config, appsettings.json 파일 값 저장 (0) | 2025.06.25 |
[C# Windows Form] 32bit 프로그램 메모리 사용량 늘리기 (editbin.exe) (0) | 2025.05.29 |
[C# Windows Form] Form 앞에 다른 Form 을 항상 윗쪽에 위치 시키기 (Owner, + WPF 위에 Form 고정) (0) | 2025.04.11 |