Click here to Skip to main content
15,886,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i have problem in declaration and using mouseEvents such as mouseClick and mouseMove in MyApplication_Startup.
how can i define them.
for example i want that when the application stars, if the user clicks the mouse, something happens.
plz help me
thanks alot
Posted

1 solution

Don't do that.

Application startup is where you initialize a bunch of things -- and that's all that should be done there.

It's generally not well defined what order things are intitialized at startup -- so if you do anything there that depends on anything else being initialized it might work one time and fail the next.


Also, the idea of "clicking the mouse when the application starts" is not well defined.

When exactly is "when the application starts"?

What happens if the click is a millisecond prior to your code executing, or a millisecond after??

(Plus, mouse clicks are probably a bad choice since windows applications are generally started by mouse clicks...)

At best you might read the keyboard state in your startup code and set a flag saying that some key is pressed or isn't pressed at that time. Then after your application is initialization is complete, check that flag and do whatever you wanted to do.

Or you might read the system clock in your startup code and save it somewhere. Then in your normal mouse event handling code (after initialization is complete) check if you are receiving a mouse event within some amount of time of the start up time. (Even that is not reliable since you can't predict how long your application will take to start since that's dependent on what else is happening in the system.)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900