2008. február 10., vasárnap

How to create a modal form that does not stop the execution of the program


Problem/Question/Abstract:

I would like to create a form in my program that is a please wait type of form. I need the form to have the same behaviour as a modal form, but not to stop the execution of the program.

Answer:

So use Show to show the dialog and disable all other forms in your application using the same function a modal dialog uses:

function DisableTaskWindows(ActiveWindow: HWnd): Pointer;
procedure EnableTaskWindows(WindowList: Pointer);

Both are exported by the forms unit but are not documented. You use them like this:

var
  p: Pointer;

  waitform.show;
  application.processmessages; {needed to get form to paint}
  p := DisableTaskWindows(waitform.handle);
try
  { ... do stuff here }
finally
  EnableTaskWindows(p);
  waitform.close;
end;

Nincsenek megjegyzések:

Megjegyzés küldése