简体   繁体   English

C#将表单放在Windows 7 ThumbnailToolBarButton的click事件中

[英]C# bring form to front in Windows 7 ThumbnailToolBarButton's click event

I've made an ThumbnailToolBarButton and I want to bring the form to front whwn i click the button. 我做了一个ThumbnailToolBarButton,我想将表单带到前面,然后单击按钮。 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? 我怎样才能使表格以topmost = false保留在前面?

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

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM