Is it possible to make VCL element transparent to clicks like disabling hit test in FMX?
Delphi VCL make element "transparent" to clicks
Asked Answered
Put two Memos on the Form, but Memo2 partially behind Memo1 to test. Then add this code:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Memo2: TMemo;
procedure Memo2Enter(Sender: TObject);
procedure Memo2Exit(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
OriginalProc:TWndMethod;
procedure MyWindowProc(var Msg: TMessage);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
OriginalProc:=Memo1.WindowProc;
Memo1.WindowProc:=MyWindowProc;
end;
procedure TForm1.MyWindowProc(var Msg: TMessage);
begin
OriginalProc(Msg);
if Msg.Msg = WM_NCHITTEST then Msg.Result:=HTTRANSPARENT;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Memo1.WindowProc:=OriginalProc;
end;
procedure TForm1.Memo2Enter(Sender: TObject);
begin
Memo2.Color:=clRed;
end;
procedure TForm1.Memo2Exit(Sender: TObject);
begin
Memo2.Color:=clWhite;
end;
end.
© 2022 - 2024 — McMap. All rights reserved.
WinControl
writing aWM_NCHITTEST
handler returningHTTRANSPARENT
might do the trick. But I don't know if this works only on top level windows or all controls with a handle. – TwobyfourTCustomTransparentControl
allows clicks through when itsInterceptMouse
property is set to False. – CreditHTNOWHERE
toCM_HITTEST
. – Beaman