Solved

Disable the BorderIcons?

Posted on 1998-10-31
10
332 Views
Last Modified: 2008-03-17
How do I disable the close window BorderIcon(the X in upper right corner)?
0
Comment
Question by:Kmiller
  • 5
  • 5
10 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1345222
type
  TForm1 = class(TForm)
  private
    procedure WMNCCreate(var Message: TWMNCCreate); message WM_NCCREATE;
  end;

implementation

procedure TForm1.WMNCCreate(var Message: TWMNCCreate);
var SysMenu: HMENU;
begin
  inherited;
  SysMenu := GetSystemMenu(Handle, False);
  DeleteMenu(SysMenu, SC_CLOSE, MF_BYCOMMAND);
end;

0
 
LVL 10

Accepted Solution

by:
viktornet earned 50 total points
ID: 1345223
Yes you could siable the needed part of the BorderIcons to False or you could use this one....

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 ); //same here...

Note: The code isn't mine. I got it from John! 10x John =)

Cheers,
Viktor
0
 
LVL 3

Expert Comment

by:vladika
ID: 1345224
:(
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345225
:-|

What;s up Vladika??? How are things in Russia??
0
 
LVL 3

Expert Comment

by:vladika
ID: 1345226
Very, very, very BAD :(
I still unemployed :(
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 10

Expert Comment

by:viktornet
ID: 1345227
:( That's bad... Can't you find a job somewhere?? How come???

Cheers,
Viktor
0
 
LVL 3

Expert Comment

by:vladika
ID: 1345228
Do you mean emigration? It's interesting idea :)
But I am student now. Maybe after half a year.
BTW, Is there situation in USA
when bank block your bank account without reason? :(

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345229
I'm still a high school student so I still don't know.. There is plenty of time I need until I get into college and so on.... Probably studying Computer Scinece and stuff like that.. Don't really know if there is anything cool around here.. Actually I'm absolutely sure that if you know MS VC++ and C++ as a whole and VB then you'll find a job for sure... There are vacancies for Delphi, but they need Database programming most of the time,... so I don;t really know...

P.S. Wish you luck whatever you decide =)

Cheers,
Viktor
0
 
LVL 3

Expert Comment

by:vladika
ID: 1345230
Thank you very much!
It (luck) will be very useful to me :)

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1345231
No prob :)

Vik
0

Featured Post

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.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

20 Experts available now in Live!

Get 1:1 Help Now