Avatar of krydea
krydea
 asked on

app settings alway's on top easy!

hello,
i have two simple question's.
1 is how can i terminate my app (progress) i tryed halt; but i get a error: "onshow onhide"
in use of oncreate; (O.S: "XP")
is there no other way?

and the other is how can i set that my app in alway's on top?

plz help...
greets
Delphi

Avatar of undefined
Last Comment
Munim

8/22/2022 - Mon
PoeticAudio

Answers....

First question.

Application.Terminate;

that will end your app and setting your form on top is just as easy!

Form.FormStyle := fsStayOnTop;

With the stay on top code, you can actually set that in design time. Just go to your Object inspector, and change the FormStyle property to fsStayOnTop.
krydea

ASKER
i get an error while using `Application.Terminate;`...??
ASKER CERTIFIED SOLUTION
PoeticAudio

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Imagine

To set it ontop:

SetWindowPos(Handle,HWND_TOPMOST,Left,Top,Width,Height,0); //on top

To abort your app:

application.Terminate;
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
krydea

ASKER
in onCreate and in Onactived and in OnDeActived
Munim

use the code for closing your program

SendMessage(Handle, WM_CLOSE, 0, 0);

and use to set the window at top:

SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0,
    SWP_NOMOVE or SWP_NOSIZE or
    SWP_NOACTIVATE);
PoeticAudio

I wouldnt use windows API to close your own programs, I would use Delphis Application.Terminate, it takes care of everything for you... plus its just easier to read and remember!
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Munim

Do  you know that Application.Terminate does??? It calls the ExitProcess API function. You must understand the scheme of programming, programming is not "plus its just easier to read and remember!". When you send WM_CLOSE to a window, it follows the best way the Windows does, to destroy everything associated with the window. After destroying that, the process comes to a halt. You should have known all these....