Delphi FMX – click through form. HitTest not available

Create a Delphi FireMonkey (FMX) form that the user can click through

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
    self.BringToFront;
  • Anything that causes the SetWindowLong call to not work.

Platforms

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.

About Me

scott_hollows_201611

  • 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
blog email linkedinlogo

Author: Scott Hollows

Enterprise software developer based in Perth, Western Australia. Oracle, Delphi, Data Warehouse design and ETL, Data Architect, Business Intelligence, Oracle performance tuning. Oracle ApEx, Discoverer, BI Publisher, OBIEE, Forms, Reports, SQL, PLSQL Australian Delphi User Group (ADUG) - WA branch manager and past national president LinkedIn www.linkedin.com/in/scotthollows

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s