[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 196
  • Last Modified:

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?
0
Gwena
Asked:
Gwena
  • 4
  • 3
  • 2
  • +1
1 Solution
 
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
 
GwenaAuthor Commented:
Adjusted points to 60
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now