Always on bottom?
Always on bottom?
Hy,
Everybody knows how to set a window to "always on top". Do you know a way to get a window to "always on bottom?". Maybe there is a small check the window can do to find out if another window opened behind it?
Everybody knows how to set a window to "always on top". Do you know a way to get a window to "always on bottom?". Maybe there is a small check the window can do to find out if another window opened behind it?
From the newbies faq at beginners section:
Always on top:
Always on bottom:
USE THE SEARCH BUTTON ALREADY!!

Always on top:
Code: Select all
SetWindowPos_(WindowID(),#HWND_TOPMOST,0,0,0,0,#SWP_NOMOVE|#SWP_NOSIZE)
Code: Select all
SetParent_(WindowID(),GetWindow_(FindWindow_(0,"Program Manager"),#GW_CHILD))
Thank you for your answer! I will try this out.
But please stop this "
Use the SEARCH button". I DID USE the search button - but this button brought nearly every single thread when typing "always on bottom" - I could search the forum by hand and would be quicker - you know I even tried this!
Anyway the newbies faq could be worth a visit.
But please stop this "
Anyway the newbies faq could be worth a visit.
Hello!
Yes, you are right, you can find this in the newbes faq.
I tried this piece of code and this really works - the window is never above another window.
But there ist still a problem: Sometimes my application window disappears - (it didn't that before) - the task manager still shows the application, but it is simply not visible anymore! Could it be that my window is now 'behind' the desktop environment? I think so because this problem also matters if I change the background image of the desktop - suddenly my app disappears!
Yes, you are right, you can find this in the newbes faq.
I tried this piece of code and this really works - the window is never above another window.
But there ist still a problem: Sometimes my application window disappears - (it didn't that before) - the task manager still shows the application, but it is simply not visible anymore! Could it be that my window is now 'behind' the desktop environment? I think so because this problem also matters if I change the background image of the desktop - suddenly my app disappears!
> if I change the background image of the desktop - suddenly my app disappears
Hmm, I couldn't do this with XP -- the app was still visible. Got some code
that demonstrates the problem? And I'll need your version of Windows.
Hmm, I couldn't do this with XP -- the app was still visible. Got some code
that demonstrates the problem? And I'll need your version of Windows.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
You really should read the newbie threads before posting questions, infact you should give the whole manual a read before asking because after all you are a PB newbie and thats what they are there for.Kazmirzak wrote:Thank you for your answer! I will try this out.
But please stop this "Use the SEARCH button". I DID USE the search button - but this button brought nearly every single thread when typing "always on bottom" - I could search the forum by hand and would be quicker - you know I even tried this!
Anyway the newbies faq could be worth a visit.
I figured out that my app also disappears when I press the F5 Button when the desktop is active, what does a 'refresh' of the desktop. I use Windows 98B.
The shortest code to test this should look like this:
1. OpenWindow (blabla)
2. SetParent_(WindowID(),GetWindow_(FindWindow_(0,"Program Manager"),#GW_CHILD))
3. Progress the Events until Quit
The shortest code to test this should look like this:
1. OpenWindow (blabla)
2. SetParent_(WindowID(),GetWindow_(FindWindow_(0,"Program Manager"),#GW_CHILD))
3. Progress the Events until Quit
Ah, I see what you mean... and I found the fix, you must do this instead:
This works on all versions of Windows. The FAQ will be updated. Thanks for the bug report! 
Code: Select all
SetParent_(WindowID(),FindWindow_(0,"Program Manager"))
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Try one of these...
In the event loop...
In the WindowCallback... <-- This is the one I use
In the event loop...
Code: Select all
If OpenWindow(0, 100, 150, 300, 100, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar, "Test")
SetWindowPos_(WindowID(), #HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
Repeat
event = WaitWindowEvent()
If GetForegroundWindow_() = WindowID()
SetWindowPos_(WindowID(), #HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
EndIf
Until event = #PB_Event_CloseWindow
EndIf Code: Select all
Procedure myWindowCallback(hWnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_WINDOWPOSCHANGING
*winPos.WINDOWPOS = lParam
*winPos\flags | #SWP_NOZORDER
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 100, 150, 300, 100, #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar, "Test")
SetWindowPos_(WindowID(), #HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE | #SWP_SHOWWINDOW)
SetWindowCallback(@myWindowCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
So now for PB: Turn off your debugger. Start this code. Close ALL windows but the "New Desktop Utility". Now click the "New desktop utility" window and then press Alt+Tab. The window disappears forever on Win XP.
The new two solutions are very good - the only bad thing is that they don't hide the icon in the Alt-Tab-Popup. But this can be solved, can't it?
;***********************code snippet showing the error***********
;window creation
OpenWindow(1,0,0,800,600,#PB_WINDOW_SYSTEMMENU | 0,"New Desktop") :CreateGadgetList(WindowID(1))
;super - line
SetParent_(WindowID(F1),FindWindow_(0,"Program Manager"))
;wait-line
Repeat
event=WaitWindowEvent()
Until event=#PB_EventCloseWindow
;***********************************************************
The new two solutions are very good - the only bad thing is that they don't hide the icon in the Alt-Tab-Popup. But this can be solved, can't it?
;***********************code snippet showing the error***********
;window creation
OpenWindow(1,0,0,800,600,#PB_WINDOW_SYSTEMMENU | 0,"New Desktop") :CreateGadgetList(WindowID(1))
;super - line
SetParent_(WindowID(F1),FindWindow_(0,"Program Manager"))
;wait-line
Repeat
event=WaitWindowEvent()
Until event=#PB_EventCloseWindow
;***********************************************************





