Board index » delphi » How can I get a form to ALWAYS stay on top (over other apps)

How can I get a form to ALWAYS stay on top (over other apps)

Hi

I would like to know how myform can be made to stay on top of other
applications.
Using form2 stayontop does not go far enough.

(I want to use this possibility to paste from my database into texteditors like
msWord.
The form is a very small 4 button form, when you click a button it copies
name,-picture,-description into Windows clipboard. the 4th button is next
record)

thanks.

Frits v/d Laan
Netherlands

 

Re:How can I get a form to ALWAYS stay on top (over other apps)


Quote
Tom wrote:
> On my computer (running Win ME), setting a form's FormStyle to
> fsStayOnTop makes it system modal (i.e. stay on top of all running
> applications).

That's not what system modal means. It's usually a term used with dialog
boxes. A system-modal dialog box blocks your use of the rest of the
system until you dismiss it. Windows has very few system-modal dialogs
anymore. The MessageBox API function displays a thread-modal dialog box,
although you can set a flag that makes it process modal, which you can
read more about in the MSDN documentation for that function.

The term for a window that stays on top of all other windows is topmost.

Quote
> Is this normal?

Yes. Setting the style to fsStayOnTop makes it stay on top.

--
Rob

Re:How can I get a form to ALWAYS stay on top (over other apps)


Quote
Frits v/d Laan wrote:
> I would like to know how myform can be made to stay on top of other
> applications.
> Using form2 stayontop does not go far enough.

Doesn't it stay on top? How far would you like it to go?

--
Rob

Re:How can I get a form to ALWAYS stay on top (over other apps)


On Sun, 18 Aug 2002 00:27:54 -0500, Rob Kennedy <rikenn...@wisc.edu>
wrote:

Quote
>Frits v/d Laan wrote:
>> I would like to know how myform can be made to stay on top of other
>> applications.
>> Using form2 stayontop does not go far enough.

>Doesn't it stay on top? How far would you like it to go?

Probably some other window is competing,

procedure TForm1.Timer1Timer(Sender: TObject);
begin
SetWindowPos(Self.Handle,
             HWND_TOPMOST,
             Left,
             Top,
             Width,
             Height,0);
//Application.ProcessMessages;
end;

However this has some {*word*193} side effects (pushing out menus etc), they
can probably be overcome using WindowFromPoint

Re:How can I get a form to ALWAYS stay on top (over other apps)


This overcomes the problem :-

procedure TForm1.Timer1Timer(Sender: TObject);
Var
hWnd: THandle;
Point: TPOINT;
begin

Point.x := 0;
Point.y := 0;
Point := Self.ClientToScreen(Point);
hWnd := WindowFromPoint(Point);
If hWnd <> Self.Handle Then
   SetWindowPos(Self.Handle,
                HWND_TOPMOST,
                Left,
                Top,
                Width,
                Height,
                SWP_NOACTIVATE);
end;

Other Threads