PhilPlus 6 Posted March 5, 2022 Hello I am porting a project to FMX (from VCL). I use a TSaveDialog with Filter for the file extensions : SaveDialog1.Filter := 'Acrobat file PDF|*.pdf|'+ 'Excel file(*.xls)|*.xls|'; As the user has choice for some extensions, I use the 'OnTypeChange' event to know the chosen extension. But when I change the extension this event does'nt fire, but the 'OnShow' event fires ! I tried TOpenDialog with the same problem. Some informations : * Delphi Pro 10.3.1 (I tried Delphi 10.3.3) * Event 'OnFolderChange' does'nt fire. Any idea ? Is there any option I missed ? Or a known bug ? Thx Share this post Link to post
Mark b 0 Posted June 21 I'm having the same issue on several events with FMX TOpenDialog. Specifically OnFolderChange, OnSelectionChange and OnTypeChange. All of the other events I can trap on just not the one I need OnSelectionChange which is supposed to fire when file names displayed in the dialog are changed. The OnSelectionChange event occurs whenever the file selection is changed. This can include opening the file-selection dialog box, highlighting a file or directory, selecting a new filter, selecting a new directory, or creating a new folder. Did you ever get a work around or get it to work? Share this post Link to post
Remy Lebeau 1396 Posted June 21 (edited) Which target platform(s) are you having the trouble with? For instance, on Windows, those 3 TOpenDialog events in FMX are simply not hooked up at all (in VCL, they are). Which is funny because in later Delphi versions (not in 10.3), FMX's TOpenDialog component does actually receive those events from Vista+ (but not from earlier OS versions), but it does not pass them along to user event handlers (like VCL does). Fortunately, there is a workaround - you can write your own class that implements the IFMXDialogService interface, and then register an instance of that class with FMX via TPlatformService.AddPlatformService(). You can then implement the IFMXDialogService.DialogOpenFiles() method to do whatever you want, ie on Windows you can directly invoke the Win32 GetOpenFileName() or IFileOpenDialog API yourself and get UI events from it as needed. Edited June 21 by Remy Lebeau Share this post Link to post
Mark b 0 Posted June 21 Thanks for the reply, Currently working on Windows 11, however, the plan is to also build for Android (tablets) when compiler support becomes available. Yeah, I did an example in VCL and it works fine. I'm fairly new to this environment, but your workaround sounds like it would only work on windows? Is there a way to make it platform agnostic? Thanks again, Share this post Link to post
Remy Lebeau 1396 Posted June 21 (edited) 17 minutes ago, Mark b said: I'm fairly new to this environment, but your workaround sounds like it would only work on windows? Is there a way to make it platform agnostic? My example is specific to Windows, but the general approach is not. That is the point of providing your own IFMXDialogServices implementation - you can implement it for each target platform (which FMX does by default) and overwrite the default implementation as needed. TOpenDialog itself is platform-agnostic, it just delegates to IFMXDialogServices for the platform-specific stuff. You can have a different IFMXDialogServices class for each platform, or you can have 1 class with IFDEFs for each platform, etc. In any case, I just checked in Delphi 12.1 and FMX's default implementation of IFMXDialogService.DialogOpenFiles() (and a few other methods) for Android is a complete no-op (because modal dialogs are not supported on Android), which means that TOpenDialog would not do anything at all on Android. So, if you wanted to use TOpenDialog on Android then you would have to implement IFMXDialogServices yourself to display your own custom dialog. Edited June 21 by Remy Lebeau Share this post Link to post
Mark b 0 Posted June 21 I would have thought that FMX would be fully supported on all platforms or at least document which platforms aren't supported in the Embarcadero docs. I will start looking at IFMXDialogService, thanks again. Share this post Link to post