2012-03-31 24 views
2

私は、選択領域内で完全に透明になる半透明の灰色のレイヤーで画面をオーバーレイする方法でWindows 7のスニッピングツールを模倣しようとしました。私はかなり近づいた。私は境界線のない50%の不透明な灰色のフォームを表示しています。このフォームは画面全体を覆い、TransparencyKey of Fuchsiaを持っています。そのフォームの上に2つの長方形を描きます。透明度のためのソリッドなフクシアの矩形と、赤いボーダーのための別の矩形。それは機能しますが、3つのうちの1つを行う場合にのみ、オプションのどれもありません。フォームに C#50%の不透明な形で描かれた透明な実線の矩形

不透明な100%を作る32ビット

  • から16bitのために
  • 変更デスクトップのカラーモードを描きながら、フォームのちらつきを作る

    1. 無効にダブルバッファリングは、ここに私のコードです。どのようにこれを動作させるための任意の提案?

      public partial class frmBackground : Form 
      { 
          Rectangle rect; 
      
          public frmBackground() 
          { 
           InitializeComponent(); 
      
           this.MouseDown += new MouseEventHandler(frmBackground_MouseDown); 
           this.MouseMove += new MouseEventHandler(frmBackground_MouseMove); 
           this.Paint += new PaintEventHandler(frmBackground_Paint); 
           this.DoubleBuffered = true; 
           this.Cursor = Cursors.Cross; 
          } 
      
          private void frmBackground_MouseDown(object sender, MouseEventArgs e) 
          { 
           Bitmap backBuffer = new Bitmap(this.ClientSize.Width, this.ClientSize.Height); 
           rect = new Rectangle(e.X, e.Y, 0, 0); 
           this.Invalidate(); 
          } 
      
          private void frmBackground_MouseMove(object sender, MouseEventArgs e) 
          { 
           if (e.Button == MouseButtons.Left) 
            rect = new Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top); 
      
           this.Invalidate(); 
          } 
      
          private void frmBackground_Paint(object sender, PaintEventArgs e) 
          { 
           Pen pen = new Pen(Color.Red, 3); 
           e.Graphics.DrawRectangle(pen, rect); 
      
           SolidBrush brush = new SolidBrush(Color.Fuchsia); 
           e.Graphics.FillRectangle(brush, rect); 
          } 
      } 
      
  • 答えて

    0

    あなたはアルファが0から255に行くので、あなたのアルファのための128の値は、あなたに50%のopactityを与える

    Brush brush = new SolidBrush(Color.FromArgb(alpha, red, green, blue)) 
    

    を使用することができます。

    この溶液は、this question

    +0

    では見つかりませんでした。彼のフォームに0.2の不透明度があり、ブラシに128のアルファがある場合、彼はその長方形に0.2 * 128のアルファを得ます – dimitris93

    関連する問題