现在从一个窗体SHOW另一个窗体,但只能SHOW一次出来,然后SHOW第二次的时候就不出来了,但是在ALT+TAL能调出来.好像排在了窗体的下面...
请问怎么将要SHOW出来的窗体设为总在最上.

解决方案 »

  1.   


    class Win32
            {
                [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
                public static extern bool SetWindowPos(
                    int hWnd,               // window handle      
                    int hWndInsertAfter,    // placement-order handle      
                    int X,                  // horizontal position      
                    int Y,                  // vertical position      
                    int cx,                 // width      
                    int cy,                 // height      
                    uint uFlags);           // window positioning flags   
                public const int HWND_BOTTOM = 0x1;
                public const uint SWP_NOSIZE = 0x1;
                public const uint SWP_NOMOVE = 0x2;
                public const uint SWP_SHOWWINDOW = 0x40;
            }        private void ShoveToBackground()
            {
                Win32.SetWindowPos((int)this.Handle, -1, this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height, 1);            //Win32.SetWindowPos(
                //    (int)this.Handle,
                //    (int),
                //    0, 0, 0, 0,
                //    Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.HWND_BOTTOM);
            }        private void Bar_Activated(object sender, EventArgs e)
            {
                //总在最上
                ShoveToBackground();
            }
            private void Bar_Leave(object sender, EventArgs e)
            {
                //总在最上
                ShoveToBackground();
            }
      

  2.   

    MessageBox.Show 方法
      

  3.   

    先新建个类,类名为win32,代码如上面的
    然后在你新窗体里using它
    using win32;
    private void Main_Load(object sender, EventArgs e)
    {
        Win32.SetWindowPos((int)this.Handle, -1, this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height, 1);
    }
      

  4.   

    用 窗体名.Activate() 就可以把已存在的窗体设为最上层显示窗体了啊。
      

  5.   

    如果一直显示的话用模式对话框!
    否则用  Activate() 激活。
      

  6.   

    不知道你指的是哪一个:
    1 用ShowDialog替换Show。
    2 设置TopMost属性。