2

我正在使用安装了 Windows Mobile 6.1 的智能设备。我需要完全隐藏我的应用程序 (a Form),但我无法做到这一点。我尝试调用该Form.Hide方法,但它没有任何效果,表单仍然是打开的、可见的和最大化的。我也尝试关注这篇文章

[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);
}

但没有任何影响(再次)。做这项工作的正确方法是什么?

4

1 回答 1

1

应用程序不需要调用Application.Run(这需要 Compact Framework 中的表单)来操作。如果您的应用不需要 UI,请不要创建表单。您可以从入口点创建一个状态循环、多线程以及几乎任何其他东西,Main而无需使用表单。GetMessage如果您需要处理 Windows 消息,您始终可以通过调用和自己来创建自己的消息泵DispatchMessage

于 2012-12-09T16:31:20.217 回答