我有一个窗体与背景图像和透明度键。 在这种形式中,我把儿童形式,必须是完全透明的,以显示父窗体的背景。如果我将另一个透明度键设置为子窗体 - 它根本不会获得透明度,并且如果我设置了父窗体的透明度键 - 子窗体切入父窗体的背景图像。父母形式的透明子窗体与透明度和背景
我需要使用窗体 - 不是用户控制,所以这是一个问题。我不想将dublicate背景图像设置为子窗体。
我的视觉工作。下面是来自设计师代码:
这是我的父母
// // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.DarkRed; this.BackgroundImage = global::NWN_Tsuki.Properties.Resources.Book; this.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.ClientSize = new System.Drawing.Size(800, 665); this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.CloseBtn); this.DoubleBuffered = true; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.KeyPreview = true; this.MaximumSize = new System.Drawing.Size(800, 665); this.MinimumSize = new System.Drawing.Size(800, 665); this.Name = "Main"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Header"; this.TransparencyKey = System.Drawing.Color.DarkRed; this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Main_KeyDown); this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.Main_MouseDown); this.tableLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false);
这就是我插入孩子到父母的面板:
private void LeftPanel_Paint(object sender, PaintEventArgs e) { ToC toc = new ToC(); toc.TopLevel = false; toc.AutoScroll = true; this.LeftContent.Controls.Add(toc); toc.FormBorderStyle = FormBorderStyle.None; toc.Dock = DockStyle.Fill; toc.Show(); }
这里是我的孩子:
// // ToC // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.Color.Silver; this.ClientSize = new System.Drawing.Size(428, 396); this.Controls.Add(this.Ch7Btn); this.Controls.Add(this.Ch6Btn); this.Controls.Add(this.Ch5Btn); this.Controls.Add(this.Ch4Btn); this.Controls.Add(this.Ch3Btn); this.Controls.Add(this.Ch2Btn); this.Controls.Add(this.Ch1Btn); this.Controls.Add(this.label1); this.Name = "ToC"; this.Text = "ToC"; this.TransparencyKey = System.Drawing.Color.Silver; this.ResumeLayout(false);
那是小孩在银行里面的情况,现在它有透明钥匙银牌。 如果我设置this.BackColor = System.Drawing.Color.DarkRed;
给孩子 - 它会刺破父母的背景。
下面是我的意思的一些图像。
Child with other then parent transparency key
Child with same as parent transparency
向我们展示一些代码,以便我们可以看到您尝试过的内容。 – StijnvanGaal
增加了一些代码。 – Kodek