[英]How to Hide a Form using the .NET Compact Framework
I'm working on a smart device with installed Windows Mobile 6.1. 我正在使用已安装Windows Mobile 6.1的智能设备。 I need to completely hide my application (a
Form
), but i'm not able to do this. 我需要完全隐藏我的应用程序(一个
Form
),但是我无法做到这一点。 I tried to call the Form.Hide
method, but it does not have any effects, the form is still open, visible and maximized. 我试图调用
Form.Hide
方法,但是它没有任何效果,该窗体仍然是打开的,可见的并且已最大化。 I tried also to follow this post : 我也尝试按照这篇文章 :
[DllImport("coredll.dll")]
static extern int ShowWindow(IntPtr hWnd, int nCmdShow);
public Form1()
{
InitializeComponent();
Hide();
}
public new void Hide()
{
const int SW_MINIMIZED = 6;
FormBorderStyle = FormBorderStyle.FixedDialog;
WindowState = FormWindowState.Normal;
ControlBox = true;
MinimizeBox = true;
MaximizeBox = true;
// Since there is no WindowState.Minimize, we have to P/Invoke ShowWindow
ShowWindow(this.Handle, SW_MINIMIZED);
}
But without any effects (again). 但没有任何影响(再次)。 What is the proper way to do this work?
做这项工作的正确方法是什么?
An application doesn't need to have a call to Application.Run
(which requires a Form in the Compact Framework) to operate. 应用程序不需要调用
Application.Run
(在Compact Framework中需要一个Form)即可运行。 If your app doesn't need a UI, don't create a Form. 如果您的应用不需要用户界面,请不要创建表单。 You can create a state loop, multithread and just about anything else from the
Main
entry point without a Form just fine. 您可以在没有Form的情况下从
Main
入口点创建状态循环,多线程以及几乎所有其他内容。 If you need to process Windows messages, you can always create your own message pump by calling GetMessage
and DispatchMessage
yourself. 如果需要处理Windows消息,则始终可以通过自己调用
GetMessage
和DispatchMessage
来创建自己的消息泵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.