Making a visible form modal

Here is the scenario,
I have an application that has 2 main forms DATA and MAP. Both forms will always be open and visible. OK, in DATA when you click a button to input a new entity a modal form DATACHILD appears to facilitates input. An option is to select an element from MAP: I want to then use the MAP form that is already visible (because of MAP loading time I cannot fire it up anew every time). How do I get the MAP form to now act as a modal form for the DATACHILD form. Is this possible?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.


What about enabling both MAP and DATACHILD forms simultaneously (i.e. MAP will not be modal over the child form but will be enabled).

Let MAP form is decalred in unit2. Then on your DATACHILD form (Form3 in the example below) you have a button that enables the MAP form this way:

uses unit2; // MAP form is declared there

procedure TForm3.Button1Click(Sender: TObject);
  EnableWindow(MAP.Handle, True);

Note: MAP is the name of the MAP form.

Regards, Geo

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You could



or duplicate the functionality of the ShowModal function, which acts a a special filtering message loop, though that's nasty.

Will the first suggestion not do it?
davelaneAuthor Commented:
Did a bit of both: This function can be called from any form and makes the MAP form behave like a ModalForm. Any caveats to the following method?

function MAP.SelectFromMap: TModalResult;
  PrevActiveWindow: HWnd;
    Self.ButtonOK.Visible := true;
    Self.ButtonCancel.Visible := true;
    Self.Return := mrNone;

    // Enable myself and disable the form that called me
    PrevActiveWindow := GetActiveWindow;
    EnableWindow(Self.Handle, true);
    EnableWindow(PrevActiveWindow, false);
    SendMessage(Self.Handle, CM_ACTIVATE, 0, 0);
    until Self.Return <> mrNone;
    Result := Self.Return;

    // Disable myself and reenable that called me
    SendMessage(Self.Handle, CM_DEACTIVATE, 0, 0);
    EnableWindow(Self.Handle, false);
    EnableWindow(PrevActiveWindow, true);
    Self.OK.Visible := false;
    Self.Cancel.Visible := false;
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Things like timer events will still occur in either form.
davelaneAuthor Commented:
Yeah? But is that not also the case with ModalForms in general? If not then what have I done in the function above to cause this (presuming it is a bad thing).
Nope - Modal forms in general. Was just reminding you :-)

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.