Solved

Can't close application

Posted on 1998-07-27
8
127 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reading complex type element repeats first one found several times 3 41
Path  to current project in Delphi. 2 72
delphi prevent click fast 2 192
Delphi Form ownership 4 73
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now