如何在MDI容器表单中使MenuStrip和Panel透明 [英] How do I make MenuStrip and Panels transparent in MDI Container Form

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

问题描述

我有一个MDI Conainer表单,其中我添加了menustrip和FlowLayoutPanel来包含一些按钮。我将这两个控件的BackColor属性设置为透明,并实现了一个代码,将Container背景更改为指定的图像。我正在使用此代码更改MDI容器表单的背景



I have a MDI Conainer Form wherein I added a menustrip and a FlowLayoutPanel to contain some buttons. I set the BackColor Property of those two control to transparent and implemented a code to change the Container background to my specified image. I am using this code to change the background of the MDI container form

public partial class FormAdminConsole : Form
{
    public FormAdminConsole()
    {
        InitializeComponent();
        DateTimeTimer.Start();

        foreach (Control ctl in this.Controls)
        {
            if (ctl is MdiClient)
            {
                ctl.BackgroundImage = Properties.Resources.background3;
                ctl.BackgroundImageLayout = ImageLayout.Stretch;
                break;
            }
        }
    }







但是当我运行应用程序时,背景就在那里,但是MenuStrip和FlowLayoutPanel不是透明的,而是深灰色的。



有没有办法制作这些控件真的很透明吗?



提前谢谢。 :)




but when I ran the application the background was there but the MenuStrip and the FlowLayoutPanel is not transparent but rather dark-grayish in color.

Is there a way to make these controls to be really transparent?

Thanks in advance. :)

推荐答案

您是否需要使用Windows窗体?如果可以的话,打破90年代并加入'10s。



别担心,我在这里的第一篇文章是使用MDI的表格(起初),那是在2005年左右。



无论......谁拥有谁? Panel是否拥有MenuStrip? MenuStrip是在另一个类中创建的吗?



这是一个没有更多细节的建议(BTW我读了你的代码):

http://stackoverflow.com/questions/14126356/setting-mdi-child-transparency-possible- vb-net [ ^ ]



使MenuStrip和Panels透明......太宽泛而无法得到正确的答案。这不是那么,但请更具体,你会得到一个更具体的答案。



我希望链接或我的广泛建议给你一些方向。



如果您需要更多帮助,请随时询问。只是让你的问题更具体:)
Are you required to use windows forms? If you can, break free of the the '90s and join the '10s.

Don't worry, my first article on here was forms using MDI (at first), and that was around 2005.

No matter... who owns who? Does the Panel own the MenuStrip? Is the MenuStrip created in another class?

Here's a suggestion without more details (BTW I read your code):
http://stackoverflow.com/questions/14126356/setting-mdi-child-transparency-possible-vb-net[^]

"make MenuStrip and Panels transparent"... Far too broad to get a proper answer. This isn't SO, but please be more specific and you will get a more specific answer.

I hope the link or my broad suggestion gives you some direction.

If you need more assistance, please don't hesitate to ask. Just make your question more specific :)


不仅使用MDI 今天一个错误(它已经过时,视觉上笨重,有更好的选择),但尝试透明Windows窗体中的控件是一个死胡同。如果你把控件放在MDI创建的特殊隐藏的ContainerControl上(这是我假设你正在做的),你的MDI子窗体将在它们移动时模糊它们。



在Windows窗体中,唯一可靠的透明方法是使用窗体,并设置不透明度属性。虽然你可以逃脱它,但将一个Form插入另一个Form的ControlsCollection也是一个严重的错误。另一种方式......我认为错误是通过使用GraphicPaths(区域)和利用缠绕规则行为(区域中的区域之间的相互作用)来创建具有被淘汰区域(空洞)的表单。



我建议您重新考虑您的应用程序设计,在此处发布问题以获取想法和帮助。
Not only is using MDI today a mistake (it's outmoded, visually clunky, there are better alternatives), but attempting transparency with controls in Windows Forms is a dead-end. If you put Controls on the special hidden ContainerControl that MDI creates (which is what I assume you are doing), your MDI Child Forms will obscure them if moved over them.

In Windows Forms the only sure way to have usable transparency is to use Forms, and set the 'Opacity property. While you can get away with it, inserting a Form into another Form's ControlsCollection is also a serious error. Another way ... a mistake I think ... is to create Forms with "knocked out" regions (holes) by using GraphicPaths (Regions) and exploiting winding-rule behavior (interaction between region in region).

I suggest you re-think your Application design, post questions here to get ideas, and assistance.


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

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