dr said:
Hi,
do anyone know a tool which makes it possible to keep a specific
window on top all the time (like the option in Winamp)? The window is
a Java application run on Windows (mostly 2000). It must not be in
focus all the time.
Use JNI to do this every time you create a new top-level window
(not tested from JNI):
EnumWindows(enumWins, getpid());
static BOOL CALLBACK enumWins(HWND hwnd, LPARAM lParam) {
DWORD pid;
if(GetWindowThreadProcessId(hwnd, &pid) &&
(pid == (unsigned long)lParam)) {
LONG ex_style = GetWindowLong(hwnd, GWL_EXSTYLE);
if((ex_style & WS_EX_TOPMOST) == 0) {
HANDLE parent = (HANDLE)GetWindowLong(hwnd,
GWL_HWNDPARENT);
if(parent == 0)
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE
| SWP_NOSIZE | SWP_NOACTIVATE |
SWP_ASYNCWINDOWPOS);
}
}
return TRUE;
}
You can also use various "tricks" to get the window handle of a
new window directly, but I'm not sure if there is a VM-independent
way to do that.
If you can't modify the code, you'll have to launch the Java app
from a Windows app which collects the pid, and occasionally calls
enumWins() while waiting for the Java app to finish.
-Larry Barowski