Delphi Firemonkey Cross Platform – Generic way to pass a Windows Handle


I’m knee deep in my second Firemonkey app for Windows and OSX and slowly converting my library of functions to handle cross platform issues. I am trying to create a generic SelectDirectory function that will run platform specific code for Windows or OSX. I have SelectDirectory working great for both platforms called individually, but the Windows specific one requires a hwndparent handle to run.

This is being run in a IFDEF MSWINDOWS directive (just as the OSX one is in its compiler directive). How can I pass a generic handle to this function or how can I reference Application.MainForm or something that can be cast into a Windows handle inside this function? I am hoping to avoid using Firemonkey specific units in the uses clause of this library. I would rather pass in a THandle somehow and cast it into a TWindowHandle inside the function, but after an hour of working on it, I don’t see how to do it without compromising the usefulness of my library.

Any help appreciated.

Comments are closed.