How to obtain firemonkey MacOS window ID?

Viewed 180

On MS Windows one can obtain a window handle by using:

WindowHandleToPlatform(winhandle).wnd

How does one obtain a MacOS Window "id":

for example a function that accepts a window id:

CGWindowListCreateImage(
  CGRect screenBounds, 
  CGWindowListOption listOption, 
  CGWindowID windowID,  // <------------------ here
  CGWindowImageOption imageOption);
1 Answers

On Windows, WindowHandleToPlatform() retrieves a TWinWindowHandle for a given TFmxHandle. TWinWindowHandle contains (amongst other things) the window's HWND.

On OSX, WindowHandleToPlatform() retrieves a TMacWindowHandle, which contains the window's NSWindow, NSView, NSTrackingArea, and NSOpenGLView objects. You can get a CGWindowID from the NSWindow.windowNumber field, eg:

WindowHandleToPlatform(winhandle).Wnd.windowNumber
Related