zoukankan      html  css  js  c++  java
  • C# 大于屏幕的窗体

    1.使用SetWindowPos就可以做到这一点,只是最后一个参数要选对。

    RECT windowRect = new RECT();
    User32.GetWindowRect(MyForm2.Handle, ref windowRect);
    User32.SetWindowPos(MyForm2.Handle, 0, 0, 0, 5000, 500, ApiConstants.SWP_NOSENDCHANGING);

    2.虽然设置完后窗体的大小改变了,但如果窗体的一旦重绘又会被屏幕大小限制而缩小。所以看下面的代码:

    protected override void WndProc(ref Message m)
            {
                const int WM_GETMINMAXINFO = 0x24;
                if (m.Msg == WM_GETMINMAXINFO)
                {
                    MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO));
                    mmi.ptMinTrackSize.x = this.Size.Width;
                    mmi.ptMinTrackSize.y = this.Size.Height;
                    Marshal.StructureToPtr(mmi, m.LParam, true);
                }
                base.WndProc(ref m);
            }
    [StructLayout(LayoutKind.Sequential)]
        public struct RECT
        {
            public int left;
            public int top;
            public int right;
            public int bottom;
        }
    
        public struct POINTAPI 
        { 
            public int x; 
            public int y;        
        }
    
        public struct MINMAXINFO 
        { 
            public POINTAPI ptReserved; 
            public POINTAPI ptMaxSize; 
            public POINTAPI ptMaxPosition; 
            public POINTAPI ptMinTrackSize; 
            public POINTAPI ptMaxTrackSize;        
        }
    View Code

    以上代码在VS2010+Windows7Ultimate下调试通过,运行达到效果。

      

  • 相关阅读:
    Redis 再牛逼,也得设置密码!!
    Spring Data Redis 详解及实战一文搞定
    连接mysql
    angular6安装
    (6)ASP.NET HttpServerUtility 类
    (5)ASP.NET HttpResponse 类
    远程连接错误
    (3)一般处理程序 ,HttpContext类
    ASP.NET内置对象-状态管理
    (4)ASP.NET HttpRequest 类
  • 原文地址:https://www.cnblogs.com/nanfei/p/3200159.html
Copyright © 2011-2022 走看看