 |
|
 |
// just 1 line
DeleteMenu(GetSystemMenu(GetConsoleWindow(), FALSE, SC_CLOSE, MF_BYCOMMAND));
Best Regards!
RIX from recs73@cantv.net
|
|
|
|
 |
|
 |
Hi when I download the source code I can't obtain the "DisableCloseBtn.h" file. Please help
|
|
|
|
 |
|
 |
DisableCloseBton.h I believe is a Visual Studio generated file based on the name of your project. If you start your own project, it should aautomagically create a header file, and then you can just cut and paste the code in the cpp file into your new project file. Hope that helps
Thanks,
John
|
|
|
|
 |
|
 |
Not sure if this was available when you released this solution, but there is an easier way IMO.
http://support.microsoft.com/default.aspx?scid=kb;en-us;201553
2 lines for this fix instead of your 9 line fix.
|
|
|
|
 |
|
 |
hi all
i wish to know how to put item in popup menue in windows explorer
|
|
|
|
 |
|
 |
but does enybody knows how to remove Maximize button (not just to disable it) from MFC console app? I've tried some hard hacks but with no success. Maybe it is something easy but I cannot see it.
|
|
|
|
 |
|
 |
I'm prolly not the best one to be answering or even commenting on this, since I'm so new to the platform but I would think you are not able to actually remove a button on the system menu at all since it would be fundamentally part of the Windows API. Again, I may be completely wrong though.
kha0s
"There are 10 types of people in this world; Those that know binary and those that do not."
|
|
|
|
 |
|
 |
There is no situation where you ever need to do this (unless you really want to annoy your users).
You can catch a close event and respond in a sensible manner. See SetConsoleCtrlHandler and HandlerRoutine in the platform SDK.
|
|
|
|
 |
|
 |
Using Crtl Handler is a way to handle it but it won't work well in some case:
1.) if your application needs a lot of time to finish, course massive data structures has to be erased, the closing button (right upper corner) forces that the handler will be called but the OS kills the application prior to it's real end.
2.) On SMP (HT) machines (sometimes on SP machines) the handler will be called more than once. Reseting the handler table during first occurance of event may be corrupt the runtime and forces the kill off application by OS.
3.) Sometimes you will not be able at this point to create new threads in your application, course the OS monitors this application as "internaly dead". This also reflects running threads, the may be killed as is sometimes.
It's seems, that OS creates a "kill thread" if you press on console application the "right upper cross". Using "cross button" is different to CTRL-C and different to using "ALT-F4". All 3 exist requests may execute different strategies of application termination!
|
|
|
|
 |
|
 |
Ok, but I think the point is you have to honour the request made by the user. I think it is pretty important to design the application properly and then you won't get any of the problems you mention. Anyway, removing the button is only going to make users use ctrl+alt+del or some other method so I don't think non-standardising windows is really helping.
For long running program that for some reason cannot close quickly you have to consider not using the console.
|
|
|
|
 |
|
 |
You have to understand everyone’s situation is different.
Here’s my first use for this functionality: I have a console app on my server and it will be watching for file activity from user requests over a web service and the console app will act as the gateway to query WDS 3.0 and return the dataset via xml file back to the service for response to the client app. I want to disable the X to make sure "I" don't close it by mistake in one of my click frenzy moments when working on the server and am not use to this service running yet. If i close it by mistake all in process requests and new requests will fail.
And my second: This also would be useful for my large OCR processes which scan thousands of pages but due to my OCR's SDK functionality there is no middle ground during processing where i can close the process and not expect it to have to start all over again.
So in some instances this method can be used to make sure the user or process has a better experience.
|
|
|
|
 |
|
 |
The original idea for this came from my employer, they needed a script to be started without the beginning to average user being able to stop the script, which then loads a proprietary program. The small application worked perfectly. Although anyone with at least half of a brain can figure out a way around, the users are apparently newbs, and the problem that the app originally was written for is no longer a problem. I realize this is extremly simplistic, but I'm confident someone out there it could come in useful.
I do appreciate the comments and discussion though, without comments and discussions things can get quite boring.
kha0s
"There are 10 types of people in this world; Those that know binary and those that do not."
|
|
|
|
 |
|
 |
Actually, the user could use ALT-F4 if they really want to close it.
How about consider to catch the keypress message?
Sonork 100.41263:Anthony_Yio
|
|
|
|
 |