Search code examples
delphidelphi-7vcltform

Delphi Non Blocking ShowModal


I was wondering if theres a method to show a TForm without waiting for it (kinda like TForm.Show). But what I would like is to BLOCK all other forms (just like in ShowModal)

Example:

I have Form1 and Form2. Form1 has a button that should open Form2 but Form1 is blocked, yet the click of the button still continues the code that came AFTER Form2 opened.

procedure TForm1.Button1Click(Sender: TObject);
begin
  Form2.ShowModal; // ===> Something like that but the Code should continue, yet Form1 and all other forms are blocked (disabled)
  MessageBox (0, 'Code continues', '', 0);
end;

Hope you know what I mean.


Solution

  • You can call DisableTaskwindows, excepting your Window from beeing disabled and later EnableTaskWindows to enable other forms again.

      Form3.Show;
      FP:=DisableTaskwindows(Form3.Handle);
      //Some Code
      EnableTaskwindows(FP);