模式窗体有他的 Parent 除此之外对其他的窗体没有影响。

解决方案 »

  1.   

    ShowDialog(Parent)
    楼上的方法可能可行。。
      

  2.   

    See belows
       MSDN Home >  MSDN Library >  .NET Development >  Visual Studio .NET >  Developing with Visual Studio .NET >  Creating Windows Applications >  Windows Forms >  Creating Windows Forms  
    Visual Studio   Displaying Modal and Modeless Windows Forms
    Forms and dialog boxes are either modal or modeless. A modal form or dialog box must be closed or hidden before you can continue working with the rest of the application. For more information about working with dialog boxes, see User Input to Dialog Boxes. Dialog boxes that display important messages should always be modal. The About dialog box in Visual Studio is an example of a modal dialog box. MessageBox is a modal form you can use. Modeless forms let you shift the focus between the form and another form without having to close the initial form. The user can continue to work elsewhere in any application while the form is displayed.Modeless forms are harder to program, because users can access them in an unpredictable order. You have to keep the state of the application consistent no matter what the user does. Often, tool windows are shown in a modeless fashion. The Find dialog box, accessible from the Edit menu in Visual Studio, is an example of a modeless dialog box. Use modeless forms to display frequently used commands or information.To display a form as a modal dialog box Call the ShowDialog method. 
    The following example shows how to display a dialog box modally. ' Visual Basic
    Dim frmAbout as New Form()
    ' Display frmAbout as a modal dialog
    frmAbout.ShowDialog()// C#
    //Display frmAbout as a modal dialog
    Form frmAbout = new Form();
    frmAbout.ShowDialog();// C++
    Form * frmAbout = new Form();
    //Display frmAbout as a modal dialog
    frmAbout->ShowDialog();
    The Form.ShowDialog method has an optional argument, owner, that can be used to specify a parent-child relationship for a form. For example, when code in your main form shows a dialog box, you can pass Me (in Visual Basic) or this (in C#) as the owner of the dialog box to establish your main form as the owner, as the following code shows. ' Visual Basic
    Private Sub mnuAbout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
       Dim f As New Form()
       f.ShowDialog(Me)
    End Sub// C#
    private void mnuAbout_Click(object sender, System.EventArgs e)
    {
       Form f = new Form();
       f.ShowDialog(this);
    }// C++
    private:
       System::Void mnuAbout_Click(System::Object *  sender,
          System::EventArgs *  e)
       {
          Form * f = new Form();
          f->ShowDialog(this);
       }
    To display a form as a modeless dialog box Call the Show method. 
    The following example shows how to display an About dialog box in modeless format. ' Visual Basic
    Dim f As New Form()
    ' Display frmAbout as a modeless dialog.
    f.Show()// C#
    //Display frmAbout as a modeless dialog
    Form f= new Form();
    f.Show();// C++
    Form * f = new Form();
    //Display f as a modeless dialog
    f->Show();
    Note   If a form is displayed as modal, the code following the ShowDialog method is not executed until the dialog box is closed. However, when a form is shown as modeless, the code following the Show method is executed immediately after the form is displayed. 
    See Also.....Introduction to Windows Forms | Creating Windows Forms | Walkthrough: Retrieving Dialog Box Information Selectively Using Multiple Properties | Retrieving Dialog Box Information Collectively Using Objects | Dialog Boxes in Windows Forms 
     
    Manage Your Profile |Legal |Contact Us |MSDN Flash Newsletter
    ©2004 Microsoft Corporation. All rights reserved. Terms of Use |Trades |Privacy Statement  
      

  3.   

    调用窗体的ShowDialog 就是显示模式窗体
    调用窗体的Show就是非模式窗体
      

  4.   

    private void mnuAbout_Click(object sender, System.EventArgs e)
    {
       Form f = new Form();
       f.ShowDialog(this);
    }在这段代码中,是否this就是大家说到的Parent?如果是的话大家提供的方法解决不了我说的问题。
    我试过给需要模式显示的窗体(选项窗口)设置owner对象(this),但如果仍用模式显示的话仍旧屏蔽了另外一个窗口(对话窗口),除非对话窗口在选项窗口显示出来后接收一个事件作了一次hide和show操作后才不被对话窗口屏蔽;如果用非模式显示的话虽然能保证选项窗口显示在主窗口前面但屏蔽不了主窗口,也不能满足我的要求大家继续想办法啊
      

  5.   

    我刚才试啦好像也不行,有种可能就是程序试两个进程(一个exe调用另外一个exe 后者dll),(主窗体和选项是一个进程,而聊天窗体是另外一个进程的窗体)
      

  6.   

    不知道为什么会这样 也许你只能在对话框出来以后Hide下对话窗口了
      

  7.   

    突然想到另一个替代方法
    也许能够帮得上忙
    在对话框窗口里添加如下方法
    public DialogResult ShowDialogBase(Form owner)
    {
    bool closed = false;
    owner.AddOwnedForm(this);
    this.Visible = true;
    owner.Enabled = false;
    while(DialogResult.None == this.DialogResult)
    {
    Application.DoEvents();
    if(!this.Visible)
    {
    this.DialogResult = DialogResult.Cancel;
    closed = true;
    break;
    }
    System.Threading.Thread.Sleep(0);
    }
    owner.Enabled = true;
    if(closed) owner.BringToFront();
    this.Visible = false;
    owner.RemoveOwnedForm(this);
    return this.DialogResult;
    }调用ShowDialogBase来代替ShowDialog,
    不是尽善尽美,不过对一般的应用可以作为一个选择
      

  8.   

    抱歉 在While之前还需要添加一句
      this.DialogResult = DialogResult.None;
    否则第二次ShowDialogBase就不正常了 :)
      

  9.   

    调用窗体的ShowDialog 就是显示模式窗体
    调用窗体的Show就是非模式窗体
      

  10.   

    public DialogResult ShowDialogBase(Form owner)
    {
    bool closed = false;
    owner.AddOwnedForm(this);
    this.Visible = true;
    owner.Enabled = false;
    while(DialogResult.None == this.DialogResult)
    {
    Application.DoEvents();
    if(!this.Visible)
    {
    this.DialogResult = DialogResult.Cancel;
    closed = true;
    break;
    }
    System.Threading.Thread.Sleep(0);
    }
    owner.Enabled = true;
    if(closed) owner.BringToFront();
    this.Visible = false;
    owner.RemoveOwnedForm(this);
    return this.DialogResult;
    }
      

  11.   

    owner.Enabled = false;这句代码虽然保证了owner窗体不可被操作,但同时灰掉了owner窗体上的所有控件,在界面上不可接受,另外每一个子窗体都需要进行这种操作很繁琐,还有如果弹出一个对话框怎么办?不使用MessageBox?会有点烦的
    我想问的是有没有一种机制可以让ShowDialog不屏蔽整个Application大家继续?谢谢!
      

  12.   

    我想MSN可能是另启动了一个里程,要不这也是不可能实现的.我做到了你要的效果,就是另启了一个线程:
    System.Diagnostics.Process p =new System.Diagnostics.Process();
    p.StartInfo.FileName=Application.ExecutablePath;

    p.Start();
    可以把程序写成一个带参数的,这样可以用StartInfo.Arguments来传递参数,使程序在不同的参数下显示不同的内容;
    这样就实现了你的目的.