您的位置:程序门 -> .net技术 -> c#



如何使窗口右上角的关闭按纽不可用,即是灰色的


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何使窗口右上角的关闭按纽不可用,即是灰色的[已结贴,结贴人:wsw0515]
发表于:2007-03-10 10:03:07 楼主
如题!谢了!!!
发表于:2007-03-13 16:51:201楼 得分:0
formborderstyle设为none
发表于:2007-03-13 16:51:282楼 得分:0
好像没有现成的属性,你可以把form设为none模式,然后用不规则窗体来自己构造一个关闭按键。
或者根据条件把form的在none与非none之间转换
发表于:2007-03-13 16:51:513楼 得分:0
在property里面,   将controlbox设为false

不过这样不会把它灰掉,   而是会去掉了
发表于:2007-03-13 16:52:054楼 得分:0
controlbox   属性设置为false
发表于:2007-03-13 16:52:475楼 得分:0
参见如下的代码(使关闭控钮变灰而不是不显示):

[dllimport( "user32.dll ")]
public   static   extern   intptr   getsystemmenu(intptr   hwnd,   int   brevert);
[dllimport( "user32.dll ")]
public   static   extern   int   removemenu(intptr   hmenu,   int   nposition,   int   wflags);
public   const   int   mf_bycommand   =   0x00000000;
public   const   int   mf_disabled   =   0x00000002;
public   const   int   mf_grayed   =   0x00000001;
public   const   int   sc_close   =   0xf060;

private   void   btnnoclosebtn_click(object   sender,   eventargs   e)
{
intptr   hmenu;

hmenu   =   getsystemmenu(this.handle,   0);
removemenu(hmenu,   sc_close,   mf_bycommand   ¦   mf_disabled   ¦   mf_grayed);
}
发表于:2007-03-13 16:55:206楼 得分:0
平民百姓好强悍~~

学习了
发表于:2007-03-13 16:56:117楼 得分:0
如果只是设置最大化按钮不可用,直接this.maximizebox   =   false;就行...
发表于:2007-03-13 17:24:408楼 得分:0
谢谢!
在问一个问题,这些值代表的意义哪里可以查到?
public   const   int   mf_bycommand   =   0x00000000;
public   const   int   mf_disabled   =   0x00000002;
public   const   int   mf_grayed   =   0x00000001;
public   const   int   sc_close   =   0xf060;
发表于:2007-03-13 17:28:109楼 得分:20
你一定要装vc,这样会有一些头文件(.h),像上面的常量都要在这里找到.
发表于:2007-03-13 17:30:2310楼 得分:0
谢谢各位,特别谢谢hbxtlhx(平民百姓)
发表于:2007-03-13 17:37:4011楼 得分:0
何必非要显示呢,隐藏就可以了嘛
发表于:2007-03-13 18:33:5012楼 得分:0
我要显示最小化按纽和最大化按纽


快速检索

最新资讯
热门点击