This post shows you how to create a Delphi FireMonkey (FMX) form that the user can click through as if the form did not exist.
The form can be transparent or not transparent
Many FMX components have a HitTest property. If you set this to FALSE, the mouse will click through the component as if it is not there. Unfortunately, TForm does not have this HitTest property, but you can achieve the same result with this …
// uses FMX.Platform.Win // ,Windows; SetWindowLong( FmxHandleToHWND(Handle) // convert FMX handle to Windows hwnd handle ,GWL_EXSTYLE ,WS_EX_LAYERED or WS_EX_TRANSPARENT );
If it doesn’t work …
Some window operations will prevent the code from working so make sure you call the above code after you do any of the following
- Making the window OnTop
self.FormStyle := TFormStyle.StayOnTop;
- Bringing the window to the front
- Anything that causes the SetWindowLong call to not work.
This solution will only work on Microsoft Windows.
Please post a comment if you know how to add click through to a FireMonkey form on other platforms.
- Oracle & Delphi software developer based in Perth, Western Australia
- Australian Delphi User Group – WA branch manager, past national president
- Australian Oracle User Group – WA State Committee Member
Available to do remote presentations to user groups on Delphi and Oracle topics