半透明画像の重ね合わせ
ベースとなるフォームの上に、半透明のフォームを重ね合わせたフォームを作成します。
まず、ベースとなるフォームを作成します。
ピクチャボックスと、透明度を調節するためのスライダーを配置します。
次に、重ね合わせフォームを作成します。
ウインドウの外枠は不要なので、全て無効にします。重ね合わせフォームの大きさを、ベースとなるフォームのピクチャボックスと同じにします。
次に。重ね合わせフォーム上に、ピクチャボックスを配置します。
ピクチャボックスの大きさを重ね合わせフォームと同じにします。
次に、各々のフォームに適当な画像を貼り付けます。
最後に、イベントハンドラを実装します。
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace OpacityForm { public partial class BaseForm : Form { public BaseForm() { InitializeComponent(); this.ofm.Visible = false; this.ofm.Opacity = (double)this.trackBar1.Value / (double)this.trackBar1.Maximum; this.ofm.Visible = true; } private void trackBar1_Scroll(object sender, EventArgs e) { this.ofm.Opacity = (double)this.trackBar1.Value / (double)this.trackBar1.Maximum; } private OpacityForm ofm = new OpacityForm(); private void BaseForm_Move(object sender, EventArgs e) { this.ofm.Location = this.PointToScreen(this.pictureBox1.Location); } } }