Solved

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

Posted on 2008-06-13
5
372 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

18 Experts available now in Live!

Get 1:1 Help Now