422,530 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,530 IT Pros & Developers. It's quick & easy.

Prevent Window Closure on Application Exit

Oralloy
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,
Oralloy
Sep 23 '16 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 921
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. }
  6.  
  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.