Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
Je n'ai pas trouvé dans la doc comment changer la couleur de la bordure d'un CanvasGadget lorsque le Flag #PB_Canvas_Border est utilisé. Une suggestion ? (je suis peut-être passé à coté)
----edit----
Perso je préfère créer 2 boites dans le canvas : 1 bordure et 1 couleur de fond mais j'aimerai tout de même connaître la réponse.
Au passage je salue encore la traduction de la doc de la V5. beau boulot !
----edit----
Perso je préfère créer 2 boites dans le canvas : 1 bordure et 1 couleur de fond mais j'aimerai tout de même connaître la réponse.
Au passage je salue encore la traduction de la doc de la V5. beau boulot !
~~~~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
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳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
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
ben j'frai comme ça
** Attention , Grosse Arnaque ... qui marche
** Attention , Grosse Arnaque ... qui marche

Code : Tout sélectionner
If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(1, 10, 10, 200, 200,#PB_Canvas_Border)
; ******* grosse arnaque a Dobro ;o) ***************
StartDrawing(WindowOutput(0))
drawingmode(#PB_2DDrawing_Outlined )
FillArea(1, 1, -1,rgb(255,0,255))
StopDrawing()
; *********************************************
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 1
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(1))
x = GetGadgetAttribute(1, #PB_Canvas_MouseX)
y = GetGadgetAttribute(1, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
;
; EPB
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
Belle arnaque effectivement 

~~~~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
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳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
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
voici la version qui ne colore pas toute la fenetre
et qui resiste a l'effacement si la fenetre sort de l'ecran

et qui resiste a l'effacement si la fenetre sort de l'ecran

Code : Tout sélectionner
enumeration
#win
#cadre
#canvas
EndEnumeration
declare WindowCallback(WindowID,message,wParam,lParam)
If OpenWindow(#win, 0, 0, 600, 600, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
CanvasGadget(#canvas, 20, 20, 190, 190,#PB_Canvas_Border)
; ******* grosse arnaque a Dobro ;o) ***************
StartDrawing(WindowOutput(#win))
drawingmode(#PB_2DDrawing_Outlined )
box(10,10,210,210,rgb(0,0,0))
FillArea(11, 11, -1,rgb(255,0,255))
StopDrawing()
startdrawing(CanvasOutput(#canvas))
FillArea(11, 11, -1,rgb(255,255,255))
StopDrawing()
; *********************************************
SetWindowCallback(@WindowCallback())
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = #canvas
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(#canvas, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(#canvas))
x = GetGadgetAttribute(#canvas, #PB_Canvas_MouseX)
y = GetGadgetAttribute(#canvas, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Procedure WindowCallback(WindowID,message,wParam,lParam)
; by Dobro
res=#PB_ProcessPureBasicEvents
Select message
Case #WM_PAINT
; ******* grosse arnaque a Dobro ;o) ***************
StartDrawing(WindowOutput(#win))
drawingmode(#PB_2DDrawing_Outlined )
box(10,10,210,210,rgb(0,0,0))
FillArea(11, 11, -1,rgb(255,0,255))
StopDrawing()
; *********************************************
ProcedureReturn #True
EndSelect
ProcedureReturn res ; important , laissez passer les autres evenements !!!
EndProcedure
; EPB
Dernière modification par Backup le lun. 12/nov./2012 11:50, modifié 1 fois.
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
bonsoir
pourquoi pas avec "SetWindowColor(0,RGB(255,0,255))"
Cordialement
pourquoi pas avec "SetWindowColor(0,RGB(255,0,255))"
Cordialement
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 220, 220, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetWindowColor(0,RGB(255,0,255))
CanvasGadget(1, 10, 10, 200, 200,#PB_Canvas_Border)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 1
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(1))
x = GetGadgetAttribute(1, #PB_Canvas_MouseX)
y = GetGadgetAttribute(1, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
voilà qui est mieux avec un container
Cordialement

Cordialement
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 250, 250, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(0, 10, 9, 200,202,#PB_Container_Raised)
CloseGadgetList()
SetGadgetColor(0,#PB_Gadget_BackColor, RGB(255,0,255))
DisableGadget(0, 1)
CanvasGadget(1, 20, 20, 180, 180,#PB_Canvas_Border)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 1
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(1))
x = GetGadgetAttribute(1, #PB_Canvas_MouseX)
y = GetGadgetAttribute(1, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
j'y avais pensé, mais en mettant le Canvas dans le container (avant le closeList()
ça ne marchait plus ! plus de dessin possible (j'ai trouvé ça étonnant au passage )
c'est pourquoi je suis parti sur un CallBack
ça ne marchait plus ! plus de dessin possible (j'ai trouvé ça étonnant au passage )
c'est pourquoi je suis parti sur un CallBack

Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
Pour résumer il ni a pas de commande native pour colorier le cadre
Merci pour vos contributions.
ça ne colorie pas le cadre (gris) du canvas.kernadec a écrit :bonsoir
pourquoi pas avec "SetWindowColor(0,RGB(255,0,255))"
Merci pour vos contributions.
~~~~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
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳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
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
bonjour
@Dobro
oui comme toi, j'avais un problème avec CloseGadgetlist
et l'idée m'est venue de mettre un DisableGadget,
en me rappelant le truc du bouton avec l' ImageGadget.
@Ar-s
pour le cadre gris... si on ne met pas les options,
Cela semble faire ce que tu demande. c'est même fun
Cordialement
@Dobro
oui comme toi, j'avais un problème avec CloseGadgetlist
et l'idée m'est venue de mettre un DisableGadget,
en me rappelant le truc du bouton avec l' ImageGadget.
@Ar-s
pour le cadre gris... si on ne met pas les options,
Cela semble faire ce que tu demande. c'est même fun

Cordialement
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 250, 250, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(3, 6, 6, 208,208, #PB_Container_Flat)
CloseGadgetList()
SetGadgetColor(3,#PB_Gadget_BackColor, RGB(0,255,0))
DisableGadget(3, 1)
ContainerGadget(0, 10,10, 200,200, #PB_Container_Flat)
CloseGadgetList()
SetGadgetColor(0,#PB_Gadget_BackColor, RGB(255,0,255))
DisableGadget(0, 1)
CanvasGadget(1, 20, 20, 180, 180)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = 1
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(1))
x = GetGadgetAttribute(1, #PB_Canvas_MouseX)
y = GetGadgetAttribute(1, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
l'avantage du callback c'est de pouvoir faire ça 

Code : Tout sélectionner
enumeration
#win
#cadre
#canvas
EndEnumeration
declare WindowCallback(WindowID,message,wParam,lParam)
If OpenWindow(#win, 0, 0, 600, 600, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
CanvasGadget(#canvas, 20, 20, 190, 190,#PB_Canvas_Border)
; ******* grosse arnaque a Dobro ;o) ***************
StartDrawing(WindowOutput(#win))
drawingmode(#PB_2DDrawing_Outlined )
box(10,10,210,210,rgb(0,0,0))
FillArea(11, 11, -1,rgb(255,0,255))
StopDrawing()
startdrawing(CanvasOutput(#canvas))
FillArea(11, 11, -1,rgb(255,255,255))
StopDrawing()
; *********************************************
SetWindowCallback(@WindowCallback())
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_Gadget And EventGadget() = #canvas
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(#canvas, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(#canvas))
x = GetGadgetAttribute(#canvas, #PB_Canvas_MouseX)
y = GetGadgetAttribute(#canvas, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Procedure WindowCallback(WindowID,message,wParam,lParam)
; by Dobro
res=#PB_ProcessPureBasicEvents
Select message
Case #WM_PAINT
; ******* grosse arnaque a Dobro ;o) ***************
StartDrawing(WindowOutput(#win))
drawingmode(#PB_2DDrawing_Outlined )
box(10,10,210,210,rgb(0,0,0))
FillArea(11, 11, -1,rgb(0,255,0))
drawingmode(#PB_2DDrawing_Default )
; haut
for i=2 to 204 step 6
circle(11+i,15,2,rgb(random(255),random(255),random(255)))
next i
; bas
for i=2 to 204 step 6
circle(11+i,213,2,rgb(random(255),random(255),random(255)))
next i
; gauche
for i=2 to 204 step 6
circle(15,11+i,2,rgb(random(255),random(255),random(255)))
next i
; droite
for i=2 to 204 step 6
circle(213,11+i,2,rgb(random(255),random(255),random(255)))
next i
StopDrawing()
; *********************************************
delay(10)
ProcedureReturn #True
EndSelect
ProcedureReturn res ; important , laissez passer les autres evenements !!!
EndProcedure
; EPB
Dernière modification par Backup le lun. 12/nov./2012 13:15, modifié 1 fois.
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)


Cordialement
Code : Tout sélectionner
If OpenWindow(0, 0, 0, 250, 250, "CanvasGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ContainerGadget(3, 6, 6, 208,208, #PB_Container_Flat)
CloseGadgetList()
SetGadgetColor(3,#PB_Gadget_BackColor, RGB(0,255,0))
DisableGadget(3, 1)
ContainerGadget(0, 8,8, 204,204, #PB_Container_Flat)
CloseGadgetList()
SetGadgetColor(0,#PB_Gadget_BackColor, RGB(255,255,255))
DisableGadget(0, 1)
CanvasGadget(1, 10, 10, 200, 200)
Repeat
Event = WindowEvent()
StartDrawing(CanvasOutput(1))
; haut
For i=2 To 193 Step 6
Circle(4+i,4,2,RGB(Random(255),Random(255),Random(255)))
Next i
; bas
For i=2 To 193 Step 6
Circle(4+i,193,2,RGB(Random(255),Random(255),Random(255)))
Next i
; gauche
For i=2 To 193 Step 6
Circle(4,4+i,2,RGB(Random(255),Random(255),Random(255)))
Next i
; droite
For i=2 To 193 Step 6
Circle(193,4+i,2,RGB(Random(255),Random(255),Random(255)))
Next i
StopDrawing()
If Event = #PB_Event_Gadget And EventGadget() = 1
If EventType() = #PB_EventType_LeftButtonDown Or (EventType() = #PB_EventType_MouseMove And GetGadgetAttribute(1, #PB_Canvas_Buttons) & #PB_Canvas_LeftButton)
If StartDrawing(CanvasOutput(1))
x = GetGadgetAttribute(1, #PB_Canvas_MouseX)
y = GetGadgetAttribute(1, #PB_Canvas_MouseY)
Circle(x, y, 10, RGB(Random(255), Random(255), Random(255)))
StopDrawing()
EndIf
EndIf
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
ha oui , dans la boucle Repeat , ça le fait aussi
arg , les vieux reflex
je préfère quand meme une procédure externe , ça rends plus lisible la boucle principale


arg , les vieux reflex

je préfère quand meme une procédure externe , ça rends plus lisible la boucle principale


Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
et sans wait le processeur est à la fête aussi ça chauffe
tu as raison, je préfère également une procédure externe.
Cordialement
ps: à propos de CanvasDadget, il lui manque une option couleur avec alpha pour le fond.
cela permettrait de l'utiliser en mode calque etc...

tu as raison, je préfère également une procédure externe.
Cordialement
ps: à propos de CanvasDadget, il lui manque une option couleur avec alpha pour le fond.
cela permettrait de l'utiliser en mode calque etc...
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
DrawingMode(Mode) ne te convient pas ?
~~~~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
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳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
Re: Changer la couleur Bordure Canvas ? (#PB_Canvas_Border)
bonjour Ar-s
oui DrawingMode c'est bien pour le dessin sur le canvas.
enfin, je parlais de la surface de dessin de CanvasGadget.
On pourrait avoir la possibilité de choisir une couleur
de fond avec l'option transparence de cette surface,
genre fenêtre transparente.
Cordialement
oui DrawingMode c'est bien pour le dessin sur le canvas.
enfin, je parlais de la surface de dessin de CanvasGadget.
On pourrait avoir la possibilité de choisir une couleur
de fond avec l'option transparence de cette surface,
genre fenêtre transparente.
Cordialement