Hi.
How do I capture mouseclicks outside my newly created TCustomForm? It should work like the TCombobox dropdownwindow and be closed whenever you click anywhere.
Se code below:
I run show the form like this (not tested):
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"There is always another way to solve it, but I prefer my way.
How do I capture mouseclicks outside my newly created TCustomForm? It should work like the TCombobox dropdownwindow and be closed whenever you click anywhere.
Se code below:
Code:
unit RgListUnit;
interface
uses
StdCtrls, Dialogs, ExtCtrls, Forms, Graphics, Types,
Windows, Classes, Messages, Controls, WinProcs;
type
TRgScreenPanel = class(TCustomForm)
private
clListbox: TListbox;
protected
public
constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); override;
destructor Destroy; override;
end;
implementation
{ TRgScreenPanel }
constructor TRgScreenPanel.CreateNew(AOwner: TComponent; Dummy: Integer);
begin
inherited CreateNew(AOwner, Dummy);
BorderStyle := bsNone;
clListbox := TListbox.Create(self);
clListbox.Align := alClient;
clListbox.Parent := self;
clListbox.Items.Text := 'One'+#13#10+'Two'+#13#10+'Three';
end;
destructor TRgScreenPanel.Destroy;
begin
clListbox.Free;
inherited;
end;
end.
I run show the form like this (not tested):
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
p: TPoint;
clScreenPanel: TRgScreenPanel;
begin
p := ClientToScreen(Point(Button1.Left, Button1.Top+Button1.Height));
clScreenPanel := TRgScreenPanel.CreateNew(nil);
with clScreenPanel do
begin
Top := P.Y;
Left := P.X;
Show;
repeat
Application.HandleMessage;
until not clScreenPanel.Visible;
Free;
end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-"There is always another way to solve it, but I prefer my way.