2013-01-12 5 views
0

Windows 7의 작업 표시 줄 아이콘에 진행 막대를 추가하려고합니다 (Net 3.5). 이를 달성하기 위해 Windows API 코드 팩을 사용하고 있습니다.창이 사라진 후에도 작업 표시 줄 진행 막대가 표시되지 않습니다.

if (WindowStateInternal == FormWindowState.Normal) // the taskbar can only be set if the window is visible 
    { 
     TaskbarManager.Instance.SetProgressState(TaskbarProgressBarState.Normal); 
     TaskbarManager.Instance.SetProgressValue(100 - (int)PercentRemaining, 100); 
    } 

이 작업은 정상적으로 수행되지만 처음에는 창이 표시됩니다. 사용자는 트레이 아이콘이 존재할 때 제거 될 윈도우를 최소화 할 수 있습니다. 창이 다시 표시되면 진행률 표시 줄을 다시 켤 수 없습니다.

코드 실행 사용자가 최소화 된 윈도우 :

this.WindowState = FormWindowState.Minimized; 
    this.ShowInTaskbar = false; 
    this.Visible = false; // otherwise problem when windows starts up and program is in autostart 
    this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; // Hide from Task-List (Alt+Tab) 

그것은 정상으로 돌아 오는 경우 :

this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; // Show in Task-List (Alt+Tab) 
    this.Visible = true; 
    this.ShowInTaskbar = true; 
    this.WindowState = FormWindowState.Normal; 
    this.BringWindowToFront(); 

해제하고 진행 막대가 작동하지 않습니다에.

어떻게 progressBar를 다시 표시 할 수 있습니까?

+0

트레이에서 복원 된 창을 표시하는 코드 섹션에서 진행률 표시 줄의 진행 상태를 설정하는 데 사용한 코드를 삽입 해 보았습니까? (즉, 세 번째 코드 뒤에 첫 번째 코드 블록 삽입) –

+0

해당 코드는 매초마다 타이머에 의해 실행됩니다. 창 크기가 변경된 경우에만 다른 코드. –

답변

1

Appearly TaskbarManager에는 "this.ShowInTaskbar = false;"문제가 있습니다. 선. 창을 숨기면 작업 표시 줄도 숨겨지기 때문에 방금 제거했습니다. 그러나 "this.ShowInTaskbar = true;"를 유지해야합니다. 그냥 버그라고 생각합니다.