crazydragonx
asked on
Mouse Click
How can i make the mouse do the event click at runtime from my code ?
you can listen windows messaging .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
button1.Perform(WM_LBUTTON DOWN,-1,0 );
I assume you want the mouse click event to trigger at runtime.
For that the clicking event should occur upon some parent object like a form or a button.
In case of a button it is easy to invoke the mouse click event at runtime. It can be done by calling the click procedure for the button. thus just a single statement:
button1.click
would do the trick.
In case of a form it is a bit different from the button. Nevertheless this is also quite easy to do:
form1.formclick(applicatio n)
would do the job.
To invoke any event as such is easy:
If say 'OnClick(Sender: TObject)' was an event of object 'Object1'. You can at runtime or designtime associate a procedure with the event which will be executed when the event is invoked. At designtime it is quite simple. At runtime it can be done as follows:
Object1.OnClick := Object1click.
Note that the parameters of the event and the procedure must match.
This was on how to associate a procedure with the event.
Now to invoke the event at runtime the code is quite simple. It is as follows:
If Assigned(Object1.OnClick) do
Object1.OnClick(applicatio n);
This way any event can be invoked at runtime, let alone the mouse click event.
I hope the above solves your problem.
Best of luck!
For that the clicking event should occur upon some parent object like a form or a button.
In case of a button it is easy to invoke the mouse click event at runtime. It can be done by calling the click procedure for the button. thus just a single statement:
button1.click
would do the trick.
In case of a form it is a bit different from the button. Nevertheless this is also quite easy to do:
form1.formclick(applicatio
would do the job.
To invoke any event as such is easy:
If say 'OnClick(Sender: TObject)' was an event of object 'Object1'. You can at runtime or designtime associate a procedure with the event which will be executed when the event is invoked. At designtime it is quite simple. At runtime it can be done as follows:
Object1.OnClick := Object1click.
Note that the parameters of the event and the procedure must match.
This was on how to associate a procedure with the event.
Now to invoke the event at runtime the code is quite simple. It is as follows:
If Assigned(Object1.OnClick) do
Object1.OnClick(applicatio
This way any event can be invoked at runtime, let alone the mouse click event.
I hope the above solves your problem.
Best of luck!
John.