zoukankan      html  css  js  c++  java
  • Windows Form窗体的关闭按钮的启用与否

    public partial class Form1 : Form
        {
            private bool isEnableCloseButton = false;
            public Form1(string strFlag)
            {
                InitializeComponent();
                if (strFlag == "no")
                {
                    this.lbl_CloseButtonIsEnabled.Text = "窗体右上角关闭按钮无效";
                    this.isEnableCloseButton = false;
                }
                else
                {
                    this.lbl_CloseButtonIsEnabled.Text = "可以通过窗体右上角关闭按钮 关闭窗体";
                    this.isEnableCloseButton = true;
                }
            }

            protected override CreateParams CreateParams
            {
                get
                {
                    if (isEnableCloseButton)
                    {
                        CreateParams parameters = base.CreateParams;
                        return parameters;
                    }
                    else
                    {
          int CS_NOCLOSE = 0x200;
                        CreateParams parameters = base.CreateParams;
                        parameters.ClassStyle |= CS_NOCLOSE;
                        return parameters;                   
                    }
                }
            }
    }

    //调用显示该窗体
    Form1 frm = new Form1("no");
    frm.ShowDialog();

  • 相关阅读:
    Action获取表单数据的三种方式
    Action三种编写方式
    hibernate 查询方式
    hibernate 多对多操作(级联操作)
    对拍
    树的数据生成器
    SPOJ1825 Free tour II 树分治
    Codeforces 474(#271 Div 2) 解题报告
    HNCPC2012 总结
    Sort 对下标进行排序
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1266220.html
Copyright © 2011-2022 走看看