2010-12-03 59 views
0

我製作了一個ThumbnailToolBarButton,我想將窗體帶到前面,我點擊按鈕。 I`ve試過這樣:C#將窗體帶到Windows 7 ThumbnailToolBarButton的單擊事件

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

在按鈕單擊事件,但形式出現,當i`ve移動鼠標從縮略圖的形式消失了。我怎樣才能使表格保持在最前面= false?

回答

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()); 
    } 
    } 

}

+0

非常感謝它的工作就像一個魅力尖端。尊重。 – Sp3ct3R 2011-07-13 12:37:13