Page 1 sur 1

Fenêtre non-cliquable!

Publié : sam. 15/mars/2008 21:47
par nico

;----------------------------------------------------------------
; Un exemple pour créer une fenêtre non cliquable
; Pour la rendre de nouveau cliquable appuyer sur la touche CONTROL
;----------------------------------------------------------------
; Cela ouvre d'intéressantes perspectives...
;----------------------------------------------------------------
; Références:
; http://msdn2.microsoft.com/fr-fr/magazi ... n-us).aspx
; http://www.codeproject.com/KB/vb/ClickT ... ndows.aspx
;----------------------------------------------------------------

Procedure Cliquable(Lparam.l)
GetAsyncKeyState_ ( #VK_CONTROL )
Repeat
     If GetAsyncKeyState_ ( #VK_CONTROL )
         SetWindowLong_ ( WindowID (0), #GWL_EXSTYLE , GetWindowLong_ ( WindowID (0), #GWL_EXSTYLE )& ~#WS_EX_TRANSPARENT)
         SetLayeredWindowAttributes_ ( WindowID (0), 0, 255, #LWA_ALPHA )
     EndIf
     Delay (50)
ForEver
EndProcedure


If OpenWindow (0, 100, 200, 195, 260, "PureBasic Window" , #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget )

SetWindowLong_ ( WindowID (0), #GWL_EXSTYLE , GetWindowLong_ ( WindowID (0), #GWL_EXSTYLE )|#WS_EX_LAYERED|#WS_EX_TRANSPARENT)
SetLayeredWindowAttributes_ ( WindowID (0), 0, 155, #LWA_ALPHA )

StickyWindow (0,1)

CreateThread (@Cliquable(),Lparam)

   Repeat
    EventID = WaitWindowEvent ()

     If EventID = #PB_Event_CloseWindow
      Quit = 1
     EndIf

   Until Quit = 1
EndIf
End
  

Publié : sam. 15/mars/2008 22:38
par Backup
Super Merci :D

Publié : sam. 15/mars/2008 22:45
par Droopy
ça peut m'être utile, merci pour le code :wink:

Publié : sam. 15/mars/2008 22:57
par erix14
Merci. Effectivement, ça m'ouvre des perspectives très intéressantes dans l'affichage de données, comme l'affichage de flux RSS en temps réel sur mon écran sans que cette fenêtre me gêne pour travailler. Cependant, il faudrait une petite zone de cette fenêtre qui soit cliquable pour simplement la déplacer... Voir même un petit bouton pour la fermer, je n'aime pas beaucoup les raccourcis clavier...

Publié : sam. 15/mars/2008 23:54
par nico
On peut faire ça:

Code : Tout sélectionner

Procedure TimerProc(hwnd.l, uMsg.l, idEvent.l, dwTime.l)
   Select uMsg
     Case #WM_TIMER
       Select idEvent
         Case 0
            GetCursorPos_(@Point.POINT)
            GetWindowRect_(WindowID(0),@Rect.RECT)
            Hauteur_Caption=GetSystemMetrics_(#SM_CYCAPTION)
            Rect\Bottom=Rect\Top+Hauteur_Caption
            If PtInRect_(@Rect,Point\x,Point\y)
                SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)& ~#WS_EX_TRANSPARENT)
                SetLayeredWindowAttributes_(WindowID(0), 0, 255, #LWA_ALPHA)
            Else
                SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_TRANSPARENT)
                SetLayeredWindowAttributes_(WindowID(0), 0, 155, #LWA_ALPHA)     
            EndIf 
       EndSelect
   EndSelect
EndProcedure 

If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)

SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_LAYERED|#WS_EX_TRANSPARENT)
SetLayeredWindowAttributes_(WindowID(0), 0, 155, #LWA_ALPHA)

StickyWindow(0,1)

SetTimer_(WindowID(0), 0, 50, @TimerProc()) 

  Repeat
    EventID = WaitWindowEvent()

    If EventID = #PB_Event_CloseWindow 
      Quit = 1
    EndIf

  Until Quit = 1
EndIf
End

Publié : dim. 16/mars/2008 0:04
par erix14
Merci, c'est parfait. Beau travail. :D

Publié : dim. 16/mars/2008 0:29
par nico
Merci :)

Une autre possibilité:

Code : Tout sélectionner

#HTCLOSE=20
Procedure TimerProc(hwnd.l, uMsg.l, idEvent.l, dwTime.l)
   Select uMsg
     Case #WM_TIMER
       Select idEvent
         Case 0
            GetCursorPos_(@Point.POINT)
            x.w=(point\x & $FFFF):y.w=(point\y & $FFFF)
            lParam=x+(y<<16)
            result=SendMessage_(WindowID(0),#WM_NCHITTEST,0,lParam)

            If result= #HTCAPTION Or result=#HTMINBUTTON Or result=#HTMAXBUTTON Or result=#HTCLOSE
                SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)& ~#WS_EX_TRANSPARENT)
                SetLayeredWindowAttributes_(WindowID(0), 0, 255, #LWA_ALPHA)
            Else
                SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_TRANSPARENT) 
                SetLayeredWindowAttributes_(WindowID(0), 0, 155, #LWA_ALPHA)
            EndIf 
       EndSelect
   EndSelect
EndProcedure 

If OpenWindow(0, 100, 200, 195, 260, "PureBasic Window", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)

SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE)|#WS_EX_LAYERED|#WS_EX_TRANSPARENT)
SetLayeredWindowAttributes_(WindowID(0), 0, 155, #LWA_ALPHA)

StickyWindow(0,1)

SetTimer_(WindowID(0), 0, 50, @TimerProc()) 

  Repeat
    EventID = WaitWindowEvent()

    If EventID = #PB_Event_CloseWindow 
      Quit = 1
    EndIf

  Until Quit = 1
EndIf
End

Publié : dim. 16/mars/2008 1:05
par Backup
super !! ces petits code .. :)

Merci :)