Home > OS >  Delphi FireMonkey multi HWND in a form
Delphi FireMonkey multi HWND in a form

Time:05-04

I am quite new to FireMonkey.

I am shifting an old VCL project to Firemonkey. One of the requirements is I need to embed several video players in one form. The player itself needs an HWND parameter to handle its messages. It is very easy to implement using some TPanels in VCL, but I have no idea how to do that in FireMonkey since TCommonCustomForm is the only "container" class I could find that supports TWindowHandle which I can get an HWND.

I googled and found a solution that embeds a FireMonkey form into a VCL form but I failed to do that if I use two FireMonkey forms (perhaps I did it in a wrong way). Some other topics showing how to "move" controls from form1 to form2 are not what I am looking for since I need multiple HWNDs.

How can I do that in FireMonkey? Are there any other TWindowHandle objects that can meet my requirement?

TIA

Edward

CodePudding user response:

Unlike VCL Media Player which renders its content to a specific window Firemonkex Media Player does not support rendering to specific window. Instead FMX Media player is rendering its content to specific TMediaPlyerControl that you place on the form. And yes you can have multiple such controls placed on the form each being connected to its own Media Player.

On Windows this allows to easily play multiple media files at the same time.

But I'm not sure this will work on all other platforms that are supported by Delphi. The reason for this is that on some other platforms like Android and iOS TMediaPlayer just wraps around OS based media player which can perhaps have some of its own limitations like only one active instance.

CodePudding user response:

Finally, I solved this problem by cloning a new control from TMediaPlayerControl and replacing TMediaPlayer with our video player component.

One issue was the new video window did not generate mouse events since it uses DefWindowProc as message handler proc. Just set the lpfnWndProc to a new proc that will forward mouse messages to its parent HWND(your form Handle) when calling Windows.RegisterClass().

Thanks, @SilverWarior.

  • Related