I to make form to stay on top of another window that insists on being on top

I need for my form to be always visible... but another window keeps
taking over as top form :-(  Any idea on how to wage this battle for
the top spot?
LVL 5
GwenaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ckanetaCommented:
I assume you have stayontop for style, so I'll just jot this down quickly....
TForm
procedure SetZOrder(TopMost: Boolean);
0
MadshiCommented:
Set the form style to stayOnTop and do this:

type
  TYourTopWindow = class(TForm)
  ...
  protected
    procedure CreateParams (var Params: TCreateParams); override;
  ...

procedure TYourTopWindow.CreateParams(var Params: TCreateParams);
begin
  inherited;
  Params.WndParent:=0;
end;

Regards, Madshi.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GwenaAuthor Commented:
Adjusted points to 60
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

GwenaAuthor Commented:
Hi Madshi :-)

  Your code looks good... but it still does not quite fill the bill... the form I need to stay on top is a teeny weeny little thing with just a small scrolling label and a little button.. the window I want it to stay on top of is
one of those ad banners that gets stuck on screen by a free ISP ...like NetZero.  The ad window seems to be re-asserting it's topmost status once each second.. so my form stays on top for at most one second..is there some way to keep bringing my form to the top over and over very quickly.. to keep it visible above the ad window?? If I click on my program in the taskbar really quickly it stays on top... I just need a way for the program to accomplish this effect by itself

p.s. I'm kicking in a few more points :-)
0
ckanetaCommented:
I've actually thought about trying the same thing... I was thinking about finding a way to hide those windows though...
what if you put it on a timer and hid the window and then immediately showed it again.  That might work
0
MadshiCommented:
Well, a timer would be a possibility, but I don't like polling so much. So I would recommend trying to catch a specific window message. You could try handling WM_WINDOWPOSCHANGING or WM_MOVING or WM_ACTIVATE or WM_ACTIVATEAPP. In each of those message you could set your form on top again like this:

SetWindowPos(Handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or SWP_NOSIZE)

Regards, Madshi.
0
bryan7Commented:
listenning
0
GwenaAuthor Commented:
Nothing I try seems to be able to keep a form on top of those ad windows... at least not without causing a LOT of flickering and some system instability :-(     Oh Well... I guess some things just can't be done with delphi...... you gave me some good ideas to try though Madshi :-)


..p.s If anyone ever comes up with a way to put a form on top of one of these monsters without a bunch of flickering .. let me know.. it would be worth a few hundred points to me if I could see some working example code....


...Gwen..
0
MadshiCommented:
Well, one thing to add: It's no *Delphi* problem. It's a Windows problem. You'll exactly the same problem with C++ and VB and ...

Regards, Madshi.
0
MadshiCommented:
P.S: How about preventing those ad windows from appearing at all? You could set up a CBT hook using SetWindowsHookEx, then you are asked about each new window, whether it may be created or not.
0
bryan7Commented:
hey Gwen.. I remember you added me to your icq list some time ago but you never appeared on icq again... ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.