首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

怎么锁定MDI子窗体的位置,为什么用Location=new Point(0,0)不起作用

2011-12-30 
如何锁定MDI子窗体的位置,为什么用Locationnew Point(0,0)不起作用?如何锁定MDI子窗体的位置,为什么用Loc

如何锁定MDI子窗体的位置,为什么用Location=new Point(0,0)不起作用?
如何锁定MDI子窗体的位置,为什么用Location=new   Point(0,0)不起作用?
请问有什么好的方法?

[解决办法]
需要把StartPosition设置为Manual即可...
[解决办法]
同上
[解决办法]
this.SetBounds
[解决办法]
要想让窗体显示后不可移动(锁定位置)可以参考下代码来操作(用API):

[DllImport( "User32.dll ")]
public static extern int GetSystemMenu(int hWnd, int bRevert);
[DllImport( "User32.dll ")]
public static extern int RemoveMenu(int 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_MOVE = 0xf010;

protected override void OnLoad(EventArgs e)
{
int hMenu;
hMenu = GetSystemMenu(this.Handle.ToInt32(), 0);
//移动菜单
RemoveMenu(hMenu, SC_MOVE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
}

[解决办法]
hbxtlhx方法好。我最近也才发现这个方法的。不过是vc下用的。这样是比较完美的禁止移动的方法了。

热点排行