如何使父MDI表单透明? [英] How do make the parent MDI form transparent?

查看:69
本文介绍了如何使父MDI表单透明?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使MDI父窗体为非矩形,因此我将背景设置为位图图像,其中有很多红色.然后我将透明度键设置为红色.但是,红色区域仍未显示为透明.我什至将显示属性设置为16位(我有Windows XP,sp-3).
请帮忙.

I want to make the MDI parent form non-rectangular so i have set the background as a bitmap image which has lots of red color in it. Then i set the transparency key to red. But still the red areas are not showing as transparent. I have even set the display property to 16 bits (I have a windows XP, sp-3).
Please help.

推荐答案

嗯,我注意到了.因此,我已经努力了.这是结果.

将父窗体的IsMdiContainer属性设置为false.然后,替换form_load事件处理程序,如下所示:

Well, I noticed that. hence, I''ve worked on it. and here is the result.

Set IsMdiContainer property of your parent form to value false. then , replace form_load event handler as following:

<br />
private void Form1_Load(object sender, EventArgs e)<br />
 {<br />
   this.TransparencyKey = Color.FromArgb(255, 220, 33, 55);<br />
   <br />
   MdiClient Client = new MdiClient();<br />
   <br />
   this.Controls.Add(Client);<br />
            <br />
   Form Child = new Form();<br />
   <br />
   Child.Size = new Size(100, 100);<br />
   Child.FormBorderStyle = FormBorderStyle.FixedDialog;<br />
   Child.StartPosition = FormStartPosition.CenterParent;<br />
   Child.MaximizeBox = false;<br />
   Child.MinimizeBox = false;<br />
   <br />
   Child.MdiParent = this;<br />
   this.pictureBox1.Controls.Add(Child);<br />
 <br />
   Child.Show();         <br />
 }<br />



此代码将保持透明,并添加mdiclient和子窗体.一切正常,正如您所看到的,childe表单可以在所有父表单区域上移动.因此,最后一个TODO正在寻找一种方法来防止其在透明区域上移动.
我也会尽快进行处理.

希望对您有所帮助.

--------------------
问候

H.Maadani



this code, will do transparency, and will add the mdiclient and child form. everything works fine, just, as you can see, childe form can be moved over all the parent form area. hence, the last TODO is finding a way to prevent it from being moved over transparented areas.
I''ll work on that too, as soon as possible.

hope this helps.

--------------------
Regards

H.Maadani


当然,有办法,我的朋友.

您总是可以通过以下几段代码来获得MdiClient的背景色:

Of course there is a way, my friend.

you can always get the back color of MdiClient by this little piece of code :

<br />
MessageBox.Show(string.Format("R = {0}, G = {1}, B = {2}",<br />
 Client.BackColor.R, Client.BackColor.G, Client.BackColor.B));<br />



如您所见,它是(171,171,171).
所以;



as you can see, it is (171,171,171).
So ;

<br />
this.TransparencyKey = Color.FromArgb(255, 171, 171, 171);<br />



将透明化表单本身.

P.S. 1:对可以帮助您的答案进行评分,使来此问题的人的生活更加轻松.当然选择答案作为解决方案会有所帮助. :)

P.S. 2:我已经将您的问题和答案发布为文章,供所有人使用.请访问
制作透明的MDI父表单 [



will transparent the form itself.

P.S. 1 : rate the answers which help you, it makes life easier for people who come visit this question. and of course choosin an answer as solution wil help so. :)

P.S. 2 : I''ve published your question and the answers as an article for everyone to use. visit it at
Making a transparent MDI parent form[^]

------------------
Regards

H.Maadani


您可以使用区域创建非矩形窗口.
这是一篇演示此内容的文章-
为表单和按钮创建位图区域 [
You can create non-rectangular windows using regions.
Here an article that demonstrates this -
Creating Bitmap Regions for Forms and Buttons[^]


这篇关于如何使父MDI表单透明?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆