form初始化最大,且不可变小,不可拖动,该怎么做 我把windowsstate设为最大化,MaximizeBox设为false启动后界面可以被拖动而且状态栏把任务栏也遮住了而且双击form标题栏,也会让form变小 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.cnblogs.com/skyiv/archive/2005/10/05/WndProc.html FormBorderStyle = FormBorderStyle.FixedSingle // 用API去掉系统菜单的“移动”菜单项using System; using System.Windows.Forms; using System.Runtime.InteropServices; class Test : Form { const int MF_BYPOSITION = 0x0400; const int MF_REMOVE = 0x1000; [DllImport("user32.dll",EntryPoint="GetSystemMenu")] extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert); [DllImport("user32.dll",EntryPoint="RemoveMenu")] extern static int RemoveMenu(IntPtr hMenu, int nPos, int flags); Test() { Text = "不能移动和改变大小的窗口"; FormBorderStyle = FormBorderStyle.FixedSingle; MaximizeBox = false; MinimizeBox = false; RemoveMenu(GetSystemMenu(Handle,IntPtr.Zero),1,MF_BYPOSITION|MF_REMOVE); } static void Main() { Application.Run(new Test()); } } http://www.cnblogs.com/skyiv/archive/2005/10/05/WndProc.html FormBorderStyle = FormBorderStyle.FixedSingle---------------这个没有用,你可以试试只不过保证你不能够拖动变大变小 如果你是winform程序的话,可以这么做,controlbox设置为false没有系统功能按钮。把窗体的fomrborderstyle设置为FixedSingle\Fixed3D都行然后把maximizebox设置为false这样鼠标就不能拖拽你的窗体了 this.WindowState = FormWindowState.Maximized;设置最大 this.WindowState = FormWindowState.Maximized;this.FormBorderStyle = FormBorderStyle.FixedSingle;this.MinimizeBox = false; controlbox设置为false,标题栏就没有图标了阿 haha 要用得是FormBorderStyle = FormBorderStyle.None; // 用API去掉系统菜单的“移动”菜单项using System; using System.Windows.Forms; using System.Runtime.InteropServices; class Test : Form { const int MF_BYPOSITION = 0x0400; const int MF_REMOVE = 0x1000; [DllImport("user32.dll",EntryPoint="GetSystemMenu")] extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert); [DllImport("user32.dll",EntryPoint="RemoveMenu")] extern static int RemoveMenu(IntPtr hMenu, int nPos, int flags); Test() { Text = "不能移动和改变大小的窗口"; WindowState = FormWindowState.Maximized; FormBorderStyle = FormBorderStyle.FixedSingle; MaximizeBox = false; MinimizeBox = false; RemoveMenu(GetSystemMenu(Handle,IntPtr.Zero),1,MF_BYPOSITION|MF_REMOVE); } static void Main() { Application.Run(new Test()); } } 如果你是winform程序的话,可以这么做,controlbox设置为false没有系统功能按钮。把窗体的fomrborderstyle设置为FixedSingle\Fixed3D都行然后把maximizebox设置为false这样鼠标就不能拖拽你的窗体了 this.WindowState = FormWindowState.Maximized;设置最大---------------------这样不行我现在需要有个最小化的按钮form一启动,就是最大化,可以最小化,但是不能拖动,双击不能够变小 那就把 MinimizeBox = false; 去掉。 protected override void WndProc(ref Message m)15 {16 base.WndProc(ref m);17 if(m.Msg == 0x84 && m.Result == (IntPtr)2) // 不让拖动标题栏18 {19 m.Result = (IntPtr)1;20 }21 if (m.Msg == 0xA3) // 双击标题栏无反应22 {23 m.WParam = System.IntPtr.Zero;24 }25 }用这个就可以了下面这段不要也可以啊,if (m.Msg == 0xA3) // 双击标题栏无反应 { m.WParam = System.IntPtr.Zero; } 但是有个问题,form的状态栏把任务栏给遮住了,该怎么解决阿 任务栏 -> 右键 -> 属性 -> 勾上“总在最前” -> 去掉“自动隐藏”。 你没有明白意思,我任务栏不是自动隐藏的form一启动就把任务栏遮住了 你可以试试,把maximizebox设置为falseWindowState = FormWindowState.Maximized;设置最大form一启动就会把任务栏遮住 确实,同时指定WindowState = FormWindowState.Maximized;MaximizeBox = false;将会使form一启动就把任务栏遮住。----------------------------------------------WindowState = FormWindowState.Maximized;MaximizeBox = true; 则不会遮住任务栏,可能是M$的一个Bug。 急急!!求指导 求助:二者区别 请教,想写一个辅助软件用于旺旺等 关于网络编程,高手请进,在线等 现在招聘.net的程序员在学校招聘的难道不要C/S的么? this在这里是什么意思? 这个简单问题居然没人能答? ONE need help 请教。。。。。 asp.net中,用C#操控EXCEL,怎样解决EXCEL进程死锁问题。 Response .Redirect 重定向可不可以POST传值 测试一下你的编程思想。。
using System.Windows.Forms;
using System.Runtime.InteropServices; class Test : Form
{
const int MF_BYPOSITION = 0x0400;
const int MF_REMOVE = 0x1000; [DllImport("user32.dll",EntryPoint="GetSystemMenu")]
extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert); [DllImport("user32.dll",EntryPoint="RemoveMenu")]
extern static int RemoveMenu(IntPtr hMenu, int nPos, int flags); Test()
{
Text = "不能移动和改变大小的窗口";
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
MinimizeBox = false;
RemoveMenu(GetSystemMenu(Handle,IntPtr.Zero),1,MF_BYPOSITION|MF_REMOVE);
} static void Main()
{
Application.Run(new Test());
}
}
---------------
这个没有用,你可以试试
只不过保证你不能够拖动变大变小
this.FormBorderStyle = FormBorderStyle.FixedSingle;
this.MinimizeBox = false;
要用得是
FormBorderStyle = FormBorderStyle.None;
using System.Windows.Forms;
using System.Runtime.InteropServices; class Test : Form
{
const int MF_BYPOSITION = 0x0400;
const int MF_REMOVE = 0x1000; [DllImport("user32.dll",EntryPoint="GetSystemMenu")]
extern static IntPtr GetSystemMenu(IntPtr hWnd, IntPtr bRevert); [DllImport("user32.dll",EntryPoint="RemoveMenu")]
extern static int RemoveMenu(IntPtr hMenu, int nPos, int flags); Test()
{
Text = "不能移动和改变大小的窗口";
WindowState = FormWindowState.Maximized;
FormBorderStyle = FormBorderStyle.FixedSingle;
MaximizeBox = false;
MinimizeBox = false;
RemoveMenu(GetSystemMenu(Handle,IntPtr.Zero),1,MF_BYPOSITION|MF_REMOVE);
} static void Main()
{
Application.Run(new Test());
}
}
---------------------
这样不行
我现在需要有个最小化的按钮form一启动,就是最大化,可以最小化,但是不能拖动,双击不能够变小
15 {
16 base.WndProc(ref m);
17 if(m.Msg == 0x84 && m.Result == (IntPtr)2) // 不让拖动标题栏
18 {
19 m.Result = (IntPtr)1;
20 }
21 if (m.Msg == 0xA3) // 双击标题栏无反应
22 {
23 m.WParam = System.IntPtr.Zero;
24 }
25 }
用这个就可以了
下面这段不要也可以啊,
if (m.Msg == 0xA3) // 双击标题栏无反应
{
m.WParam = System.IntPtr.Zero;
}
form一启动就把任务栏遮住了
把maximizebox设置为false
WindowState = FormWindowState.Maximized;设置最大form一启动就会把任务栏遮住
MaximizeBox = false;将会使form一启动就把任务栏遮住。
----------------------------------------------
WindowState = FormWindowState.Maximized;
MaximizeBox = true; 则不会遮住任务栏,可能是M$的一个Bug。