rowanphilip
rowanphilip

Reputation: 319

How can I get Delphi to wait for a form to close before continuing to execute code in another form?

My program has to search through a CSV file line by line and if a unique item is found, another form needs to be opened asking the user for more information on this item to store in a file before continuing to search the CSV file. I have browsed around looking for an answer and the only thing that I can find is showmodal which closes the pop-up form after it's finished. I need to keep the form open in case there is another unique item. I have also tried having a repeat, until loop which repeats until the value of a certain variable is changed by the pop-up form, allowing the program to continue when the pop-up form is hidden. This, however, does not seem to work and causes the pop-up form to be blank and unusable. Help please!

Upvotes: 1

Views: 2581

Answers (1)

Arioch 'The
Arioch 'The

Reputation: 16045

another form needs to be opened asking the user for more information on this item to store in a file before continuing

This is what called "Modal Window"

Hence it is displayed by .ShowModal method.

if ItemFound then begin
  user_info := false;
  user_prompt := CreateMessageDialog(... 'answer me!' );
  try
    user_choice := user_prompt.ShowModal();
    if IsPositiveResult(user_choice) then begin
       user_Var_1 := Trim(user_prompt.Edit1.Text);
       user_Var_2 := user_prompt.ListBox1.ItemIndex;
       ....
       user_info := True;
    end. 
  finally
    user_prompt.Destroy;
  end;
  if user_info then begin
    ...
  end;
end;

Read manuals:

Upvotes: 1

Related Questions