C#将窗体带到Windows 7 ThumbnailToolBarButton的click事件中

时间:2010-12-03 20:54:32

标签: c# windows-7 button thumbnails toolbar

我制作了一个ThumbnailToolBarButton,我想把表单放到前面,然后单击按钮。我试过这个:

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

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

1 个答案:

答案 0 :(得分:0)

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

}