Make a TopMost Window
Archives Forums/Win32 Discussion/Make a TopMost Window
| ||
Does anyone know exactly how to make a window topmost so you can't have any windows over it? I've tried this:hWnd=QueryObject(Window,1) Bits=api_GetWindowLong(hWnd,-16) Bits=Bits Or 8 api_SetWindowLong(hWnd,-16,Bits) This works for regular things like WS_SYSMENU but not for extended bits (WS_EX_TOPMOST=8). Anyone have any ideas? |
| ||
I've used this in BMax for a little tool window thingy...'Extern "win32" 'Function GetParent(hWnd) 'Function SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx, cy, uFlags) 'End Extern 'Const SWP_NOSIZE = $1 'Const SWP_NOMOVE = $2 'Const HWND_TOPMOST = -1 'Const HWND_NOTOPMOST = -2 ... If ontop ontop = False UncheckMenu(ontopItem) SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) Else ontop = True CheckMenu(ontopItem) SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE) EndIf ......something to be going on with. |
| ||
That's good, but I want to be able to have Windows keep the window ontop rather than doing it myself. I'm also trying to learn how to add an extended bit to the window style. |
| ||
but I want to be able to have Windows keep the window ontop rather than doing it myself. That's exactly what the code above does. I just ripped it straight out of a MaxGUI app and there's a lot of extraneous stuff there. Apologies if that was confusing.I've doctored some old B3D code to do the job (should be easier to understand and get running in B+)... |