使控件全屏显示

发布于 2024-12-24 16:07:44 字数 163 浏览 1 评论 0原文

我可以使控件(在 Windows 窗体中)全屏显示吗?我可以用 P/Invoke 来实现吗?我认为解决方案可能会遍历表单中的所有控件,然后确保它是我的控件的类型,将位置设置为 0,0,将其放在顶部,重新调整控件大小以适合表单,然后更改表单,使其填满屏幕。我宁愿用另一种方式来做,因为这种方法似乎不可靠。提前致谢。

Can I make a control (in Windows Forms) go fullscreen? Could I do it with P/Invoke? I thought that a solution might be running through all of the controls in the Form, then ensuring it is a type of my control, setting the location to 0,0, putting it on top, re-sizing the control to fit the form, and then changing the form so it fills the screen. I would prefer to do it another way because this method doesn't seem to reliable. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遮了一弯 2024-12-31 16:07:44

我建议最大化表单,然后将控件完全停靠到表单上。

        control.Dock = DockStyle.Fill;
        this.WindowState = FormWindowState.Maximized;

I would recommend maximizing the form, then docking the control as full to the form.

        control.Dock = DockStyle.Fill;
        this.WindowState = FormWindowState.Maximized;
水中月 2024-12-31 16:07:44

考虑到您也想隐藏 SysTray,我知道并在多年前编写 POS 应用程序期间使用了一个解决方案。你可以这样做:

private const int SW_HIDE = 0;
private const int SW_SHOW = 1;

[DllImport("user32.dll")]
private static extern int FindWindow(string className, string windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);

int hWnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(hWnd, SW_HIDE);

这样系统托盘将被隐藏。

这里是一篇关于该主题的好文章。

但由于这是很久以前的事了,您应该检查一些可能的问题。

  • 它可以在 Windows 7 上运行吗?
  • 它是否在 Windows 64 位版本上运行(请参阅[DllImport("user32.dll")])?

希望这有帮助。

Considering that you want to hide SysTray too, there is a solution I'm aware of and used long years ago during writing the POS applications. You could do something like this:

private const int SW_HIDE = 0;
private const int SW_SHOW = 1;

[DllImport("user32.dll")]
private static extern int FindWindow(string className, string windowText);
[DllImport("user32.dll")]
private static extern int ShowWindow(int hwnd, int command);

int hWnd = FindWindow("Shell_TrayWnd", "");
ShowWindow(hWnd, SW_HIDE);

In this way the systray will be hidden.

Here is a good article on subject.

But as this was a long time ago here you should check a couple of possible problems.

  • Does it run on Windows 7 ?
  • Does it run on Windows 64 bit versions (see [DllImport("user32.dll")]) ?

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文