Window

Blitz3D Forums/Blitz3D Programming/Window

splinux(Posted 2005) [#1]
in which way could i create an always on top window[you cannot minimize it...]


Picklesworth(Posted 2005) [#2]
I have this one :D
Uses win32. You may need these lines added to user32.decls
api_GetWindowLong% (hwnd%, nIndex%) : "GetWindowLongA"
api_SetWindowLong% (hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA"
Const GWL_STYLE=(-16),WS_DISABLED=$08000000,WS_POPUP=$80000000 ;Win32 constants
hWnd=SystemProperty("AppHWND") ;Get the window handle
style=GetWindowLong(hWnd ,GWL_STYLE) ;Find out the current window style so we can add to it
style = style + WS_POPUP ;Make the window a popup window
SetWindowLong hwnd,GWL_STYLE,style ;Set the style



splinux(Posted 2005) [#3]
It doesn't do anythings...


jfk EO-11110(Posted 2005) [#4]
Did you add the neccessary stuff to user32.decls in the userlibs folder?


splinux(Posted 2005) [#5]
Yes, but it doesn't work...


splinux(Posted 2005) [#6]
In the first post i had an error:
i would make the window of the program in execution always on top, not create another.


jfk EO-11110(Posted 2005) [#7]
Personally I am using SetWindowPos to make a window remain always ontop, have a look at the Api docs on www.msdn.com .


Picklesworth(Posted 2005) [#8]
My code currently has an odd habit of suddenly deciding to not work...


jfk EO-11110(Posted 2005) [#9]
Hey, that's AI. hats off.


splinux(Posted 2005) [#10]
Which parameters Setwindowpos have?
Doeas this command make the window on top also if you click the desktop icon in the quick lunch toolbar?


Sarge(Posted 2005) [#11]
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = 1
Const SWP_NOMOVE = 2
Const SWP_SHOWWINDOW = 40

Function WinSettings( x, y, width, height, topmost )
hwnd=Api_GetActiveWindow()

Select topmost
Case true
topmost=HWND_TOPMOST
Case false
topmost=HWND_NOTOPMOST
End Select

Api_SetWindowPos( hwnd, topmost, x, y, width, height, SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOSIZE )
End Function


I dont use blitz3d so i dont know the lib commands, but once you get them this should work.


splinux(Posted 2005) [#12]
It works, but if i press the desktop icon in the quick lunch toolbar(near start) in win2k the window minimize itself...


Sarge(Posted 2005) [#13]
You can do a check in your Repeat / Until command
like this:
Function CheckMin()
hwnd=Api_GetActiveWindow()
If IsIconic(hwnd) then
WinSettings( 5,5, 300, 300, true )
End If
End Function


Hope this helps


splinux(Posted 2005) [#14]
it doesn't work...
i still can minimize the window pressing 'desktop icon' near 'start' button...


Rook Zimbabwe(Posted 2005) [#15]
Mr. Picklesworth (Posted 2005-05-01 11:45:59)

My code currently has an odd habit of suddenly deciding to not work...

It's a feature... ;)


GfK(Posted 2005) [#16]
Set a full screen graphics mode, then switch back to windowed mode. This will force 'always on top'.


Picklesworth(Posted 2005) [#17]
It's a feature... ;)

Ah yes, 3 bug fixes in one day is a feature!
Yay :D

SpLinux, what is this window for? Perhaps there's another way to do this.


splinux(Posted 2005) [#18]
Yes, if i could keep my program always working also if it is minimized.
There is a chance to transform the program to put it on the "clock toolbar"?

Sarge: what is wrong in your program?


Sarge(Posted 2005) [#19]
As i said i dont use blitz3d i cant even test this myself but give this a try

Local x=50
Local y=50
Local width=800
Local height=600
Local ontop=True

AppTitle "test" 

Graphics width,height

Const HWND_TOPMOST = -1 
Const HWND_NOTOPMOST = -2 
Const SWP_NOSIZE = 1 
Const SWP_NOMOVE = 2 
Const SWP_SHOWWINDOW = 40 
Const SW_RESTORE=9

WinSettings( x, y, width, height, ontop )

While Not KeyHit(1)

CheckMin()

Flip
Wend
End

Function WinSettings( x, y, width, height, topmost ) 
hwnd=api_FindWindow("Blitz Runtime Class","test" ) 
Select topmost
Case True 
topmost=HWND_TOPMOST
Case False 
topmost=HWND_NOTOPMOST
End Select 
Api_SetWindowPos( hwnd, topmost, x, y, width, height, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE ) 
End Function

Function CheckMin()
hwnd=api_FindWindow("Blitz Runtime Class", "test") 
If api_IsIconic(hwnd)=True Then
api_ShowWindow(hwnd,SW_RESTORE)
End If
End Function

userlib commands can be found here - http://www.blitzbasic.co.nz/Community/posts.php?topic=27586

[edit]code updated

Hope it works.


splinux(Posted 2005) [#20]
Thanks!!!
It works!!!

Now, if i click the icon the window minimize itself, but after this it maximize itself too!


Picklesworth(Posted 2005) [#21]
Yay!


Sarge(Posted 2005) [#22]
The other way is just to use GetWindowLong / SetWindowLong and disable the minimize button. If you want me to create that just tell me.

Im happy it worked.


splinux(Posted 2005) [#23]
Thanks, but it doesn't need the minimize button disabled, it was the icon in the quicklunch bar the problem.


splinux(Posted 2005) [#24]
Scuse me, but i need another thing not in this argument:
there is a way to set privileges to the current application?
I need the window will cannot be closed(for example task menager will not close it).


Sarge(Posted 2005) [#25]
Sorry i would like to tell you this but i cant because i dont know what type of program you are making.


splinux(Posted 2005) [#26]
scuse me, but i cannot tell you it...
i need a way to make a not possible to close window...


John Blackledge(Posted 2005) [#27]
Thanks, Sarge. I've been trying to do this for ages.
Hats off!