Version 16 of always on top

Updated 2002-02-25 11:18:54

[the question of how an application can force some part of itself as the top level window is a FAQ]

Could someone please write something here about the topic?

ptk*


Win32

The API function needed is (see also [L1 ]):

  SetWindowPos(HWND hWnd,       // handle to window
               HWND hWndAfter,  // placement order handle
               int x, int y,    // position (horizontal, vertical)
               int cx, int cy,  // size (width, height) 
               UINT uFlags)     // positioning flags

The placement order handle can be either another HWND or once of the following constants:

  • HWND_BOTTOM (1) Moves to the bottom
  • HWND_NOTOPMOST (-2) Place above all non-topmost windows.
  • HWND_TOP (0) Move to the top
  • HWND_TOPMOST (-1) Move to the top and keep it there.

The Flags can be one of a number but for this page probably SWP_NOMOVE (2) and SWP_NOSIZE (1) are likely the most useful. So:

  SetWindowPos([winfo id .], HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE)

which turns out to be the code used by XRaiseWindow in win/tkWinWindow.c


Melissa Schrumpf recommends the GPLed WinCtl [L2 ] utility, which makes it possible to write

    exec WinCtlW.exe -id [wm frame .] topmost &

(or might there be more punctuation in the vicinity of the id?).


Martin Lemburg

I found the original topmost package made by John Rosauer in 12.1997. It works only with tcl/tk v.8.0.

The URL is: ftp://ftp.dcade.de/pub/ml/tcl/projects/topmost10/topmost10.zip [L3 ]

So I created a Visual Studio project to create an uptodate stubs enabled package usable from tcl/tk v.8.1 and higher.

The first call of Tk_MainWindow(ip) (topmost.cpp, line 277) with the pointer to the current interpreter inside the topmost command causes a access violation.

I tried with the tcl versions 8.1(.1) and 8.3.4 (tclstubs8(1|3).lib, tkstubs8(1|3).lib with the corresponding include files tcl.h, tk.h and tkWin.h) on Windows 2000/SP2.

Even the try of a call of Tk_GetNumMainWindows() caused a access violation.

The URL to the sources is: ftp://ftp.dcade.de/pub/ml/tcl/projects/topmost20a/topmost20a.src.zip [L4 ] (< 3 kB)

The URL to the VisualStudio project is (tcl/tk 8.3.4 runtime environment included): ftp://ftp.dcade.de/pub/ml/tcl/projects/topmost20a/topmost20a.vcppproj.zip [L5 ] (4.861 kB)

Has anybody a hint or a suggestion?

Thanks

Martin Lemburg