hagur
asked on
STAY ON TOP - no matter what.
I need my form to stay on top of everything. Setting the stay on top property to true is not enough, because when I start another program which also is stay on top, it covers my form.
A good example would be the windows NT/2000/XP task manager. I want my form to be able to cover it and any other windows/forms that may come along.
I know this is possible because I saw a program that could lock any windows workstation, even XP and 2K.
When you pressed the ctrl-shift-esc key to try to open the task-manager, it was like the program immediately got focus again and covered the task-manager even before I was able to see it.
200 points for a good solution and maybe even more. This is pretty urgent.
What is a good way to do this? I'd preferably not use any 3rd-party components though.
Thanks in advance,
Hagur
A good example would be the windows NT/2000/XP task manager. I want my form to be able to cover it and any other windows/forms that may come along.
I know this is possible because I saw a program that could lock any windows workstation, even XP and 2K.
When you pressed the ctrl-shift-esc key to try to open the task-manager, it was like the program immediately got focus again and covered the task-manager even before I was able to see it.
200 points for a good solution and maybe even more. This is pretty urgent.
What is a good way to do this? I'd preferably not use any 3rd-party components though.
Thanks in advance,
Hagur
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
listening :-)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
listening ... for moment
ASKER
Thanks guys.
Tongalite: When I try to run your code, I always get an error in this line:
property StayOnTop: boolean read FStayOnTop write SetStayOnTop;
The error I get is: "Field or method identifier expected"
I'm using Delphi 5.0
Geobul: Your code almost works ... my program can now cover the task-manager, but when I use ALT-TAB to switch to the task manager, it sometimes manages to stay on top of my form, but sometimes not. Weird!
Any solutions?
Tongalite: When I try to run your code, I always get an error in this line:
property StayOnTop: boolean read FStayOnTop write SetStayOnTop;
The error I get is: "Field or method identifier expected"
I'm using Delphi 5.0
Geobul: Your code almost works ... my program can now cover the task-manager, but when I use ALT-TAB to switch to the task manager, it sometimes manages to stay on top of my form, but sometimes not. Weird!
Any solutions?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
put this on formcreate
procedure TForm1.FormCreate(Sender: TObject);
begin
setwindowpos(form1.Handle, hwnd_notop most,0,0,g etsystemme trics(sm_c xscreen),g etsystemme trics(sm_c yscreen),0 );
setwindowpos(form1.Handle, hwnd_topmo st,0,0,get systemmetr ics(sm_cxs creen),get systemmetr ics(sm_cys creen),swp _nomove);
setforegroundwindow(form1. Handle);
SetWindowLongA(Handle,GWL_ style,WS_E X_TOOLWIND OW);
end;
don't forget to build back door for your application, i use
PopupMenu1: TPopupMenu;
and in the exit button
exit1: TMenuItem;
procedure TForm1.exit1Click(Sender: TObject);
begin
close;
end;
i hope u can enjoy this answer
procedure TForm1.FormCreate(Sender: TObject);
begin
setwindowpos(form1.Handle,
setwindowpos(form1.Handle,
setforegroundwindow(form1.
SetWindowLongA(Handle,GWL_
end;
don't forget to build back door for your application, i use
PopupMenu1: TPopupMenu;
and in the exit button
exit1: TMenuItem;
procedure TForm1.exit1Click(Sender: TObject);
begin
close;
end;
i hope u can enjoy this answer
surodimedjo,
I see that you are new expert here at Ex-Ex. We ( the other experts ) have a rule . We just add comments and not give directly answers.
The result of this rule is that we don't block the question and we let the freedom to asker to choice the best solution for her needs .
In same time he can ask more support to improve a comment from list .
Untill your answer will be evaluate ( accepted or rejected ) I doubt that someelse will add comments .
Best regards,
Nick
P.S. Of course you are free to do what you want.
I see that you are new expert here at Ex-Ex. We ( the other experts ) have a rule . We just add comments and not give directly answers.
The result of this rule is that we don't block the question and we let the freedom to asker to choice the best solution for her needs .
In same time he can ask more support to improve a comment from list .
Untill your answer will be evaluate ( accepted or rejected ) I doubt that someelse will add comments .
Best regards,
Nick
P.S. Of course you are free to do what you want.
Hi hagur! I just warn you that those answers suggesting including setwindowpos in form create event will go wrong after user moves your program to another monitor or alters the screen resolution.
Regards,
Steve
Regards,
Steve
For this reason I suggest to hook WMWindowPosChanging messages.
Hi,
I think that (SWP_NOMOVE or SWP_NOSIZE) in uFlags means that the function will ignore x,y,cx and cy parameters. So the window changes its Z order only. That's why there won't be any problems altering screen resolution or monitor type. Am I wrong?
Regards, Geo
I think that (SWP_NOMOVE or SWP_NOSIZE) in uFlags means that the function will ignore x,y,cx and cy parameters. So the window changes its Z order only. That's why there won't be any problems altering screen resolution or monitor type. Am I wrong?
Regards, Geo
ASKER
surodimedjo: Read Ginsonic's post to see why I rejected your answer.
ASKER
ginsonic:
This isn't working .... the form can not cover other forms that have the "stay on top" form-style.
This isn't working .... the form can not cover other forms that have the "stay on top" form-style.
thinking to another way ..........
listening
hagur:
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.
This old question needs to be finalized -- accept an answer, split points, or get a refund. For information on your options, please click here-> http:/help/closing.jsp#1
EXPERTS:
Post your closing recommendations! No comment means you don't care.