Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo
How to Deactivate all MDI child forms (Friday, October 08, 2004)
 

Found the following interesting discussion in the Newsgroups:

Deactivate all MDI child forms
by:Anonymous

By default it seems that there always must be an active MDI child form. But, I want to deactivate all of the MDI child forms when the user clicks on a control that is owned by the MDI parent. This is similar to how the MDI child forms in Visual Studio are deactivated when a docking window is selected. Is there any way to do this? I tried Me.ActivateMdiChild(Nothing) but that doesn't work.

Thank you,
Lance


 Reply:
by:v-phuang@online.microsoft.com (Peter Huang)

 Hi Lance,

First of all, I would like to confirm my understanding of your issue.
From your description, I understand that you wants to make your MDI
appliation work like the VS.NET IDE.
Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

I think the VS.NET IDE is not a usual MDI appliation. And we do not
recommend to change the default behavior of the MDI children form that
there will be one activated window by default. If you wants to make a
control something like VS.NET IDE, I think you may try to take a look at
the third party control.
Here is the link.
DotNetMagic
http://www.dotnetmagic.com/

Please apply my suggestion above and let me know if it helps resolve your
problem.

Best regards,

Peter Huang
Microsoft Online Partner Support



Posted by Xander Zelders



2 Comments:

Anonymous Anonymous said...

Hi Lance
To deactivate all Mdi child for paste this code in your control clicks event ::
dim frm as form
for each frm in me.Mdichildren
frm.close
next

12:16 PM  
Anonymous Barry said...

Well, what visual studio actually does is simply send the WM_NCACTIVATE (with WParam = 0) message to the active MDI child. This tells the child to draw itself 'unselected'.

That solution, however, is incomplete - if the form is forced to redraw for some reason (window is highlighted, menu opened, etc.), it will redraw itself as selected. So, to get around this, override the OnPaint procedure, and tell it to send a WM_NCACTIVATE message if the form should be deactivated [You will need a variable to track whether or not the form should be deactivated]. I believe this, too, is what visual studio does [You'll see alot of WM_NCACTIVATE 0 0 messages if you use Spy++ to inspect a MDI child of VS2005].

[I try to avoid Visual Basic if I can - so I don't know if you can override functions in it. But I'm sure there's a similar workaround]

8:55 PM  

Post a Comment

<< Home

 
Previous Posts
    - Typed dataset and the grid control
    - About Events in datagrid and SelectedIndexChanged
    - How to get SQL Server Timestamp value
    - How to disable F1 Thru F12
    - Copying files over network
    - How to simplify .NET setup program.
    - Thread Calls DLL, DLL Loops Infin, Application Stu...
    - How to set datagrid's datasource as arraylist
    - How to create PDF files
    - Invisible form appears in Alt-tab list

Archives
    - 10/03/2004 - 10/10/2004
    - 10/10/2004 - 10/17/2004
    - 10/17/2004 - 10/24/2004
    - 10/24/2004 - 10/31/2004
    - 10/31/2004 - 11/07/2004
    - 11/21/2004 - 11/28/2004
    - 11/28/2004 - 12/05/2004
    - 12/05/2004 - 12/12/2004
    - 12/12/2004 - 12/19/2004
    - 12/19/2004 - 12/26/2004
    - 12/26/2004 - 01/02/2005
    - 01/23/2005 - 01/30/2005
    - 01/01/2006 - 01/08/2006
    - 09/24/2006 - 10/01/2006


Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland