掌上电脑/ Windows Mobile的:如何检测智能最小化 [英] Pocket PC/Windows Mobile: How to detect smart minimize
问题描述
我如何检测什么时候我Compact Framework的应用程序正在智能最小化(智能最小化是当用户点击在Pocket PC上的右上角的X按钮,会发生什么)?
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)?
在停用事件是不正确的做法,因为它发生的情况下比其他的最小化,比如当一个消息框或者其他的形式显示在主窗体的顶部。而形式的的WindowState没有帮助,因为没有对.NET CF没有最小化的WindowState。
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.
我听说通过设置MinimizeBox =假,我的应用程序将被关闭,而不是最小化。但其实我不希望我的应用程序关闭,我只是想知道什么时候已经被最小化。
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.
推荐答案
我觉得要走的路在这里正在处理的 WM_ACTIVE 的消息,然后检查是否fMinimized参数不为零。你可以找到如何在在这里宣布在code此消息的更多信息。
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.
我会尝试找出如何准确code在C#和证明的假设。但是你比我也许更快,看着办吧。
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.
另外,还要检查功能给DefWindowProc 和的 WindowProc中,该用于处理的消息。功能在您的code这样的声明:
Also check the functions DefWindowProc and WindowProc, which are used to process the messages. Functions are declared in your code like this:
首先有包括:
using System.Runtime.InteropServices;
然后在类中声明是这样
then in the class declare like this
[DllImport("coredll.dll")]
static extern IntPtr DefWindowProc(IntPtr hWnd, uint uMsg, UIntPtr wParam,
IntPtr lParam);
还有一件事你可以做的,这更多的是一种哲学的解决方法。 INMO的智能最小化X的困惑对于用户来说,这就是为什么我不喜欢把它列入。相反,我提供在该使用形式的close方法的形式,上面写着关闭或回,的右下角的按钮。我用它在各种形式保持一个标准。这是更加明确的Windows用户,因为他们可能会认为,在Windows Mobile的X是在窗口PC相同的X。
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.
如果由于某种原因,你需要尽量减少您的应用程序或将其发送到后台使用下面的code:
If for some reason you need to minimize your app or send it to the background use the following code:
using System.Runtime.InteropServices;
...
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
[DllImport("coredll.dll")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_MINIMIZED = 6;
...
...
public void HideForm()
{
ShowWindow(this.Handle, SW_MINIMIZED);
}
}
这篇关于掌上电脑/ Windows Mobile的:如何检测智能最小化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!