Discussion:
disable standard window buttons (close/iconify/activate) + auto-start
(too old to reply)
p***@yahoo.it
2006-08-30 14:05:32 UTC
Permalink
Raw Message
Hi everyone. Two questions for you.

1) I want to create an application, say MYAPP, whose
termination has to be possible ONLY by clicking a generic
Button1 upon main form AND NOT by clicking the standard
'X' (close) button upright in the window. In other words, I'd like
to disable 'X' (close) button. How to?

2) Suppose I set automatic start of MYAPP. This is quite simple,
for example by adding a value in a specific registry key
(seems to me it is
HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\run).
My question now is: who does terminate automatically started tasks at
logoff time? OS? Or, concerning MYAPP, is my job to prepare its
termination at logoff time? If so, how to?

Thanks everyone, bye
r***@tiscali.it
2006-08-30 15:31:22 UTC
Permalink
Raw Message
1) In order to do that you must use the CloseQuery event like in this
example. Using a private boolean var you can set that the close is
originated by the button

type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
closebybutton: boolean;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose:
Boolean);
begin
canclose:= closebybutton;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
closebybutton:= false;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
closebybutton:= true;
Close;
end;

2) The applications started by registry run are automatically closed by
the LOGON.EXE process.

Bye
Rafael Andres Marin de la Cruz
http://affittistagionali.it
Post by p***@yahoo.it
Hi everyone. Two questions for you.
1) I want to create an application, say MYAPP, whose
termination has to be possible ONLY by clicking a generic
Button1 upon main form AND NOT by clicking the standard
'X' (close) button upright in the window. In other words, I'd like
to disable 'X' (close) button. How to?
2) Suppose I set automatic start of MYAPP. This is quite simple,
for example by adding a value in a specific registry key
(seems to me it is
HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\run).
My question now is: who does terminate automatically started tasks at
logoff time? OS? Or, concerning MYAPP, is my job to prepare its
termination at logoff time? If so, how to?
Thanks everyone, bye
its me
2006-08-30 22:51:19 UTC
Permalink
Raw Message
No need to do all of that.

If you dont want to show the little 'X' close button on any form
just add this to the form's 'OnCreate' event:

EnableMenuItem(GetSystemMenu(self.Handle, False), sc_Close,
MF_BYCOMMAND or MF_GRAYED);


Sorted!
Post by r***@tiscali.it
1) In order to do that you must use the CloseQuery event like in this
example. Using a private boolean var you can set that the close is
originated by the button
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
closebybutton: boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
Boolean);
begin
canclose:= closebybutton;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
closebybutton:= false;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
closebybutton:= true;
Close;
end;
2) The applications started by registry run are automatically closed by
the LOGON.EXE process.
Bye
Rafael Andres Marin de la Cruz
http://affittistagionali.it
Post by p***@yahoo.it
Hi everyone. Two questions for you.
1) I want to create an application, say MYAPP, whose
termination has to be possible ONLY by clicking a generic
Button1 upon main form AND NOT by clicking the standard
'X' (close) button upright in the window. In other words, I'd like
to disable 'X' (close) button. How to?
2) Suppose I set automatic start of MYAPP. This is quite simple,
for example by adding a value in a specific registry key
(seems to me it is
HKEY_LOCAL_MACHINE\software\microsoft\windows\currentversion\run).
My question now is: who does terminate automatically started tasks at
logoff time? OS? Or, concerning MYAPP, is my job to prepare its
termination at logoff time? If so, how to?
Thanks everyone, bye
Riki Wiki
2006-08-30 21:37:42 UTC
Permalink
Raw Message
Hoi PGianessi and RamC18

FYI this newsgroup do not officially exist that is why there is so few
postings here. The newsgroup is now called b.p.d.nativeapi.win32. To post
there use the Borland news server.

How to post to Delphi newsgroups:
<http://delphi.wikia.com/wiki/Delphi_Newsgroups>
Loading...