How to make OpenDialog shown modal in Firemonkey?

When I call OpenDialog from my form in the ButtonClick event. The dialog is not displayed as modal, but is also displayed on the taskbar (in WindowsXP). I can return to the main form and click "Open" again and again - several dialogs appear immediately.

How to make OpenDialog modal in Firemonkey? Is this specifically so that modal dialogs are not allowed due to the multi-platform surroundings of FM?

EDIT: Fixed bug in update 3.

+4
source share
1 answer

I think this is a mistake. There are many modal type errors in FireMonkey, and hopefully they will fix them soon. Currently, even modal forms are not modal.

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

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

In with OpenFile do change:

 hwndOwner := 0; 

For this:

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

The function uses the Windows API call GetOpenFileName , even if it is deprecated in Vista and later. If the owner descriptor is passed, the dialog is modal, otherwise it is not.

You might want to present this as an error for qc.embarcadero.com along with a workaround.

+3
source

Source: https://habr.com/ru/post/1383827/


All Articles