2011-07-01 7 views
4

Windows XPシステムをシャットダウンすると、背景がグレースケールにフェードする間にモーダルダイアログボックスが表示されます。私は、タグリストのどのプログラミング言語でも同じ効果を達成したいと考えています。誰も助けることができますか?モーダルダイアログが表示されている間に背景をフェードします

+0

、あなたのアプリケーションの背景、または画面全体を意味していますか? –

+0

私のアプリケーションですが、画面全体で実行できる場合は感謝します。 – afaolek

答えて

6

これはWinformsで行うのが簡単です。あなたはタイマーで不透明度を変更する灰色の背景を持つボーダレスな最大化ウィンドウが必要です。フェードが完了すると、境界線のないダイアログを表示し、TransparencyKeyを使用して背景を透明にします。ここでは、これを実装するサンプルメインフォームです:

public partial class Form1 : Form { 
    public Form1() { 
     InitializeComponent(); 
     this.FormBorderStyle = FormBorderStyle.None; 
     this.WindowState = FormWindowState.Maximized; 
     this.BackColor = Color.FromArgb(50, 50, 50); 
     this.Opacity = 0; 
     fadeTimer = new Timer { Interval = 15, Enabled = true }; 
     fadeTimer.Tick += new EventHandler(fadeTimer_Tick); 
    } 

    void fadeTimer_Tick(object sender, EventArgs e) { 
     this.Opacity += 0.02; 
     if (this.Opacity >= 0.70) { 
      fadeTimer.Enabled = false; 
      // Fade done, display the overlay 
      using (var overlay = new Form2()) { 
       overlay.ShowDialog(this); 
       this.Close(); 
      } 
     } 
    } 
    Timer fadeTimer; 
} 

やダイアログ:

public partial class Form2 : Form { 
    public Form2() { 
     InitializeComponent(); 
     FormBorderStyle = FormBorderStyle.None; 
     this.TransparencyKey = this.BackColor = Color.Fuchsia; 
     this.StartPosition = FormStartPosition.Manual; 
    } 
    protected override void OnLoad(EventArgs e) { 
     base.OnLoad(e); 
     this.Location = new Point((this.Owner.Width - this.Width)/2, (this.Owner.Height - this.Height)/2); 
    } 
    private void button1_Click(object sender, EventArgs e) { 
     this.DialogResult = DialogResult.OK; 
    } 
} 
関連する問題