Solved

Can't close application

Posted on 1998-07-27
8
128 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 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