1
votes

So, i'm making firemonkey application, and for my vcl app's i was able to use SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE); so my app would always be on top if something else (browser) is focused at the moment. I'm trying to find something similar to do with firemonkey, are there any ideas,please? P.S. That code for firemonkey will be placed on OnChange event for some hidden Tedit. If it helps..

1

1 Answers

1
votes

You code still works fine except that in FMX a the Handle of a TForm is now of type TWindowHandle whereas it used to be of type HWND in VCL. You only need to convert your TWindowHandle to a HWND so you can pass it to SetWindowPos(..) as you used to do.

Typing firemonkey window handle into the internet search engine of my choice leads to many solutions, several of them right here on StackOverflow. Long story short: Use FMX.Platform.Win.WindowHandleToPlatform(..) to convert.

Example:

implementation

uses
  Fmx.Platform.Win,
  WinApi.Windows;

{$R *.fmx}

procedure TForm1.Button1Click(Sender: TObject);
var
    nativeWindowHandle: HWND;
begin
    nativeWindowHandle := Fmx.Platform.Win.WindowHandleToPlatform(Handle).Wnd;
    // TODO: Check for error when SetWindowPos returns false
    SetWindowPos(nativeWindowHandle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE or SWP_NOACTIVATE);
end;