2010-05-25 6 views
4

가능한 중복 :
What's the proper way to minimize to tray a C# WinForms app?C# 백그라운드에서 실행되는 프로그램 만들기?

나는 백그라운드에서 실행 및 Windows ' "알림 영역"(날짜와 시간을 통해 액세스 할 수있는 프로그램을 만들 수있는 방법 오른쪽 하단에 있습니다)?

즉, 실행중인 프로그램을 만들고 디스플레이 창과 디스플레이 창을 가지지 않고 토글 할 수 있기를 원합니다.

+0

이 답을 점검해라. http://stackoverflow.com/questions/46918/whats-the-properway-to-minimize-to-tray-ac-winforms-app/47743#47743 관련 질문에서. –

답변

3
  1. NotifyIconContextMenuStrip을 드래그 앤 드롭하십시오. 것과
  2. 설정 드 NotifyIcon의 컨텍스트 메뉴 당신은
  3. (예, 출구 복원)
  4. 는 양식 이벤트 resize 설정이 메뉴 아이템을 추가하고 들어 다음과 같은 체크

    private void MyForm_Resize(object sender, EventArgs e) 
    { 
        if (this.WindowState == FormWindowState.Minimized) this.Hide(); 
        else this.Show(); 
    } 
    
    // you could also restore the window with a 
    // double click on the notify icon 
    private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) 
    { 
        this.Show(); 
        this.WindowState = FormWindowState.Normal; 
    } 
    

을 추가 예를 다운로드 할 수 있습니다 this project

오른쪽 클릭 이벤트에 대해 걱정하지 마십시오. NotifyIcon은 au 그것을 자동으로 감지하고 보여라. ContextMenu

관련 문제