views:

297

answers:

1

ALT + TAB is not working after displaying MessageBox on modal dialog...

I've three projects (P1, P2 and P3) under one solution file. P1 contains P1Form.cs, P2 contains P2Form.cs.

Detail of these files are as follow:

P1Form.cs contains one button which shows the Message box from MessageBox.Show() method. P2Form.cs contains one button which shows the Message box from MessageBox.Show() method.

Project P3 contains 3 forms Form_A, Form_B and Form_C. Form_A is the MDI container and has one button which opens the Form_B as its child form. Form_B has also one button which open the Form_C as modal dialog from ShowDialog() method.

Form_C is inherited from P2Form.cs and P2Form.cs is inherited from P1Form.cs. Form_A.cs is the Main form which will be the first form for application.

Steps to Reproduce desired issue:

  1. Open the Form_A which is the MDI Container
  2. Click on button which will open the Form_B
  3. Again click the button on the Form_B which will open the Form_C which will be having two buttons (both buttons are from base classes P1Form.cs and P2Form.cs)
  4. Click the any button of Form_C which will open the message box.

Issue: Now switch the window through Alt + Tab. You will not be able to see the current windows icon on switching window.

Alternative options which I tried...

  1. If I use Form.show() instead of Form.ShowDialog, then it works fine.
  2. If I write all messageBox coding in current class instead of writing in base class, then it works fine.

Can anyone suggest me how can I resolve this issue without doing both above mentioned alternatives which I had already tried?


Thanks Prashant Sethia

+1  A: 

Try setting up a parent-child relationship from Form_B (parent) to Form_C (child):

Form_C f = new Form_C();
f.ShowDialog(this);
alexm
Forgot to add the MSDN link:http://msdn.microsoft.com/en-us/library/aa984358(VS.71).aspx#Mtps_DropDownFilterText
alexm
Can't you edit your own post? +1 anyway. This is the answer I would give.
jpbochi