|
LITTLEBLACKDOG.COM
|
| Author |
Message |
cmurphy
Stray Dog

Joined: 19 Sep 2006 Posts: 41
Location: US
|
Posted:
Thu Feb 08, 2007 4:48 pm Post subject: Disable mouse click? |
|
I want to prevent user to click around in any part of my C# windows application (button, menu and so on) while my application saving file. This is a drawing program. This is my boss's project and I'm adding features.
It saving serveral image & rtf files at the time so if user keep click around or try to drawing more anyway, it will crash my application. I've search google and found few refers to API but I'm not familiar with it. I'm not sure how should I proceed this.
I have a small pop-up display progress bar while it's saving. I make it always on top but the problem is my user still can click on my main application and continue do other thing.
Is there a better way? Please advice, |
|
|
|
|
|
|
T
Curmudgeon

Joined: 17 May 2001 Posts: 16187
Location: Airstrip One
|
Posted:
Thu Feb 08, 2007 4:53 pm Post subject: |
|
http://en.wikipedia.org/wiki/Modal_window perhaps? |
_________________ Got questions? Click here.
Still got questions? Click here, too.
affabletoaster, Akely, anglachel, blahpony, CMTG, EdisonRex, Elk, Equin, evilness, Fido, fathertyme, Goddess, Jaymac, je, jodygirl, KingKobra, Lycander, mally, Max, OhioArt2, perrito_blanco, Rover, Spot, sully_51, Superdwarf, the taz man, thriftyjack, twiztid, wrathiron, yiayia49
Would you like good music at a price that is right? CD Baby, baby.
You look like you need a monkey.
|
|
|
|
|
cmurphy
Stray Dog

Joined: 19 Sep 2006 Posts: 41
Location: US
|
Posted:
Tue Feb 13, 2007 3:17 pm Post subject: |
|
I did but user still be able to continue whatever they are doing. I just want to somehow prevent them to mouse click on any part of the program. Thanks away. |
|
|
|
|
|
|
Lycander
Lead Dog


Joined: 24 May 2002 Age: 25 Posts: 12198
Location: The Constitution State
|
Posted:
Tue Feb 13, 2007 3:41 pm Post subject: |
|
Hehehe.... hide the main appication window Then unhide it when you're done.
That's the quick and dirty way to do it. The longer and probably more visually appealing way to do it is to create a global variable that's basically a boolean, "allowMouseEvent." When you start the saving routine, set it to false. Then in every mouse event handler you'd have to check the global variable to see if mouse event processing it allowed or not. |
_________________ To the top of hunger mountain
I found my solitary ways
Where I could live on nuts and honey
And take my shelter in a cave
|
|
|
|
|
CMTG
Leg Humper


Joined: 23 Feb 2002 Posts: 4959
Location: On average, Cheltenham.
|
Posted:
Tue Feb 13, 2007 4:21 pm Post subject: |
|
Globals? Pah... What's wrong with just disabling the relevant controls while your application is saving? Try System.Windows.Forms.Control.Enabled. (Or maybe even EnableWindow(hwnd, bool); if you're into Win32API.)
The most elegant way is, of course, to do what Toxin suggests and make your progress window a modal dialog rather than always-on-top. Modal dialogs effectively disable their parent windows. Try System.Windows.Forms.Form.ShowDialog. (Or DialogBox() etc...) |
_________________ Pie. I wish I could
constrain my hungry greed but...
Sadly, defeated.
Charlene's Law: There's no such thing as can't.
Charlene's Corollary: Unless it's followed by be arsed.
If only 20% of your staff is programmers, and you can save 50% on salary by outsourcing programmers to India, well, how much of a competitive advantage are you really going to get out of that 10% savings?
|
|
|
|
|
cmurphy
Stray Dog

Joined: 19 Sep 2006 Posts: 41
Location: US
|
Posted:
Wed Feb 14, 2007 10:22 am Post subject: |
|
I choose System.Windows.Forms.Control.Enabled. That's all I need to disable control so user can't draw while my application saving file.
Thank you very much, guys. This all great ideas! |
|
|
|
|
|
|
|
|
|
|
View next topic
View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB
© 2001, 2002 phpBB Group
phpBB SEO
All times are GMT - 8 Hours
Help us keep advertisements off this site. Donate today!
|
|