tags:

views:

214

answers:

7

Possible Duplicate:
How to disable the minimize button in C#?

Is there a way to make a c sharp program impossible to minimize ? Is there a way to stop a program from being affected by the Show Desktop button?

A: 

How about catching the minimize event (or other means of checking wheter the window is currently minimized), and just un-minimize it again?

LukeN
A: 

well, the only way i can think of is to catch the event of minimizing and write a code for that.

I would suggest against it because ultimately, its the user who should decide what he wants to do.

Another approach could be to force the form as a Dialog and topmost with no minimize button. However in this case, the user would be able to minimize it using "Show Desktop".

A: 

Don't. I wish an API didn't even exist for this. If a user wants to minimize your program, he/she has every right to. Messing with what the user has the right to do w/ his/her own system (think preventing using the back button, preventing minimization, preventing fast forwarding of certain sections of DVDs) should be punishable by death.

dsimcha
Sorry but this is not helpful. I once wanted to make a program that popped up for a few seconds, displaying sentences in a language I was learning. Programs can also be for a personal usage.
subtenante
DVDs that act like old VHS tapes are really annoying - you must watch these previews, the menu button is disabled, so you can only skip ahead preview by preview or fastforward the whole time...
jball
hehe, I know you are getting burned for thinking about the evil stuff, but there's reasons to do it, you can't think of every scenario. What if you just want to implement a feature to pin the window on top?
Richard Hein
@Richard: I actually run an "always on top" tool. If you manually click minimize, it still minimizes the window. It just doesn't allow other windows to hide it.
dsimcha
Punishable by death?! Excuse me, but **I** am the programmer, and therefore **I** will decide how the computer behaves when any user attempts to run **my** program. The user benefits from **my** work, and that is all. Sorry I had to chime in like this, but your answer is way off, and it appears that your way of thinking is abstracted beyond reality. If any given user *wanted* these kinds of rights, they would not expect an easy-to-use operating system when they buy a new computer, they would hope for a mobo beep instead. Sounds like a perfect world, right?!
Josh Stodola
@Josh I suppose you think user expectations and common interface and usability practices are silly too, since you're the one putting **your** hard work into **your** program?
jball
@jball There is no "best practice" regarding user interface and/or usability that can be globally applied. There are too many variants, too many oddball situations, too many different kinds of programs that serve too many different purposes. Closed-minded purists would beg to differ, but most of them are too caught up in ethics to focus on releasing production software.
Josh Stodola
@jball Oh, and by the way, every "expectation" that any user has today is the byproduct of a programming decision made some time ago. Don't forget it.
Josh Stodola
@Josh, and those programming decisions that survived were the ones that produced the most usable and consistent interfaces. I'm not going to presume to tell you what you should and shouldn't forget.
jball
@Josh: Your program is running on **my machine**. http://www.dailykos.com/story/2010/2/20/839011/-RELOAD:-DVD-Piracy-vs.-DVD-Paying-Customer-%28POLL%29
Roger Pate
@jball I'm glad we understand each other. So... are you saying that there is no possible way that an app could be usable without an option to "minimize"? You can't minize the desktop, does that deem it unusable and worthless? Absolutely not; it disappears when you choose to do something else. Look at the question he asked the other day. Not *everything* conceivable has to be subjected to these so-called programming proverbs. It's a legitimate question, and an answer like this is just (controversial) noise.
Josh Stodola
@Josh, *So... are you saying that there is no possible way that an app could be usable without an option to "minimize"?* - No, I am saying that it is less usable than it would be with the option.
jball
-1 Maybe this is for a kiosk where the user is only permitted to interact with this one application.
Jon B
Whoever voted this down needs remedail training in UI design. @Jon: in kiosk mode what you do is make sure that nothing else is launchable so if they minimize it all they get is a taskbar with one button on it, or perhaps the minimum size window if you reduce it to the point where there's not even a taskbar.
Joshua
@Joshua - my point is that there may be a valid reason to do this. LBushkin's answer is perfect. He tells the OP how to accomplish his goal, but also warns about the risks of doing so.
Jon B
+4  A: 

You will need to use the Window Hook API.

This API includes methods that applications like computer-based training programs or Kiosk-based applications use to make themselves the only window that can interact with the user. There are many different methods to hook - but there's an article on MSDN that describes how to use the API from .NET that you may find useful.

There is a particular hook event: HCBT_MINMAX that you can intercept and cancel for your window.

If all you want to do is disable the minimize button in your app you can look at the following question's accepted answer http://stackoverflow.com/questions/319124/how-to-disable-the-minimize-button-in-c. However, this will not prevent the app from being hidden if the user clicks Show Desktop, or some other window wants to appear over your application.

One word of caution: You should be very careful about the instances where you choose to write an application that takes over control of a machine in this manner. This is the antithesis of user-friendly design. It's only appropriate in narrow situations, like computer-based training, kiosks, or ATM machine software where you really DO want to completely control the machine.

LBushkin
A: 

You can prevent yourself from being minimized but I think the ShowDesktop button does some composting that makes that not preventable w/o setting topmost.

Joshua
A: 
tommieb75
A: 

Set your window parent of taskbar. Done!

Leo
Care to elaborate?!
Josh Stodola