C# 在 Windows 7 ThumbnailToolBarButton 的单击事件中将表单置于前面

发布于 2024-10-06 03:01:44 字数 239 浏览 0 评论 0原文

我制作了一个 ThumbnailToolBarButton,我想在单击该按钮时将表单置于前面。我已经尝试过:

this.TopMost = true;
this.Focus();
this.BringToFront();
this.TopMost = false;

在按钮单击事件中,但出现了表单,当我将鼠标从缩略图上移开时,表单消失了。如何使表单保留在 topmost = false 的前面?

I've made an ThumbnailToolBarButton and I want to bring the form to front whwn i click the button. I`ve tried this:

this.TopMost = true;
this.Focus();
this.BringToFront();
this.TopMost = false;

in the button click event but the form appear and when i`ve move the mouse away from the thumbnail the form disappear. How can i make the form remain in front with topmost = false?

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

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

发布评论

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

评论(1

望喜 2024-10-13 03:01:44
using System.Runtime.InteropServices;  
...  
namespace N  
{  
   class C {  
     [DllImport("User32.dll")]  
     public static extern Int32 SetForegroundWindow(int hWnd);  
     ...  
     void f(){  
          SetForegroundWindow(this.Handle.ToInt32());  
     }  
  }  

}

using System.Runtime.InteropServices;  
...  
namespace N  
{  
   class C {  
     [DllImport("User32.dll")]  
     public static extern Int32 SetForegroundWindow(int hWnd);  
     ...  
     void f(){  
          SetForegroundWindow(this.Handle.ToInt32());  
     }  
  }  

}

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