Page 2 of 2

Re: Pin a window to the desktop

Posted: Fri Dec 04, 2009 11:55 am
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

Re: Pin a window to the desktop

Posted: Fri Dec 04, 2009 1:25 pm
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

Re: Pin a window to the desktop

Posted: Fri Dec 04, 2009 3:21 pm
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