• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 148
  • Last Modified:

Can't close application

How can I make a form when just the minimize button (on the borderIcons) will be enabled.
0
talklein
Asked:
talklein
  • 3
  • 2
  • 2
  • +1
1 Solution
 
viktornetCommented:
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
 
talkleinAuthor Commented:
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
 
talkleinAuthor Commented:
when I  change the    biSystemMenu to false  there is no control box on the form.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
erajojCommented:
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
 
buboiCommented:
It's impossible.
0
 
buboiCommented:
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
 
erajojCommented:
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
 
talkleinAuthor Commented:
great this is what I was looking for!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now