zoukankan      html  css  js  c++  java
  • 给MDI父窗体添加背景和解决闪烁的问题

     #region 给MDI 父窗体添加背景和解决闪烁的问题
            //1、在Properties/Resources.resx中添加名称为"BackgroundImage"的背景图片

    //2、在以下位置添加BackgroundNoSplash();

    public FrmMain()
            {

              

                InitializeComponent();


                //给MDI 父窗体添加背景和解决闪烁的问题
                BackgroundNoSplash();


            }

    //以下代码复制到MDI主窗体代码中

            MdiClient mdiClient = new MdiClient();
           
            private void BackgroundNoSplash()
            {
                foreach (Control var in this.Controls)
                {
                    if (var is MdiClient)
                    {
                        mdiClient = var as MdiClient;
                        break;
                    }
                }

                if (mdiClient != null)
                {
                    mdiClient.Paint += new PaintEventHandler(OnMdiClientPaint);
                    System.Reflection.MethodInfo mi = (mdiClient as Control).GetType().GetMethod("SetStyle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                    mi.Invoke(mdiClient, new object[] { ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer
                     | ControlStyles.ResizeRedraw, true });

                }
            }

            private void OnMdiClientPaint(object sender, PaintEventArgs e)
             {
                Graphics g = e.Graphics;
                 g.DrawImage(Properties.Resources.BackgroundImage, new Rectangle(0, 0, mdiClient.Width, mdiClient.Height));
                 string msg = "系统名称+版本号+最后更新日期";
                 SizeF size = e.Graphics.MeasureString(msg, this.Font);
                 g.DrawString(msg, this.Font, new SolidBrush(Color.White), mdiClient.Width - size.Width, mdiClient.Height - size.Height);

             }

            #endregion

    分享到: 更多
  • 相关阅读:
    (IEEE-754) 字节数组与浮点数之间的互相转换(MODBUS float类型)
    C#中浮点数依IEEE-754标准转二进制串 (MODBUS 浮点数转换)
    SQL 向上取整、向下取整、四舍五入取整的实例!round、rounddown、roundup
    查看SQL SERVER数据库运行参数和连接数
    three.js 材质
    three.js 曲线
    three.js 几何体-组合网格
    three.js 几何体(三)
    three.js 几何体(二)
    three.js 几何体(一)
  • 原文地址:https://www.cnblogs.com/tiasys/p/1615507.html
Copyright © 2011-2022 走看看