桌面上的窗口/winforms 中最底部的窗口
我试图在启动时启动一个表单,并让它在应用程序运行的整个过程中保留为背景。本质上我想隐藏所有桌面图标并拥有空白背景。此外,当用户单击某些按钮时,我希望表单 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建背景表单并将“主”表单的所有者表单设置为该背景表单。例如:
Create background form and set owner form of your 'main' form to that background form. For example:
将
frmBackground.Enabled
设置为 false。在你的主窗体中:
如果你这样做:
那么当你单击背景窗体时,你的主窗体边框将会闪烁(至少在 Windows 7 中,我不确定其他版本)。无论哪种方式,将 Enabled 设置为 false 都会起作用。但是,当您单击背景表单时,您会听到蜂鸣声,这可能很烦人。可能有某种方法可以阻止它。
Set
frmBackground.Enabled
to false.In your mainform:
If you do this:
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.