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?

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

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!

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!!!

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.

Thanks !

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

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.

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 know findwindows does.

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

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.