How to make OpenDialog show modal in Firemonkey?

When I'm calling an OpenDialog from my form on ButtonClick event. The dialog does not shows as modal and is also displays in taskbar (in WindowsXP). I can return to main form and click Open again and again - popping up several dialogs at once..

How do I make an OpenDialog to be modal in Firemonkey? Is it specifically made so that no modal dialogs are allowed due to multi-platform anture of FM?

EDIT: The bug is fixed in Update 3.

Answers


I think it's a bug. There are a lot of modal type bugs with FireMonkey, and hopefully they will be fixing them soon. Currently, even modal forms aren't modal.

For your problem, I have a workaround for Windows, but you might not like it.

You need to fix the following line in the TPlatformWin.DialogOpenFiles() method in FMX.Platform.Win.

Under with OpenFile do change:

hwndOwner := 0;

To this:

hWndOwner := FmxHandleToHWND(Application.MainForm.Handle);

The function utilizes the Windows GetOpenFileName API call, even though it's deprecated on Vista and above. If a owner handle is passed in, the dialog is modal, otherwise it's not.

You might want to submit this as a bug to qc.embarcadero.com along with the workaround.


Need Your Help

How to calculate inflection point in C# by a given function

c# math statistics regression

My function always looks like this: y = beta1 / (1 + exp(beta2 + beta3 * x)). With the data it can get, it always looks like a mirror of that (it starts with high values, then decreases)