private void OnLoaded(Object sender, EventArgs e)
{
int nStyle = Win32API.GetWindowLong(new WindowInteropHelper(this).Handle, Win32API.GWL_STYLE);
nStyle &= ~Win32API.WS_SYSMENU;
Win32API.SetWindowLong(new WindowInteropHelper(this).Handle, Win32API.GWL_STYLE, nStyle);
}
public class Win32API
{
public const int GWL_STYLE = -16;
public const int GWL_EXSTYLE = -20;
public const int WS_CAPTION = 0x00C00000;
public const int WS_SYSMENU = 0x00080000;
[DllImport("user32.dll")]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int newN);
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
}
本文介绍了一种通过C#代码调用Win32API来移除Windows窗体应用程序中的系统菜单栏的方法。具体实现包括获取窗口样式并清除系统菜单对应的位标志。
1360

被折叠的 条评论
为什么被折叠?



