2010-12-01 6 views
-1

私が書いたシンプルな背景色変更プログラムで、視覚的なコントロールと色を使って遊んでいます。私はまた、黒で囲まれた黒い円のビットマップを作成し、黒を透明にすることによって、循環アプリケーションウィンドウを組み込むことを望んでいました。今私の背中の色はループしません。誰も私にこの問題を解決する方法を教えてもらえますか?病気の場合に備えて私のコードが含まれていますが、これはフォームプロパティの問題だと思います。助けてくれてありがとう!循環型アプリケーションで背景色が変化しない

public partial class Form1 : Form 
{ 
    public Form1() 
    { 
     InitializeComponent();  
    } 

    public Point mouse_offset; 
    public int c; 

    private void button1_Click(object sender, EventArgs e) 
    { 
     using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer()) 
     { 
      synth.Speak("This is a test of the emergency see sharp broadcasting network!"); 
      synth.Speak("The man to the left is actually trying to dance without graphics capabilities"); 

     } 
     while (Visible) 
     { 
      using (SpeechSynthesizer synth = new System.Speech.Synthesis.SpeechSynthesizer()) 
      { 
       synth.Speak("Flash dance commencing in three. two. one."); 
      } 
      while (Visible) 
      { 
       for (int c = 0; c < 255 && Visible; c++) 
       { 
        this.BackColor = Color.FromArgb(c, 255 - c, c); 
        Application.DoEvents(); 
        //slow(); 

       } 


       for (int c = 255; c > 0 && Visible; c--) 
       { 
        this.BackColor = Color.FromArgb(c, 255 - c, c); 
        Application.DoEvents(); 
        //slow(); 

       } 

      } 
     } 
    } 

    public static void slow() 
    { 
     System.Threading.Thread.Sleep(3); 
    } 

    private void button2_Click(object sender, EventArgs e) 
    { 
     this.Close(); 
    } 

    private void Form1_MouseDown(object sender, MouseEventArgs e) 
    { 
     mouse_offset = new Point(-e.X, -e.Y); 

    } 

    private void Form1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) 
    { 
     if (e.Button == MouseButtons.Left) 
     { 
      Point mousePos = Control.MousePosition; 
      mousePos.Offset(mouse_offset.X, mouse_offset.Y); 
      Location = mousePos; 
     } 
    } 


} 

}

+0

言語タグを追加する必要があります – Gerrat

答えて

0

あなたがコンポーネントの外観を変更し、この変更を表示したい持っているすべての時間は、

myComponent.Invalidate(); 

を呼び出すこれは、それ自体を再描画するconponentを強制します。ここにいるので、再描画を最適化する方法はいくつかありますが、上記のようにすれば開始することができます。

+0

ありがとうございます。私は助けに感謝します。病気を試してみてください。 –

関連する問題