Fenêtre non-cliquable!

Partagez votre expérience de PureBasic avec les autres utilisateurs.
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Fenêtre non-cliquable!

Message 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
  
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

Super Merci :D
Avatar de l’utilisateur
Droopy
Messages : 1151
Inscription : lun. 19/juil./2004 22:31

Message par Droopy »

ça peut m'être utile, merci pour le code :wink:
erix14
Messages : 480
Inscription : sam. 27/mars/2004 16:44
Contact :

Message 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...
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Message 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
erix14
Messages : 480
Inscription : sam. 27/mars/2004 16:44
Contact :

Message par erix14 »

Merci, c'est parfait. Beau travail. :D
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Message 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
Backup
Messages : 14526
Inscription : lun. 26/avr./2004 0:40

Message par Backup »

super !! ces petits code .. :)

Merci :)
Répondre