对于Form怎样使它的任务栏中的右键选项全部变灰,包括关闭选项。 对于普通Form,设了ControlBox = false;右键就变灰了。可是我现在用的一个Form相当于是一个没有标题栏的提示画面。它的ControlBox 已经是false了,可右键任务栏其他都灰了,就关闭不灰怎么办呢? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以把最大化和最小化的禁用掉,把关闭留着啊this.ControlBox = true;this.MaximizeBox = false;this.MinimizeBox = false; 你可以把提示栏去掉:Form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; 回fuyiyong(戴眼镜的猫):我需要把关闭禁了。回bumm(......) :FormBorderStyle是需要的。 可以把Form的鼠标右击事件屏蔽掉:写一个消息过滤类:public class MessageFilter : IMessageFilter { public bool PreFilterMessage(ref Message m) { //0xA5 当用户按下鼠标右键同时光标又在窗口的非客户区时发送此消息 if (m.Msg == 0xA5) { return true; } return false; }在Form_Load事件中添加代码:MessageFilter filter = new MessageFilter();Application.AddMessageFilter(filter); using System.Runtime.InteropServices;private const int MF_BYPOSITION=0x400;private const int MF_DISABLED=0x2; [DllImport("user32", EntryPoint="GetSystemMenu")] private static extern IntPtr GetSystemMenu ( IntPtr hwnd, bool bRevert ); [DllImport("user32", EntryPoint="EnableMenuItem")] private static extern int EnableMenuItem ( IntPtr hMenu, int wIDEnableItem, int wEnable );hwnMenu = GetSystemMenu(this.Handle,false);EnableMenuItem(hwnMenu,6,MF_BYPOSITION|MF_DISABLED); 回bumm(......) :感谢你的帮助,不过不行。我需要任务栏上的右键关闭不可用。另外,如果有其它方法护短,尽量不用消息驱动,因为这样只适用于Windows回sxlfybb(房客):也同样感谢你,能再详细点吗? 《《《正则表达式达人进》》》 请问ajax toolkit里的日历控件,可以同时映射到两个文本框吗 使用企业库如何设计连接串 关于Repeater与DataBinder同时使用取控件ID的问题?急 請教DataSet 中表的操作 什么是“windows用户体验”? treeview如何判断一个结点下面是否还有子结点? 关于数组反序列化问题,急急 vs13 c#64位系统下编的程序无法在32位系统运行 简单问题 程序控制打开一个浏览器后,怎么程序控制参数 windowform 中关掉Form2时如何向form1返回一个参数?
this.ControlBox = true;
this.MaximizeBox = false;
this.MinimizeBox = false;
回bumm(......) :FormBorderStyle是需要的。
public class MessageFilter : IMessageFilter
{
public bool PreFilterMessage(ref Message m)
{
//0xA5 当用户按下鼠标右键同时光标又在窗口的非客户区时发送此消息
if (m.Msg == 0xA5)
{
return true;
}
return false;
}在Form_Load事件中添加代码:
MessageFilter filter = new MessageFilter();
Application.AddMessageFilter(filter);
private const int MF_DISABLED=0x2;
[DllImport("user32", EntryPoint="GetSystemMenu")]
private static extern IntPtr GetSystemMenu (
IntPtr hwnd,
bool bRevert
);
[DllImport("user32", EntryPoint="EnableMenuItem")]
private static extern int EnableMenuItem (
IntPtr hMenu,
int wIDEnableItem,
int wEnable
);hwnMenu = GetSystemMenu(this.Handle,false);
EnableMenuItem(hwnMenu,6,MF_BYPOSITION|MF_DISABLED);
另外,如果有其它方法护短,尽量不用消息驱动,因为这样只适用于Windows
回sxlfybb(房客):也同样感谢你,能再详细点吗?