espeterson
asked on
MouseDown on TDBComboBox
I want to trap the OnMouseDown on a TDBComboBox. I want to clear the box if right-mouse button is clicked on it.
There is no event for mousedown... how do I trap it?
thanks for the help.
There is no event for mousedown... how do I trap it?
thanks for the help.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, DBCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
procedure MyDBComboBoxMouseDown(Send
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TMyDBComboBox = class(TDBComboBox)
published
property OnMouseDown;
end;
var
Form1 : TForm1;
MyDBComboBox : TMyDBComboBox;
implementation
{$R *.DFM}
procedure TForm1.MyDBComboBoxMouseDo
Shift: TShiftState; X, Y: Integer);
begin
if ssRight in Shift then
begin
ShowMessage('Right Mouse Button has been Clicked...')
// Do whatever when right mouse button is clicked...
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyDBComboBox := TMyDBComboBox.Create(self)
with MyDBComboBox do
begin
Parent := Form1;
Left := 10;
Top := 10;
Width := 145;
Height := 21;
// Define any other properties...
end;
MyDBCombobox.OnMouseDown := MyDBComboBoxMouseDown;
end;
end.
Cheers,
Alan