[bb] Keep A Window On Top by SebHoll [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:38

Previous topic - Next topic

BlitzBot

Title : Keep A Window On Top
Author : SebHoll
Posted : 1+ years ago

Description : 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) [/i]

Code :
Code (blitzbasic) Select
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 :


Hip Teen(Posted 1+ years ago)

 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 + ontopbut as I said, just a little thing ;-)


TomToad(Posted 1+ years ago)

 What aboutontop = ontop - 2or eliminate the check altogether and just useSetWindowPos(wndHandle,ontop-2,0,0,0,0,1+2+40)


SebHoll(Posted 1+ years ago)

 Good point! - That makes much more sense. Is there anyway I can edit the code I've put down or not?


SebHoll(Posted 1+ years ago)

 Found out how to edit it. :PThanksSeb [/i]