Solved

Can't close application

Posted on 1998-07-27
8
125 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

11 Experts available now in Live!

Get 1:1 Help Now