黎波

Windows Mobile Development for Line of Business
posts - 177, comments - 1124, trackbacks - 36, articles - 0
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

如何通过代码实现 Windows Mobile 窗体的最小化

Posted on 2007-11-26 18:08 黎波 阅读(782) 评论(3)  编辑 收藏 所属分类: .NET CF
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();
}

Feedback

#1楼    回复  引用  查看    

2007-12-18 23:23 by kejia [未注册用户]
请教一下,Mobile 5。0 如何让我开发的程序能够像游戏的窗口一样永远至顶,因为每次程序通过GPRS访问服务器的时候就会在顶部显示正在连接网络的那个信息一点设置就跳出去了,我把顶部的那一条Disable掉也不行,想的头发都白了~~ 谢谢!

#2楼 [楼主]   回复  引用  查看    

2007-12-23 22:39 by 黎波      
@kejia
这个问题在我的程序也会,还没有尝试去解决。

#3楼    回复  引用  查看    

2007-12-29 11:09 by kejia [未注册用户]
@黎波
kejia :这两天看了一个老外写的东西,改注册表可以隐藏掉那个泡泡,黎兄可以试一下,我这边已经搞定了。不过有点治标不治本的感觉~~~

I've also had this problem and spent (too) much time on resolving it. But I think, I've finally found a solution:
It is either possible to disable those kind of notification bubbles through Start->Settings->Sounds&Notifications from the "Personal" tab, then choose the "Notifications" tab and disable the "display messages" checkbox for "connection closed" and "connection created" events. (I'm not sure if these translations are correct, because I'm not having an English OS-Device in front of me...

You can also do that programmatically through registry settings
[HKEY_CURRENT_USER\ControlPanel\Notifications\{8ddf46e8-56ed-4750-9e58-afc6ce486d03}] "connection closed"
[HKEY_CURRENT_USER\ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}] "connection created"
by just setting the "Options" value to DWORD(0)

If you have a look to other keys in the HKCU\ControlPanel\Notifications section, you'll find settings for other notification events which you might want to modify...

HTH,
magu

标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-11-26 18:27 编辑过
 
另存  打印
最新IT新闻:
· 深藏33年Unix操作系统bug被消灭
· Expression Studio 2.0 中文版发布了
· 雅虎首页大变脸 阿里风格上身
· 万名Linux使用者向暴雪请愿Linux版《Diablo III》
· 56.com我乐网将全面转行 退出视频行业