Delphi Firemonkey跨平台 - 通用Windows句柄的通用方式 [英] Delphi Firemonkey Cross Platform - Generic way to pass a Windows Handle

查看:446
本文介绍了Delphi Firemonkey跨平台 - 通用Windows句柄的通用方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows和OSX的第二个Firemonkey应用程序中处于深深的位置,并缓慢转换我的函数库来处理跨平台问题。我正在尝试创建一个通用的SelectDirectory函数,它将为Windows或OSX运行特定于平台的代码。我有SelectDirectory对于单独调用的两个平台都很好,但Windows具体需要一个hwndparent句柄来运行。

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.

这是在IFDEF MSWINDOWS指令中运行(就像OSX一个在其编译器指令中)。我如何传递一个通用的句柄到这个函数,或者如何引用Application.MainForm或一些可以投射到这个函数中的Windows句柄?我希望避免在这个库的uses子句中使用Firemonkey特定的单元。我宁愿以某种方式传递一个THANDLE,并将其转换为函数内的一个TWindowHandle,但是经过一个小时的工作之后,我没有看到如何做,而不会影响我的库的有用性。

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.

任何帮助赞赏。

推荐答案

使用 WindowHandleToPlatform 获取Windows特定的具有 Wnd 属性的TWinWindowHandle 。这是本机窗口句柄( HWND )。

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

这篇关于Delphi Firemonkey跨平台 - 通用Windows句柄的通用方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆