小弟不才,请教各位大大。
我在程序中弹出了如下MessageBox窗体作为提示信息:    MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);可是当程序执行到这里时,MessageBox并不总是弹出到最前。于是考虑使用win32的API将弹出的MessageBox手动置最前如下:            int i = FindWindow(null, "提示");
            IntPtr hWnd = new IntPtr(i);
            SetWindowFront(hWnd);可是,在调试的时候又发现当程序执行到MessageBox的时候就会停住了,后面的操作都需要等弹出的窗体点OK之后才会执行,那样也就没有意义了。我考虑能不能将这里改为多线程执行,或者有其他更好的办法?望赐教。

解决方案 »

  1.   

    API MessageBox,第一个参数的handle指定为你的主窗口。
      

  2.   

    DialogResult choice=MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
    if(choice==DialogResult.Yes)
    {
    .......
    }
      

  3.   

    我的意思是MessageBox.Show弹出的对话框并不总是在最前面的,所以我想手动把他置为最前
      

  4.   

    用这个重载public static MessageBoxResult Show(
    Window owner,
    string messageBoxText,
    string caption,
    MessageBoxButton button
    )
      

  5.   

    不如用scriptPage.RegisterStartupScript("alert", "<script language='javascript'>alert(\"我弹!\")</script>");
      

  6.   

    用 Spy++  之类的工具 先 查下 确认 没有问题  你自己在模拟鼠标点OK 不就行了
      

  7.   

     int i = FindWindow(null, "提示");
      IntPtr hWnd = new IntPtr(i);
      SetWindowFront(hWnd);
    这都用了  还不会用  SendMessage(ah.ToInt32(), (uint)0x0201, 0, 0x012b01bf);
                SendMessage(ah.ToInt32(),(uint) 0x0202, 0, 0x012b01bf);
      

  8.   

    你新开线程进行MessageBox.Show弹出操作,然后在主线程中
    int i = FindWindow(null, "提示");
    IntPtr hWnd = new IntPtr(i);
    SetWindowFront(hWnd);
    =============
    不过没多大意义
      

  9.   

    最好自定义个form窗体,在show后,进行focus操作,即个性化,又方便。