By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,156 Members | 1,069 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,156 IT Pros & Developers. It's quick & easy.

Prevent Window Closure on Application Exit

Expert 100+
P: 983
I am building a command-line application which writes messages to the terminal as it processes. There is no GUI for this applicaion.

Currently I run from the command line, although in "normal use", our field-service people will just double-click on the image name in the explorer.

Normally the program just runs "silently", and the window should close at end of execution. QED.

When a failure occurrs, then I would like for my field people to capture the output and send a copy to me.
  • This lets us "fix" the problem immediately, resulting in happy customer.
  • Avoids scheduling a second customer-site visit.
  • Upgrades cause minimal customer down-time.

When I did something similar to this years ago, I remember setting a bit somewhere (a properties check-box) that prevented window closure.

I have looked for this check-box on the "Command Prompt" window properties (alt-space|Properties) and on the menu-item properties (right-mouse|Properties}. Neither seems to provide a suitable property.

What am I missing?

Do you have any suggestions?

Thank You,
Sep 23 '16 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,035
To disable the Close button in the caption dynamically, you enable and disable the SC_CLOSE menu item in your system menu.
Expand|Select|Wrap|Line Numbers
  1. void DisableCloseButton(HWND hwnd)
  2. {
  3.  EnableMenuItem(GetSystemMenu(hwnd, FALSE), SC_CLOSE,
  4.                 MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  5. }
  7. void EnableCloseButton(HWND hwnd)
  8. {
  9.  EnableMenuItem(GetSystemMenu(hwnd, FALSE), SC_CLOSE,
  10.                 MF_BYCOMMAND | MF_ENABLED);
  11. }
Jan 6 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.