Link to home
Start Free TrialLog in
Avatar of Gwena
Gwena

asked on

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?
Avatar of ckaneta
ckaneta

I assume you have stayontop for style, so I'll just jot this down quickly....
TForm
procedure SetZOrder(TopMost: Boolean);
ASKER CERTIFIED SOLUTION
Avatar of Madshi
Madshi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Gwena

ASKER

Adjusted points to 60
Avatar of Gwena

ASKER

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 :-)
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
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.
listenning
Avatar of Gwena

ASKER

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..
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.
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.
hey Gwen.. I remember you added me to your icq list some time ago but you never appeared on icq again... ?