简体   繁体   English

FMX:控制手柄

[英]FMX: Handle of controls

I'm working with DirectShow in firemonkey, and i have a problem with outputting Video.我在 firemonkey 中使用 DirectShow,但在输出视频时遇到问题。

iVideoWindow.Put_Owner(Panel1.Handle); 

I need handle of TPanel, to display video at it.我需要 TPanel 的句柄,以在其上显示视频。 But FMX controls have no handle.但是 FMX 控件没有句柄。 I know, that Firemonkey is not based on traditional windows and FMX do not provide this, but how to solve this problem?我知道,Firemonkey 不是基于传统的 windows 并且 FMX 不提供这个,但是如何解决这个问题? I have no idea, please, help me.我不知道,请帮助我。

If you want to get a window handle as an HWND (windows api) type, you can now call this function: 如果要获取HWND(windows api)类型的窗口句柄,现在可以调用此函数:

WindowHandleToPlatform(form1.Handle).wnd

Put in your uses section: 在您的使用部分中输入:

uses
  FMX.Platform.Win;

Note that just calling WindowHandleToPlatform(form1.Handle) will not work, you have to access .wnd to obtain the winapi handle. 请注意,仅调用WindowHandleToPlatform(form1.Handle)将不起作用,您必须访问.wnd以获得winapi句柄。

Since this makes an application less portable, it is also a good idea to put {$IFDEF MSWINDOWS} whenever doing this, and if you ever port to MacOS, you'll have to write code for that platform. 由于这使应用程序的可移植性降低,因此在执行此操作时放置{$ IFDEF MSWINDOWS}也是一个好主意,并且,如果您移植到MacOS,则必须为该平台编写代码。 Or put this code into a separate unit that deals with MS Windows related code only, and IFDEF the unit into your uses. 或将此代码放到一个单独的单元中,该单元仅处理与MS Windows相关的代码,然后将IFDEF单元用于您的使用。

FmxHandleToHWND is marked deprecated now. FmxHandleToHWND已被标记为已弃用。

WindowHandleToPlatform will convert given FireMonkey handle to its platform dependent window handle (in your case a Windows handle). WindowHandleToPlatform将给定的FireMonkey句柄转换为其依赖于平台的窗口句柄(在您的情况下为Windows句柄)。

To get handle of a panel, try this : 要处理面板,请尝试以下操作:

uses 
  FMX.Platform.Win;

var
  Handle : HWND;

begin

  Handle := TWinWindowHandle (Panel1).Wnd;

end;

Use Timage control, then you can assign your output to Image1.Bitmap.Handle.使用Timage控件,然后你可以将你的output分配给Image1.Bitmap.Handle。 Its the only component that provides window Handle under FMX FMX下唯一提供window句柄的组件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM