473,387 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Catching the cancel event of console application

Hi,

I creating a console application.
In that I want to catch the cancel event of the console application .Please
guide me in this.I figured out that I will have to attach event to the
console.How can I do that?

Please help !

Thanks,
--
Analyst Programmer
Jul 11 '07 #1
2 3033

"Neeta" <Ne***@discussions.microsoft.comwrote in message
news:1D**********************************@microsof t.com...
Hi,

I creating a console application.
In that I want to catch the cancel event of the console application
.Please
guide me in this.I figured out that I will have to attach event to the
console.How can I do that?
The only thing you may be able to do is disable the Close button. That way,
the user has to press an exit key that you check for in code or the user has
to go to Task Manager to kill the Console application.

http://www.codeproject.com/tips/disableClose.asp

Jul 11 '07 #2
Thanks for the reply I tried the following code:
IntPtr hwd = GetConsoleWindow();
if (hwd != IntPtr.Zero)
{
EnableMenuItem(GetSystemMenu(hwd, false),
SC_CLOSE, MF_BYCOMMAND | MF_DISABLED);
}

It seems EnableMenuItem works absolutely fine with forms .For Forms it
disables the cancel buton and also the Alt+F4 option.But when i use it for
console it doesnot.
Am I missing something here ?
--
Neeta
Programmer Analysts
"Mr. Arnold" wrote:
>
"Neeta" <Ne***@discussions.microsoft.comwrote in message
news:1D**********************************@microsof t.com...
Hi,

I creating a console application.
In that I want to catch the cancel event of the console application
.Please
guide me in this.I figured out that I will have to attach event to the
console.How can I do that?

The only thing you may be able to do is disable the Close button. That way,
the user has to press an exit key that you check for in code or the user has
to go to Task Manager to kill the Console application.

http://www.codeproject.com/tips/disableClose.asp

Jul 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Hautzendorfer | last post by:
Hello, I'm currently working on some printing stuff: I have to print out several .xml files using a stylesheet. Therefor I choose the Internetexplorer PlugIn via SHDocVW. My problem: After...
5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
2
by: Ron L | last post by:
I have an MDI application which opens a number of child windows, each of which could have data in a state that needs to be saved. Each child window catches its Closing event and cancels it if the...
11
by: ryanmhuc | last post by:
I have a function which needs to cancel the input into a text field on a form. I cancel the event in IE fine and the text does not get entered. But for firefox (1.0) I cancel the event and the text...
5
by: James Hancock | last post by:
I would like to have some way that if there is no error handling and an exception is thrown in our application that it will do a last resort error handling so that we can send information to...
3
by: Elp | last post by:
Hi, I've developped a Window Form C# application which main form contains several activex controls. No problems most of the time but on some machine, the application crashes when the main form...
2
by: Eric Sabine | last post by:
I built a generic exception handler form which allows the user to get information from it, print it, email it, etc. for exceptions for which I explicitly didn't handle in code, such as missing...
5
by: lord.zoltar | last post by:
How can I prevent the big close button in the top of the window from closing the window? I want to have and "are you sure?" confirmation so the user must press "Yes" before the program ends. Right...
3
by: Anthony P. | last post by:
Hello Everyone, I am writing a Windows Mobile 5.0 application using VS 2..8 in VB.NET. When someone clicks the "Exit" menu option, which generates a button_click() event, I find it easy to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.