桌面上的窗口/winforms 中最底部的窗口

发布于 2024-12-13 20:55:42 字数 489 浏览 1 评论 0原文

我试图在启动时启动一个表单,并让它在应用程序运行的整个过程中保留为背景。本质上我想隐藏所有桌面图标并拥有空白背景。此外,当用户单击某些按钮时,我希望表单 BackColor 发生变化。

我搜索了很多,并且不断找到一半的解决方案。这是我到目前为止所尝试过的:

创建了一个覆盖 WndProc 事件的 BackBaseForm,如果它是 WM_WINDOWPOSCHANGING,我不会调用 base.WndProc(ref m) 并且而是发送以下消息:

SetWindowPos(Handle, new IntPtr(1), 0, 0, this.width, this.height, SWP_NOZORDER);

但是,每当我单击表单时,它仍然会将其带到前面。我还尝试创建一个 WINDOWPOS 结构,将指针编组到该结构,然后修改该结构。不过,我认为这不会改变消息中的实际 lParam

I'm trying to launch a form at startup and have it remain as the background for my application the entire time its running. Essentially I want to hide all the desktop icons and have a blank background. Further, when a user clicks certain buttons I want the form BackColor to change.

I've searched a bunch and I keep finding half solutions. Here is what I've tried so far:

Created a BackBaseForm that overides the WndProc event and if its WM_WINDOWPOSCHANGING, I don't call base.WndProc(ref m) and instead send the following message:

SetWindowPos(Handle, new IntPtr(1), 0, 0, this.width, this.height, SWP_NOZORDER);

However, whenever I click on form it still brings it to the front. I also tried creating a WINDOWPOS struct, marshalling the pointer to the struct, then modifying the struct. I don't think that this changes the actual lParam in the message though.

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

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

发布评论

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

评论(2

爱格式化 2024-12-20 20:55:42

创建背景表单并将“主”表单的所有者表单设置为该背景表单。例如:

frmBackground backgroundForm = new frmBackground();
frmMain mainForm = new frmMain();
mainForm.Owner = backgroundForm;
backgroundForm.Show();
mainForm.Show();

Create background form and set owner form of your 'main' form to that background form. For example:

frmBackground backgroundForm = new frmBackground();
frmMain mainForm = new frmMain();
mainForm.Owner = backgroundForm;
backgroundForm.Show();
mainForm.Show();
喜你已久 2024-12-20 20:55:42

frmBackground.Enabled 设置为 false。

在你的主窗体中:

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        var bg = new Form();
        bg.WindowState = FormWindowState.Maximized;
        bg.ShowInTaskbar = false;
        bg.FormBorderStyle = FormBorderStyle.None;
        bg.Show();
        bg.Enabled = false;
        this.Owner = bg; // optional - see below
    }

如果你这样做:

this.Owner = f; 

那么当你单击背景窗体时,你的主窗体边框将会闪烁(至少在 Windows 7 中,我不确定其他版本)。无论哪种方式,将 Enabled 设置为 false 都会起作用。但是,当您单击背景表单时,您会听到蜂鸣声,这可能很烦人。可能有某种方法可以阻止它。

Set frmBackground.Enabled to false.

In your mainform:

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        var bg = new Form();
        bg.WindowState = FormWindowState.Maximized;
        bg.ShowInTaskbar = false;
        bg.FormBorderStyle = FormBorderStyle.None;
        bg.Show();
        bg.Enabled = false;
        this.Owner = bg; // optional - see below
    }

If you do this:

this.Owner = f; 

Then your main form border will flash when you click the background form (at least in Windows 7, I'm not sure about other versions). Either way, setting Enabled to false will work. But you'll get a beep when you click the background form, which may be annoying. There's probably some way to prevent it.

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