I was trying to do exactly that a few days ago, and came up with this code quick & dirty snippet:
I didn't even check yet if passing false actually makes it normal again.
NOTE: the forum is buggy, it adds a "\" before "LoadLibraryA@4" and "GetProcAddress@8". They're not in the original code.
?Win32 Extern "os" Function win32_LoadLibrary:Int(lpFileName$z) = "LoadLibraryA@4" Function win32_GetProcAddress:Byte Ptr(hModule:Int, lpProcName$z) = "GetProcAddress@8" End Extern ? Function SetAlwaysOnTop(win:TGadget, bState:Int = True) ?Win32 Local hModule:Int = win32_LoadLibrary("user32.dll") If hModule = 0 Then Return EndIf Local SetWindowPos:Int(hWnd:Int, hWndInsertAfter:Int, X:Int, Y:Int, cx:Int, cy:Int, uFlags:Int) "os" = win32_GetProcAddress(hModule, "SetWindowPos") Const HWND_TOPMOST = -1 Const HWND_NOTOPMOST = -2 Const SWP_NOSIZE = $0001 Const SWP_NOMOVE = $0002 'Const SWP_NOZORDER = $0004 'Const SWP_NOREDRAW = $0008 Const SWP_NOACTIVATE = $0010 Local hwnd% = QueryGadget(win, QUERY_HWND) If hwnd <> 0 Then If bState SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE) Else SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE) EndIf EndIf ? End Function
I didn't even check yet if passing false actually makes it normal again.
NOTE: the forum is buggy, it adds a "\" before "LoadLibraryA@4" and "GetProcAddress@8". They're not in the original code.