Skip to content

Attaching SDL2 to an Existing FMX Window Delphi 10.2

I want to use SDL_CreateWindowForm to initialize SDL2 video on an existing window using Firemonkey.

Since FMX is a cross-platform, I need to find the native window handle for each platform. In my case, it is Windows.
Using FMX.Platform.Win unit, I can call:

nativeHandle := WindowHandleToPlatform( myForm.Handle).Wnd;
//then pass the handle to SDL2, the secret is to pass it casting to Pointer)
fWindow := SDL_CreateWindowFrom(pointer(nativeHandle);

This was the method I used to make it work!