【问题标题】:C# bring form to front in Windows 7 ThumbnailToolBarButton's click eventC# 在 Windows 7 ThumbnailToolBarButton 的点击事件中将表单置于最前面
【发布时间】:2011-05-19 23:38:36
【问题描述】:

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

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

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

【问题讨论】:

    标签: c# windows-7 button thumbnails toolbar


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

    }

    【讨论】:

      猜你喜欢
      • 2010-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-07
      • 2013-06-08
      • 1970-01-01
      • 2023-03-30
      • 2016-06-23
      相关资源
      最近更新 更多