Click here to Skip to main content
15,902,845 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi ,
I need to know how can i stop the mouse click on the form in C# windows application.
i need to keep the other forms of the application active and need to disable clicks on just this one form.
i dont want to use the form.Enabled = false property as it greys out the entire form.
i have been looking in Message Filters but am unable to make proper use of them.

Please help.

Regards,
Saurabh
Posted
Comments
Saurabh.abhyankar 14-Jul-11 0:21am    
Thank you guys for the help . I think i will go with the Enabled = false property as most of u suggest. Thanks a lot

You should use Enabled, that's what it's there for. The greying out is a UI cue so that users of your application know that the form is not going to respond to input, instead of just thinking it crashed.

You can just have a boolean flag and check that in your Click or MouseDown events and not do anything if events are 'turned off'.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 13-Jul-11 16:25pm    
You're absolutely right, my 5. I added an explanation on why do I think so -- please see my solutions.
--SA
Mohammad A Rahman 15-Jul-11 19:16pm    
5, nice explanation.
If you don't use Enabled and confuse the user and make them feel like an idiot who clicks and clicks and nothing happens. What you want it possible, but you should not want it. Your users will through your application to dumpster real quick where it truly belongs. Don't get yourself in trouble.

—SA
 
Share this answer
 
Comments
Espen Harlinn 13-Jul-11 18:07pm    
Good point, my 5
Sergey Alexandrovich Kryukov 13-Jul-11 18:18pm    
Thank you, Espen.
--SA
KUMAR619 24-Jul-15 19:57pm    
I am having a doubt regarding mouse click.
I am loading a gridview containig nearly 3000 records. while its populating if I click anywhere on the form I get a not responding message.
I tried Disabling mouse Click, deregistering event handler and even diabled the form but none of these works. Kindly help me to get rid of this issue.
Sergey Alexandrovich Kryukov 24-Jul-15 21:11pm    
Of course your click won't be handled if you do everything in the UI thread...
—SA
KUMAR619 27-Jul-15 2:50am    
@SA Then how can I stop the "Not Responding Message".
 
Share this answer
 
Do not put anything in the form that is clickable. For instance, use a caption rather than a textbox to display data.

If you do, capture the click event for that object to pass the focus to where you would like.
 
Share this answer
 
v2
You should change the cursor of the mouse to a Wait Cursor then when you are finished with your process change it back to the Arrow Cursor. However, I think setting the enable to false is a good option as well.
 
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