Code archives/BlitzPlus Gui/Keep A Window On Top
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
In short, this script makes a basic window and calls the function "MakeWindowOnTop()" which sets the windows attributes to always be on top. I've tried the code on Windows XP and it works fine. Syntax for the "MakeWindowOnTop()" function is: MakeWindowOnTop(blitzwindowhandle,ontop) blitzwindowhandle = The Gadget Handle For The Window Given By Blitz ontop = Either 1 or 0. 1 makes the window "always on top". 0 Removes the "always on top" attribute. Really easy to follow and use - just thought someone might need it. I've tried to document as best as I can. Please post any suggestions... Seb Userlib Declaration: .lib "user32.dll" SetWindowPos%(hwnd%,hWndInsertAfter%,x%,y%,cx%,cy%,wFlags%):"SetWindowPos" Sample Code: (Thanks to Hip Teen and TomToad for suggestions) | |||||
wndMain = CreateWindow("Hello",100,100,400,300,0,5) MakeWindowOnTop(wndMain) Repeat If WaitEvent() = $803 Then End Forever ;+++++++++++++++++++++++++++++++++++++ ;FUNCTION ;+++++++++++++++++++++++++++++++++++++ Function MakeWindowOnTop(wndBlitzHandle,ontop=1) ;Windows gadget handle and switch to be set. Defaults to 1. E.g. make ontop. wndHandle = QueryObject(wndBlitzHandle,1) ;Gets the actual handle of the window to be used with API call. SetWindowPos(wndHandle,ontop-2,0,0,0,0,1+2+40) ;Applies setting to window with constants at end (see below). ;1: Keep Original Window Size ;2: Keep Orginal Pos. ;40: Keep Original Z-Order End Function |
Comments
| ||
Just a little thing, but you can replace Select ontop Case 1:ontop = -1 Case 0:ontop = -2 End Select by this line: ontop = -2 + ontop but as I said, just a little thing ;-) |
| ||
What aboutontop = ontop - 2 or eliminate the check altogether and just use SetWindowPos(wndHandle,ontop-2,0,0,0,0,1+2+40) |
| ||
Good point! - That makes much more sense. Is there anyway I can edit the code I've put down or not? |
| ||
Found out how to edit it. :P Thanks Seb |
Code Archives Forum