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

喜欢而已 提交于 2019-12-02 07:51:03

问题


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.


回答1:


Use WindowHandleToPlatform to get the Windows-specific TWinWindowHandle which has the Wnd property. This is the native window handle (HWND).



来源:https://stackoverflow.com/questions/25328042/delphi-firemonkey-cross-platform-generic-way-to-pass-a-windows-handle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!