简体   繁体   中英

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. 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?

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

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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