Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onmouse event

Status
Not open for further replies.

auditdi30

Programmer
Feb 25, 2009
39
NO
Hello!

Using D7 and XP.

Is trying to make a onmouse event to a button working without success. I have the following code in my onmouse event;

if shift=[ssctrl] then form1.label1.caption:='Test';

But if I held down the Ctrl key and click the mouse, the label1 doesn't change. What is wrong??

And a second question; if I have a code in the onclick event, will that code be runnig before onmousedown event?

TIA
Kåre!
 
What is an OnMouse event?

I'm assuming that you mean an OnMouseDown event. Your code should look something like this:
Code:
 if ssctrl in shift then begin
   form1.label1.caption:='Test';
 end;

You can easily determine which event should come first by writing something like this
Code:
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    memo1.lines.append ( 'down' );
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  memo1.lines.append ( 'click' );
end;
Run the program, click on the button and see which event occurs first. Although if you think about it, it should be obvious.

Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top