Lars가 말한 것처럼 양식에 Opacity
속성이 있습니다.
양식이 비활성 상태 일 때 불투명도를 절반으로 설정하려면 Deactivated
또는 Application.Idle 이벤트를 처리해야합니다. 이 타이머를 시작하면 UI 스레드의 양식으로 메시지를 보내 실제로 값을 설정합니다. 당신이 점차적으로 다음 투명성을 확보 적은 양에 타이머 간격을 설정하는 형태를 원하는 경우
private void Form_Deactivate(object sender, EventArgs e)
{
this.inactiveTimer = new Timer();
this.inactiveTimer.Interval = 1000;
this.inactiveTimer.Tick += this.InactiveTimer_Tick;
// Start timer
this.inactiveTimer.Start();
}
private void InactiveTimer_Tick(object sender, EventArgs e)
{
// This is being handled on the UI thread
this.Opacity = 0.5;
this.inactiveTimer.Stop();
}
(100 밀리를 말한다) 및 각 눈금에 단계에 의해 투명성을 줄일 수 있습니다. 그런 다음 불투명도가 0.5에 도달하면 타이머를 정지시킵니다.
Activated
이벤트는 폼이 다시 활성화 될 때 시작됩니다 :
private void Form_Activate(object sender, EventArgs e)
{
this.Opacity = 1.0;
// Stop the timer for the cases where the user reactivates the app
this.inactiveTimer.Stop();
}
불투명도이 해고한다 (정확하게 1로 다시 설정되어 있는지 확인하기 위해 트랩에해야 할 수도 있습니다 SizeChanged
같은 다른 이벤트가 있습니다 양식이 최소화 된 상태로 복원 된 경우) 및 ResizeEnd
.