I have an application in Delphi 7, which pops up modal dialogs for several conditions. I am trying to determine if the dialog from a specific unit is open from another unit and close it. So far, I've tried with following code:
Wnd := GetLastActivePopup(Application.Handle);
if (Wnd <> 0) and (Wnd <> Application.Handle) then
PostMessage(Wnd, wm_close,0,0);
But, it closes all the opened dialogs. When I tried to specify for a specific form such as:
if (Wnd <> 0) and (Wnd <> FormTest.Handle) then
it throws Access Violation error.
How can I determine whether the dialog from specific unit is being popped up?