Pin a window to the desktop

Windows specific forum
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Re: Pin a window to the desktop

Post by Le Soldat Inconnu »

This work well on XP but on Vista (and may be 7) it's don't work well.

Any solution ? or tell me if it's work well. Thanks

Code: Select all

If OpenWindow(0, 0, 0, 300, 300, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget) = 0
  End
EndIf

SetParent_(WindowID(0), GetShellWindow_())

ButtonGadget(0, 0, 0, 100, 100, "Button")

Repeat
  Event = WaitWindowEvent()
  
		Case #PB_Event_Gadget
      Select EventGadget() ; Gadgets
 				Case 0
					Debug "OK"
			EndSelect
	EndSelect
  
Until Event = #PB_Event_CloseWindow
LSI
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Pin a window to the desktop

Post by gnozal »

This code may have the same effect (not tested on Vista/se7en).

Code: Select all

;
; Force a window to stay in the background
;
Procedure Callback(WindowID, message, wParam, lParam) 
  Protected *WindowPos.WINDOWPOS 
  Result = #PB_ProcessPureBasicEvents 
  ; 
  If message = #WM_WINDOWPOSCHANGING ; Window position is about to change !
    *WindowPos = lParam 
    *WindowPos\hwndInsertAfter = #HWND_BOTTOM   ; <-- Forces the window to stay in the background
  EndIf 
  ; 
  ProcedureReturn Result 
EndProcedure 

If OpenWindow(0, 450, 200, 400, 400, "Reste dans le fond même si a le focus", #PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget|#PB_Window_TitleBar) 
  
  SetWindowCallback(@Callback(), 0) 
  SetWindowPos_(WindowID(0), #HWND_BOTTOM, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE) ; Forces the window to stay in the background the 1st time
  
  Repeat 
    Event = WaitWindowEvent() 
    Select Event 
      Case #PB_Event_CloseWindow 
        Break 
    EndSelect 
  ForEver
EndIf
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
User avatar
Le Soldat Inconnu
Enthusiast
Enthusiast
Posts: 306
Joined: Wed Jul 09, 2003 11:33 am
Location: France

Re: Pin a window to the desktop

Post by Le Soldat Inconnu »

no, because when you show desktop (Windows + D), the windows disappear.

I search to do something like Widget.
So my window have to be attach on desktop.

But this code is interesting. For this moment. He will help me on another bug. Thanks for your help
LSI
Post Reply