Microsoft .NET Compact Framework 2.0 的窗体类(System.Windows.Forms.Form)也提供了 WindowsState 属性,是 FormWindowState 枚举类型。在 .NET Framework 中 FormWindowState 枚举有 Normal, Minimized, Maximized 三个值。但是 .NET Compact Framework 中的 FormWindowState 枚举只有 Normal 和 Maximized 两个值。因此在 .NET Compact Framework 的窗体类中,不能通过设置 WindowState 属性为 FormWindowState.Minimized 实现窗体的最小化。不过我们可以通过调用 Win32 API 来实现,以下是实现该功能的关键代码:
//using System.Runtime.InteropServices;
[DllImport( " coredll " )] private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow); private const int SW_MINIMIZE = 6 ; private void mniHide_Click( object sender, EventArgs e) { // 隐藏窗体,可以通过重新运行程序来显示窗体 ShowWindow( this .Handle, SW_MINIMIZE); } private void mniExit_Click( object sender, EventArgs e) { // 关闭窗体,窗体对象将会被销毁 this .Close(); } |
实现Windows Mobile 窗体的最小化
最新推荐文章于 2024-10-04 10:45:54 发布