954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help needed on "MDI child forms"

Hi,
My parent MDI form (MDIForm1) has opens various child forms on their respective menu click events.
I want to know that :
1) How will I check if a particular child form is already open?
2) On closing the MDIForm1 if any of the child forms are open then it must popup a message box and wait until the user manually closes each and every child form before closing the parent MDIForm1. How should i do this?

RahulV
Junior Poster in Training
92 posts since Jun 2007
Reputation Points: 26
Solved Threads: 0
 

try to use some flag setting for loading and unloading of child forms and check the same during unload of the MDI form.

debasisdas
Posting Genius
6,872 posts since Feb 2007
Reputation Points: 666
Solved Threads: 434
 
try to use some flag setting for loading and unloading of child forms and check the same during unload of the MDI form.

OK,
I surely will try it out!

RahulV
Junior Poster in Training
92 posts since Jun 2007
Reputation Points: 26
Solved Threads: 0
 
try to use some flag setting for loading and unloading of child forms and check the same during unload of the MDI form.


Can u suggest some other methods like, is there any class or methods to detect the active child form and external windows. Such as App class?

Pls help!!!

RahulV
Junior Poster in Training
92 posts since Jun 2007
Reputation Points: 26
Solved Threads: 0
 

In the mdi parent (main form) when you want to get the caption of the foreground/active window, you can use msgbox me.activeform.caption to get the caption of the active child MDI form.

To find out if the window is loaded and visible you can use this (add it to the same code module as your other post):

Public Function IsLoadedAndVisible(frmName As String) As Boolean
Dim frm As Form
   
For Each frm In Forms
    If frm.Name = frmName Then
        IsLoadedAndVisible = frm.Visible
        Exit Function
    End If
Next

IsLoadedAndVisible = False
End Function

Then, whenever you want to know if a form is open or not, you can check with something like if IsLoadedAndVisible("mdiChild") = true then . Remember, if a MDI window is closed, and you access any property of the window by the MDI parent, the window will become visible and loaded again. So you can't use this if IsLoadedAndVisible(form1.name) = true then that will make form1 (assuming it is a MDI Child) visible and active again, even if the user closed it.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

Thanks !

and im calling a windows calculator how to find out whether a calculator is already active?

RahulV
Junior Poster in Training
92 posts since Jun 2007
Reputation Points: 26
Solved Threads: 0
 

FindWindow API Call. You might be able to use something like retval = appactivate("Calculator") , and then check the return value of retval for success or failure, but I'm not sure if appactivate returns a value... I know findwindows does.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

AppActivate("calculator") does not return an value!!!

FindWindow API Call. You might be able to use something like retval = appactivate("Calculator") , and then check the return value of retval for success or failure, but I'm not sure if appactivate returns a value... I knowfindwindows does.


Can u please explain wht did u mean by "FindWindow" ?

RahulV
Junior Poster in Training
92 posts since Jun 2007
Reputation Points: 26
Solved Threads: 0
 

Hi,

Check This Link

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

Will as of now I stop using VB6 so I have no VB6 here in my PC. but regarding with your problem I think there's a method or function that indicates the form whether is it activated or not or opened or not opened or you can make a function for it.

Or you can put a function in every form in Form_Unload that checks if it its ok to close directly or not because there are transactions that needs to be saved.

jireh
Posting Whiz
316 posts since Jul 2007
Reputation Points: 11
Solved Threads: 49
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You