Window

Blitz3D Forums/Blitz3D Programming/Window

in which way could i create an always on top window[you cannot minimize it...]

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


It doesn't do anythings...

Did you add the neccessary stuff to user32.decls in the userlibs folder?

Yes, but it doesn't work...

In the first post i had an error:
i would make the window of the program in execution always on top, not create another.

Personally I am using SetWindowPos to make a window remain always ontop, have a look at the Api docs on www.msdn.com .

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

Hey, that's AI. hats off.

Which parameters Setwindowpos have?
Doeas this command make the window on top also if you click the desktop icon in the quick lunch toolbar?

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.

It works, but if i press the desktop icon in the quick lunch toolbar(near start) in win2k the window minimize itself...

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

it doesn't work...
i still can minimize the window pressing 'desktop icon' near 'start' button...

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... ;)

Set a full screen graphics mode, then switch back to windowed mode. This will force 'always on top'.

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.

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?

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.

Thanks!!!
It works!!!

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

Yay!

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.

Thanks, but it doesn't need the minimize button disabled, it was the icon in the quicklunch bar the problem.

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).

Sorry i would like to tell you this but i cant because i dont know what type of program you are making.

scuse me, but i cannot tell you it...
i need a way to make a not possible to close window...

Thanks, Sarge. I've been trying to do this for ages.
Hats off!