Delphi Help Please

I use delphi 6, and I have a button, and at a point in the button, I want another form to pop up (that’s easy form.visible), but I want the code in the first button to wait until the user finishes entering all his/her info in the second form before continuing past the point where I made the second form visible.

The user will push a button, the results will be stored in variables, then I want the code in my first button to start up again.

I don’t want the code after where I made the second form visible to execute, because the code after that point needs to use variables that are filled by the second form.

How can I do this?

References to forums where I would get answers would be appreciated too.

Thanks!

Looks to me like you want Form.Showmodal, rather than Form.visible.

Your best source for Delphi help is newsgroups.borland.com

As LionelHutz said, ShowModal is the answer. Just make sure your secondary form has buttons that return at least mrOK and mrCancel (and optionally, mrAbort, mrRetry, etc.). You can do this easily by adding buttons as required to your secondary form and setting their ModalResult properties in the Object Inspector. If you’re using a standard dialog (see File -> New -> Other -> Dialogs), the standard buttons are already there, but you can modify them or add more as you see fit.

Then, in the button click event where you want to invoke this form, do something like this:


with frmSecondaryForm do
  if ShowModal = mrOK then
  begin
    { perform your data persistence or calculations here }
  end;


If you want to get more specific and do other things depending on what button they clicked to close the secondary form, do something like this:


with frmSecondaryForm do
  case ShowModal of
    mrOK:
    begin
      { perform your data persistence or calculations here }
    end;
    mrCancel: ShowMessage('Operation cancelled');
    mrAbort: ShowMessage('Operation aborted');
  end;