Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top