• 关于c# winForm窗体最大化的设置


    http://blog.csdn.net/cnkivm/archive/2010/05/30/5635166.aspx

    private void btnFormMax_Click(object sender, EventArgs e) 

         if (this.WindowState == FormWindowState.Maximized) 
         { 
       this.WindowState = FormWindowState.Normal; 
         } 
    else 
         { 
       this.WindowState = FormWindowState.Maximized; 
         } 

    此时this.FormBorderStyle. 默认为 Sizable

    2. 窗体最大化时 会全屏 及遮盖任务栏
    private void btnFormMax_Click(object sender, EventArgs e) 

          if (this.WindowState == FormWindowState.Maximized) 
          {        
             this.WindowState = FormWindowState.Normal; 
          } 
          else 
          { 
             this.FormBorderStyle. = FormBorderStyle.None; 
             this.WindowState = FormWindowState.Maximized; 
          } 
       }
    此时this.FormBorderStyle. 为 None 不会显示窗体标题栏等相关

    3. 窗体最大化时 非全屏 不会遮盖任务栏
    private void btnFormMax_Click(object sender, EventArgs e) 

          if (this.WindowState == FormWindowState.Maximized) 
          {        
             this.WindowState = FormWindowState.Normal; 
          } 
          else 
          { 
             this.FormBorderStyle. = FormBorderStyle.None; 
             this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); 
             this.WindowState = FormWindowState.Maximized; 
          } 
       }

    此时this.FormBorderStyle. 为 None 不会显示窗体标题栏等相关


    using System; 
    using System.Collections.Generic; 
    using System.ComponentModel; 
    using System.Data; 
    using System.Drawing; 
    using System.Text; 
    using System.Windows.Forms; 
    namespace WindowsApplication1 

    public partial class FormRegion : Form. 

    private const long WM_GETMINMAXINFO = 0x24; 
    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; 

    public FormRegion() 

    InitializeComponent(); 
    this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height); 

    protected override void WndProc(ref System.Windows.Forms.Message m) 

    base.WndProc(ref m); 
    if (m.Msg == WM_GETMINMAXINFO) 

    MINMAXINFO mmi = (MINMAXINFO)m.GetLParam(typeof(MINMAXINFO)); 
    mmi.ptMinTrackSize.x = this.MinimumSize.Width; 
    mmi.ptMinTrackSize.y = this.MinimumSize.Height; 
    if (this.MaximumSize.Width != 0 || this.MaximumSize.Height != 0) 

    mmi.ptMaxTrackSize.x = this.MaximumSize.Width; 
    mmi.ptMaxTrackSize.y = this.MaximumSize.Height; 

    mmi.ptMaxPosition.x = 1; 
    mmi.ptMaxPosition.y = 1; 
    System.Runtime.InteropServices.Marshal.StructureToPtr(mmi, m.LParam, true); 



    }  

    MessageBox.Show("当前窗体标题栏高度"+(this.Height - this.ClientRectangle.Height).ToString());//获得当前窗体标题栏高度获取表示控件的工作区的矩形 
    MessageBox.Show(SystemInformation.PrimaryMonitorSize.ToString()); //获取主显示器屏幕的尺寸(像素获取主显示器当前当前视频模式的尺寸(以象素为单位菜单栏高度"+SystemInformation.MenuHeight.ToString()); //获取标准菜单栏的高度标题栏高度"+SystemInformation.CaptionHeight.ToString()); //获取标准标题栏的高度获取一个菜单行的高度(以象素为单位获取窗口的标准标题栏区域的高度(以象素为单位)

    发表于 @ 2010年05月30日 21:37:00 | 评论( 0 ) 举报收藏

  • 相关阅读:
    CentOS7 安装Docker 18.09.5
    CentOS7 安装Jenkins 2.164.2
    Python3从零开始爬取今日头条的新闻【一、开发环境搭建】
    Win10 安装Oracle11g2、配置PL/SQL Developer11环境
    IDEA 使用Mybatis效率飞起来的必备工具:MybatisCodeHelperPro 最新破解版,亲测可用!
    Navicat Premium 12 (64位)实现连接Oracle 11 (64位)
    VMware14 安装CentOS7 实现宿主机ping通虚拟机、虚拟机ping通宿主机、虚拟机能上网且能ping通百度
    Java中util.Date通过mybatis向数据库中datetime的操作!
    Java中try-catch-finally语句中return的执行顺序总结
    java中this用法总结
  • 原文地址:https://www.cnblogs.com/kevinzhwl/p/1766475.html
Copyright © 2020-2023  润新知