Solved

Can't close application

Posted on 1998-07-27
8
132 Views
Last Modified: 2010-04-04
How can I make a form when just the minimize button (on the borderIcons) will be enabled.
0
Comment
Question by:talklein
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1358760
Go to BorderIcons in the form's property editor, then double click on the plus sign and set all options to false except the one that says Minimize... Minimize := true; Got it? C'Ya later...

Regards,
Viktor Ivanov
0
 

Author Comment

by:talklein
ID: 1358761
I clicked that I accept your answer but it doesn't help,
when I  change the    biSystemMenu to false  there is no control box on the form.
0
 

Author Comment

by:talklein
ID: 1358762
when I  change the    biSystemMenu to false  there is no control box on the form.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:erajoj
ID: 1358763
Hi,
I have searched all resources I could find on disabling/deleting the close button, but it seems to be "impossible" (very hard) to do so.
If you just want to prevent a user from closing your app, there are other ways...
.tell us if so, and you will get a prompt answer.
I have forwarded this question to the MFC group, since there are MS developers active in that group, for 300pts.

/// John
0
 

Expert Comment

by:buboi
ID: 1358764
It's impossible.
0
 

Expert Comment

by:buboi
ID: 1358765
you can set the CanClose variable to false in the FormQueryClose procedure. and you must provide other close application method, for example, select the menu item to execute a statement:
Application.Terminate;
0
 
LVL 4

Accepted Solution

by:
erajoj earned 40 total points
ID: 1358766
After getting some help from the MFC-guys...
Here's a working, excellent(!?), solution (didn't know it was this easy):

procedure SetCloseState( hForm: HWND; bEnabled: Boolean );
var
  hSysMenu: HMENU;
begin
  hSysMenu := GetSystemMenu( hForm, False );
  if ( hSysMenu <> 0 ) then begin
    if ( bEnabled )
    then EnableMenuItem( hSysMenu, SC_CLOSE, MF_ENABLED )
    else EnableMenuItem( hSysMenu, SC_CLOSE, MF_DISABLED or MF_GRAYED );
  end;
end;

Usage:
  SetCloseState( Form1.Handle, False ); // disables close button + menu item immediately
  SetCloseState( Form1.Handle, True ); // enables close button + menu item immediately

Hope this is what you needed. At least it will help me getting some sleep...

/// John
0
 

Author Comment

by:talklein
ID: 1358767
great this is what I was looking for!
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question