Pocket PC/Windows Mobile:如何检测智能最小化
如何检测我的 Compact Framework 应用程序何时被智能最小化(智能最小化是当用户单击 Pocket PC 右上角的“X”按钮时发生的情况)?
Deactivate 事件不是正确的方式,因为它发生在最小化以外的情况下,例如当消息框或其他窗体显示在主窗体顶部时。 而且窗体的 WindowState 没有帮助,因为 .NET CF 上没有“最小化”WindowState。
我听说通过设置 MinimizeBox = false,我的应用程序将被关闭而不是最小化。 但我实际上不想关闭我的应用程序,我只是想知道它何时被最小化。
How do I detect when my Compact Framework application is being smart-minimized (smart minimize is what happens when the user clicks the "X" button in the top-right corner on a Pocket PC)?
The Deactivate event isn't the right way because it occurs in circumstances other than minimization, such as when a message box or another form is shown on top of the main form. And the form's WindowState doesn't help because there is no "Minimized" WindowState on .NET CF.
I heard that by setting MinimizeBox = false, my app will be closed instead of minimized. But I actually don't want my app to close, I just want to know when it has been minimized.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这里的方法是处理 WM_ACTIVE 消息,然后检查 fMinimized 参数是否不为零。 您可以在此处。
我将尝试找出如何在 C# 中准确编码并证明这个假设。 不过你可能比我更快地弄清楚。
另请检查函数 DefWindowProc 和 WindowProc,用于处理消息。 函数在代码中声明如下:
首先包含:
然后在类中声明如下
您还可以做另一件事,这更像是一种“哲学”解决方法。 INMO 智能最小化 X 会让用户感到困惑,这就是为什么我不喜欢包含它。 相反,我在表单的右下角提供了一个按钮,显示“关闭”或“返回”,它使用表单的 close 方法。 我以各种形式使用它来保持标准。 这对于 Windows 用户来说不太含糊,因为他们可能会认为 Windows Mobile 中的 X 与 Windows PC 中的 X 相同。
如果由于某种原因您需要最小化您的应用程序或将其发送到后台,请使用以下代码:
I think the way to go here is processing the WM_ACTIVE message and then checking if the fMinimized parameter is not zero. You can find more information on how to declare this messages in your code in here.
I will try figure out how to exactly code this in C# and prove the hypothesis. However you maybe faster than me and figure it out.
Also check the functions DefWindowProc and WindowProc, which are used to process the messages. Functions are declared in your code like this:
First have the include:
then in the class declare like this
There is another thing you could do, this is more a "philosophical" workaround. INMO the smart minimize X is confusing for users, that is why I don't like to include it. Instead I provide a button at the right lower corner of the form that says "close" or "back", which uses the close method of the form. I used it in all forms to keep a standard. This is less ambiguous for windows users because they may assume that the X in windows mobile is the same X in windows for PC.
If for some reason you need to minimize your app or send it to the background use the following code:
智能最小化到底是什么意思? 我想你的意思是你的应用程序在一段时间内没有活动时会自动最小化? 嗯,我不认为有这样的活动。
此博客站点的作者使用了 Deactivate 事件用于打开和关闭内部进程。 这对于动画和其他类似的过程来说是可以接受的,并且弹出消息框或其他表单的情况也没有问题。 但是,如果除非应用程序关闭或“智能最小化”,否则您的进程不得停止,您可以尝试在停用事件上启动计时器。 如果表单在特定时间间隔内没有重新激活,则可以安全地停止内部进程。
当然,在设计解决方案时,您需要考虑电源管理。 看看这个,当然还有用于电源通知的 OpenNetCF。
What exactly do you mean by smart-minimized? I suppose you mean your app being automatically minimised on no activity for some time? Well, I don't think that there is an event for that.
The author of this blog spot uses the Deactivate event for turning internal process on and off. This is acceptable for animation and other similar processes and the cases of a message box or another form popping up are no problems. If however, your process must not be stopped unless the application closes or 'smart-minimizes', you could try starting a timer on deactivate events. If the form isn't activated back for a specific interval, then it would be safe to stop the internal process.
Of course in designing your solution you need to take Power Management into consideration. Have a look at this and of course also OpenNetCF for power notifications.