Solved

I need to have a form without the red x close button

Posted on 2008-06-13
5
373 Views
Last Modified: 2010-04-05
I need to remove the red x close button on a form. II will handle the close with a button on the form.
I want to keep all other functionality such as minimize, maximize and caption.
 I have tried EnableMenuItem(AppSysMenu,SC_CLOSE,MF_BYCOMMAND or MF_GRAYED) but this only grays it out.  Any suggestions ?
0
Comment
Question by:jrb1204
  • 4
5 Comments
 
LVL 14

Expert Comment

by:SteveBay
ID: 21781041
look at the BorderIcons property of the Form.
You will want to set biSystemMenu = False;
or at runtime you can do this:


procedure TForm1.Button1Click(Sender: TObject);

begin

     Self.BorderIcons := Self.BorderIcons - [biSystemMenu];

end;

Open in new window

0
 
LVL 14

Expert Comment

by:SteveBay
ID: 21781068
I just re-read your question and I see that you wish to keep minimize, maximize and caption. That will require some more effort. I'll have to do some looking...
0
 
LVL 14

Expert Comment

by:SteveBay
ID: 21781162
I think this is close to what you want.
procedure TForm1.FormCreate(Sender: TObject);

var  h : hMenu;

     i : Integer;

begin

     h := GetSystemMenu(Handle, False );

     for i := GetMenuItemCount(h)- 1 downto 0 do

          if GetMenuItemID(h,i) = SC_CLOSE then

                RemoveMenu(h,i,MF_BYPOSITION);

end;

Open in new window

0
 

Author Comment

by:jrb1204
ID: 21781502
The solution from your last post works to disable the close [x]  icon but what I was looking for was a way to hide it.
0
 
LVL 14

Accepted Solution

by:
SteveBay earned 50 total points
ID: 21781678
Everywhere I've looked this is roughly the technique I have found. I suppose that it is posible to hide the [X] and not the the other menu buttons but I cannot find an example.
Why do wish to hide it? Are you trying to control the program close process? If so you should be using the the TForm.OnCloseQuery event rather than changing a long standing and well accepted Windows convention.
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
Internet Explorer View Settings Question 15 107
Printing problem 2 81
control image tags in a string ? 12 111
how to update exe applicatio from internet ? 6 68
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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

864 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

23 Experts available now in Live!

Get 1:1 Help Now