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 prevent floating editor windows in eclipse 4 RCP apps?

eclipse-rcp e4

Eclipse 4 RCP apps support floating editor windows.

Android java.lang.NullPointerException solving?

android pointers null

I am working on camera application, where it take a picture and pass it to a another activity as a bitmap.