Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invisible

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
lepiaf31
Messages : 510
Inscription : dim. 25/mars/2007 13:44
Localisation : Toulouse, France
Contact :

Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invisible

Message par lepiaf31 »

Bonjour bonsoir ! (ca faisait longtemps)

J'essaye d'utiliser AnimateWindow sur une fenêtre purebasic. Bon j'y arrive bien mais le fond de l'HyperLinkGadget n'a pas l'air d'être pris en compte lorsque la fenêtre est initialisée avec #PB_Window_Invisible.
Bon un code pour tester est toujours plus simple qu'un discours:

Code : Tout sélectionner

window = OpenWindow(#PB_Any, 0, 0,400, 60, "", #PB_Window_BorderLess | #PB_Window_Invisible)
SetWindowColor(window, RGB(248,113,5))

text = TextGadget(#PB_Any, 10, 35, 290, 25, "text")
SetGadgetColor(text, #PB_Gadget_BackColor,RGB(248,113,5))

hyperLink1 = HyperLinkGadget(#PB_Any, 300, 0, 100, 20, "Close", 0)
SetGadgetColor(hyperLink1, #PB_Gadget_BackColor,RGB(248,113,5))

hyperLink2 = HyperLinkGadget(#PB_Any, 300, 20, 100, 20, "Rename file", 0)
SetGadgetColor(hyperLink2, #PB_Gadget_BackColor,RGB(248,113,5))

Delay(1000)
AnimateWindow_(WindowID(window), 500, #AW_BLEND | #AW_ACTIVATE)
Repeat : Until WaitWindowEvent()  = #PB_Event_Gadget
et voilà le résultat:
Image
Comme vous pouvez le voir, le fond des liens n'est pas pris en compte à moins de passer le curseur sur le lien. Alors peut-être qu'il y a une histoire de rafraichissement ou quelque chose du style à faire. Mais j'avoue que je ne suis pas expert alors je demande votre aide pour me débarrasser de se comportement étrange.


Voilà merci d'avance !

PS: je suis sous Windows 7 avec PureBasic 5.11
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par venom »

Salut,

Si tu met la ligne :

Code : Tout sélectionner

AnimateWindow_(WindowID(window), 500, #AW_BLEND | #AW_ACTIVATE)
avant tes gadget le problème se résolu. en revanche les gadgets apparaissent après le delay :?

Code : Tout sélectionner

window = OpenWindow(#PB_Any, 0, 0,400, 60, "", #PB_Window_BorderLess | #PB_Window_Invisible)
SetWindowColor(window, RGB(248,113,5))

Delay(1000)
AnimateWindow_(WindowID(window), 500, #AW_BLEND | #AW_ACTIVATE)

text = TextGadget(#PB_Any, 10, 35, 290, 25, "text")
SetGadgetColor(text, #PB_Gadget_BackColor,RGB(248,113,5))

hyperLink1 = HyperLinkGadget(#PB_Any, 300, 0, 100, 20, "Close", 0)
SetGadgetColor(hyperLink1, #PB_Gadget_BackColor,RGB(248,113,5))

hyperLink2 = HyperLinkGadget(#PB_Any, 300, 20, 100, 20, "Rename file", 0)
SetGadgetColor(hyperLink2, #PB_Gadget_BackColor,RGB(248,113,5))

Repeat : Until WaitWindowEvent()  = #PB_Event_Gadget





@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
lepiaf31
Messages : 510
Inscription : dim. 25/mars/2007 13:44
Localisation : Toulouse, France
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par lepiaf31 »

venom a écrit : Si tu met la ligne :

Code : Tout sélectionner

AnimateWindow_(WindowID(window), 500, #AW_BLEND | #AW_ACTIVATE)
avant tes gadget le problème se résolu. en revanche les gadgets apparaissent après le delay :?
Oui c'est un problème. Ca ne me convient pas vraiment hélas.
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par venom »

un peut barbare mais fonctionnel :D

Code : Tout sélectionner

window = OpenWindow(#PB_Any, 0, 0,400, 60, "", #PB_Window_BorderLess | #PB_Window_Invisible)
SetWindowColor(window, RGB(248,113,5))

text = TextGadget(#PB_Any, 10, 35, 290, 25, "text")
SetGadgetColor(text, #PB_Gadget_BackColor,RGB(248,113,5))

hyperLink1 = TextGadget(#PB_Any, 300, 0, 100, 20, "Close", 0)
SetGadgetColor(hyperLink1, #PB_Gadget_BackColor,RGB(248,113,5))

hyperLink2 = TextGadget(#PB_Any, 300, 20, 100, 20, "Rename file", 0)
SetGadgetColor(hyperLink2, #PB_Gadget_BackColor,RGB(248,113,5))

AnimateWindow_(WindowID(window), 1500, #AW_BLEND | #AW_ACTIVATE)
 
FreeGadget(hyperLink1)
FreeGadget(hyperLink2)
    
hyperLink1 = HyperLinkGadget(#PB_Any, 300, 0, 100, 20, "Close", 0)
SetGadgetColor(hyperLink1, #PB_Gadget_BackColor,RGB(248,113,5))

hyperLink2 = HyperLinkGadget(#PB_Any, 300, 20, 100, 20, "Rename file", 0)
SetGadgetColor(hyperLink2, #PB_Gadget_BackColor,RGB(248,113,5))
    
Repeat : Until WaitWindowEvent()  = #PB_Event_Gadget






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
lepiaf31
Messages : 510
Inscription : dim. 25/mars/2007 13:44
Localisation : Toulouse, France
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par lepiaf31 »

Certes ... ^^
En effet, pas très propre mais je garde de coté on ne sais jamais ^^
Avatar de l’utilisateur
falsam
Messages : 7317
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par falsam »

Normalement la couleur de fond d'un HyperLinkGadget() est toujours celui de la fenêtre.
The backgroundcolor is always the color of the window.
Mais ça ...... c'est normalement.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
venom
Messages : 3128
Inscription : jeu. 29/juil./2004 16:33
Localisation : Klyntar
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par venom »

falsam a écrit :Normalement la couleur de fond d'un HyperLinkGadget() est toujours celui de la fenêtre.
The backgroundcolor is always the color of the window.
Mais ça ...... c'est normalement.
Tout a fait :D






@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Avatar de l’utilisateur
falsam
Messages : 7317
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par falsam »

Solution avec un Callback

Code : Tout sélectionner

Enumeration
  #MainForm
  #HyperLink1
  #HyperLink2
EndEnumeration

Procedure WndProc(hwnd, uMsg, wParam, lParam)
  Result = #PB_ProcessPureBasicEvents
  
  Select uMsg
    Case #WM_CTLCOLORSTATIC, #WM_PAINT
      Select lparam
        Case GadgetID(#HyperLink1), GadgetID(#HyperLink2)
          SetBkMode_(wParam, #TRANSPARENT) 
          Result = Color
      EndSelect    
  EndSelect
  ProcedureReturn Result
EndProcedure


OpenWindow(#MainForm, 0, 0, 400, 60, "", #PB_Window_BorderLess | #PB_Window_Invisible)

SetWindowColor(window, RGB(248,113,5))
AnimateWindow_(WindowID(window), 500, #AW_BLEND | #AW_ACTIVATE)
text = TextGadget(#PB_Any, 10, 35, 290, 25, "text")
SetGadgetColor(text, #PB_Gadget_BackColor,RGB(248,113,5))

HyperLinkGadget(#hyperLink1, 300, 0, 100, 20, "Close",  RGB(0,255,0), #PB_HyperLink_Underline)
HyperLinkGadget(#hyperLink2, 300, 20, 100, 20, "Rename file", RGB(0,255,0), #PB_HyperLink_Underline)

SetWindowCallback(@WndProc())

Repeat : Until WaitWindowEvent()  = #PB_Event_Gadget
Effectivement, AnimateWindow_ doit être placer avant les gadgets.
Configuration : Windows 11 Famille 64-bit - PB 6.20 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
lepiaf31
Messages : 510
Inscription : dim. 25/mars/2007 13:44
Localisation : Toulouse, France
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par lepiaf31 »

falsam a écrit : Effectivement, AnimateWindow_ doit être placer avant les gadgets.
Oui mais non sinon il n'y a plus aucun intérêt, c'est moche quoi. Bon je vais chercher encore un peu et sinon tant pis je prendrais une solution sale.
Avatar de l’utilisateur
Ar-S
Messages : 9539
Inscription : dim. 09/oct./2005 16:51
Contact :

Re: Soucis avec le fond d'HyperLinkGadget & #PB_Window_Invis

Message par Ar-S »

solution par les canvas.

Code : Tout sélectionner

; hyperLink en Canvas Gadget by Ar-S - PB 5.20 b11

Global.i BG_COLOR = RGB(248,113,5)
Q = 0

Global LinkFont = LoadFont(#PB_Any, "Arial", 10, #PB_Font_Underline) 

Procedure HyperLinkCanvas(GadgetCanv, TextLink.s, CouleurFond.i, CouleurText.i = $0)
; Ar-S
Protected Larg, Haut, Mid_text_L, Text_H
Shared X_Text, Y_Text, Text_L

Larg = GadgetWidth(GadgetCanv)
Haut = GadgetHeight(GadgetCanv)
Mid_Larg = Larg / 2
Mid_Haut = Haut / 2


StartDrawing(CanvasOutput(GadgetCanv))
      DrawingFont(FontID(LinkFont))
      Text_L = TextWidth(TextLink)
      Text_H = TextHeight(TextLink)
      Mid_text_L = Text_L / 2
      Mid_text_H = Text_H / 2
      
      X_Text = Mid_larg - Mid_text_L
      Y_Text = Haut - Text_H
      
      BackColor(CouleurFond)
      Box (0,0,Larg, Haut,CouleurFond)

      DrawText( X_text, Y_Text, TextLink, CouleurText,CouleurFond)

StopDrawing()

EndProcedure


window = OpenWindow(#PB_Any, 0, 0,400, 60, "", #PB_Window_BorderLess | #PB_Window_Invisible)


text = TextGadget(#PB_Any, 10, 35, 290, 25, "text")

HyperLK1 = CanvasGadget(#PB_Any, 300,0,100,20, #PB_Canvas_ClipMouse)
SetGadgetAttribute(HyperLK1, #PB_Canvas_Cursor, #PB_Cursor_Hand)
HyperLinkCanvas(HyperLK1, "Close", BG_COLOR, $0)

HyperLK2 = CanvasGadget(#PB_Any, 300,21,100,20, #PB_Canvas_ClipMouse)
SetGadgetAttribute(HyperLK2, #PB_Canvas_Cursor, #PB_Cursor_Hand)
HyperLinkCanvas(HyperLK2,  "Rename file", BG_COLOR, $0)


SetWindowColor(window, BG_COLOR)
SetGadgetColor(text, #PB_Gadget_BackColor,BG_COLOR)

AnimateWindow_(WindowID(window), 2500, #AW_BLEND | #AW_ACTIVATE)

Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
        Select EventGadget()
            
            ; lien 1
            Case HyperLK1
                  Select EventType()
                        Case #PB_EventType_MouseMove
                              CX = GetGadgetAttribute(HyperLK1, #PB_Canvas_MouseX)
                              CY = GetGadgetAttribute(HyperLK1, #PB_Canvas_MouseY)
                              
                              If CX > X_Text And CX < X_Text + Text_L
                                    HyperLinkCanvas(HyperLK1, "Close", BG_COLOR, #Blue)
                                    Else
                                    HyperLinkCanvas(HyperLK1, "Close", BG_COLOR, $0)
                              EndIf
                              
                         Case #PB_EventType_MouseLeave
                               HyperLinkCanvas(HyperLk1, "Close", BG_COLOR, $0)     

                         Case #PB_EventType_LeftClick
                              Debug "Runprogram du lien"
                              Q = 1
                              
                  EndSelect
            
            ; lien 2
            Case HyperLK2
            
            Select EventType()
                        Case #PB_EventType_MouseMove
                              CX = GetGadgetAttribute(HyperLK2, #PB_Canvas_MouseX)
                              CY = GetGadgetAttribute(HyperLK2, #PB_Canvas_MouseY)
                              
                              If CX > X_Text And CX < X_Text + Text_L
                                    HyperLinkCanvas(HyperLk2, "Rename file", BG_COLOR, #Blue)
                                    Else
                                    HyperLinkCanvas(HyperLk2, "Rename file", BG_COLOR, $0)
                              EndIf
                         
                         Case #PB_EventType_MouseLeave
                               HyperLinkCanvas(HyperLk2, "Rename file", BG_COLOR, $0)
                              

                         Case #PB_EventType_LeftClick
                              Debug "Rename !"
           
                              
                  EndSelect
            
                
            
      EndSelect
EndSelect
Until Q = 1


~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
Répondre