Comment feriez vous pour que la croix apparaisse au dessus du bouton et bien sur suive la fenetre.
Car le bleme c'est que la croix c'est aussi une fenetre.
Et que quand on clique sur le bouton la croix ne disparaisse pas derriere

J'ai pensé aux fenetres filles, mais a ce moment la, le bouton se retrouve au dessus de la croix

A moins que vous ayez une meilleure methode qu'avec une fenetre pour la croix rouge peut etre un sprite, une image gadget a fond transparent un draw quelque chose


Voici la croix:
http://purebasic.myftp.org/files/413/CroixRouge.png
Et le code:
Code : Tout sélectionner
Enumeration
#Window_Main = 1
#Button_0 = 2
#Croix = 3
EndEnumeration
Declare OpenMaskedWindow_CroixRouge(WinID, xx, yy, Title.s, imID)
Declare myCallback(Hwnd.l, uMsg.l, wParam.l, lParam.l)
Global Dim DistanceCroixRougeX(50)
Global Dim DistanceCroixRougeY(50)
UsePNGImageDecoder()
OpenWindow(#Window_Main,20,20,150,150,"Mère",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(#Window_Main))
ButtonGadget(#Button_0, 45, 45, 55, 55, "")
OpenMaskedWindow_CroixRouge(#Croix, WindowX(#Window_Main) + 50, WindowY(#Window_Main) + 60, "CroixRouge", 0)
SetWindowCallback(@myCallback(),#Window_Main)
DistanceCroixRougeX(1) = WindowX(#Croix) - WindowX(#Window_Main)
DistanceCroixRougeY(1) = WindowY(#Croix) - WindowY(#Window_Main)
Repeat
event=WaitWindowEvent()
Until event=#PB_Event_CloseWindow
Procedure OpenMaskedWindow_CroixRouge(WinID, x, y, Title.s, imID)
HwndCroixRouge = OpenWindow(winID, GetSystemMetrics_(#SM_CXSCREEN), y, 44, 68, Title, #WS_POPUP)
Memhandle = GlobalAlloc_(#GMEM_MOVEABLE,1672)
*Mem = GlobalLock_(Memhandle)
UnpackMemory(?CroixRouge_Mask, *Mem)
Region = ExtCreateRegion_(0,1664, *Mem)
SetWindowRgn_(HwndCroixRouge, Region, #True)
Pic = CatchImage(imID,?CroixRouge)
Brush = CreatePatternBrush_(Pic)
SetClassLong_(HwndCroixRouge, #GCL_HBRBACKGROUND, Brush)
ResizeWindow(WinID, x, y, #PB_Ignore, #PB_Ignore)
GlobalUnlock_(Memhandle)
GlobalFree_(Memhandle)
DeleteObject_(Region)
ProcedureReturn HwndCroixRouge
DataSection
CroixRouge:
;***********
IncludeBinary "CroixRouge.png"
CroixRouge_Mask:
;***********
Data.l $680434A ,$3D670000,$50110000,$4792000 ,$86604204,$AAD292E0,$9184C004,$A093C34A,$A5282A84,$D3AA808A
Data.l $4A1934A8,$832A9285,$AA983A29,$8A2D2610,$20A17380,$4282876 ,$A3129942,$A1D4608 ,$38088862,$894A3A21
Data.l $2A94A352,$8A38584 ,$A858E846,$4E849A13,$3DA142A8,$842A608A,$56083A81,$13A884E8,$A84EA3DA,$8A411842
Data.l $7D848660,$E876A13A,$5A132A74,$42A708A4,$608AA798,$29E64E88,$93A24999,$926610A9,$842A5822,$A6084A75
Data.l $929C54E8,$953AA4D9,$2946610A,$18422D82,$8C6044A7,$9129A44E,$A9138A51,$2295B610,$6984A318,$E8D6624A
Data.l $58122A34,$A8908A5 ,$873A9A61,$960C3A39,$428E5929,$4A5A898 ,$3AA56088,$B767D882,$4A61474B,$75221961
Data.l $10468129,$989138EB,$429058F3,$7DA72818,$8229608A,$1E323A41,$1561E503,$A53A2C7 ,$731608CB,$846CA06
Data.l $EA0624FB,$B1055428,$1194108C,$108C42C8,$46D0EA26,$842AB2A5,$E32C1C65,$A9B846C0,$C09CC952,$93EBF4FA
Data.l $6541B062,$4EA71A3C,$52430EA8,$54B14EA8,$D29D8CA7,$87190550,$507352A6,$82AA4EAA,$8CA7AA58,$59D558C3
Data.l $D56C55A8,$58134D89,$82AB4119,$AC5AAB18,$A7566D4E,$D58C430C,$A719A851,$AB934156,$4EA50E3 ,$30CAAB54
Data.l $5EC4E5BC,$829D871D,$86191572,$C1445EE1,$5093620A,$70C38EAF,$758AAC1C,$60A12A34,$B1048B1D,$8EB22758
Data.l $C53A6546,$C32620A ,$9A8FC9CD,$A227C415,$21861D64,$EB4559BC,$CD885488,$E32A1E3A,$AB102B44,$32754475
Data.l $1865568A,$651EABCE,$882B882B,$2A543AD5,$8F1D64E3,$275B75BA,$65486CA4,$5163B104,$84EB8EB8,$CC32ADD4
Data.l $5CB18547,$9D72A347,$3AED0570,$B9629C65,$5333478E,$5780AED ,$5DB40CB1,$3104A3C7,$8EBD075E,$AF1B654A
Data.l $558751E3,$105703AF,$195230CB,$5902EC21,$4761E3B0,$196132A4,$89123487,$B0C
EndDataSection
EndProcedure
Procedure.l myCallback(Hwnd.l, uMsg.l, wParam.l, lParam.l)
Select uMsg
Case #WM_ERASEBKGND
ProcedureReturn
Case #WM_PAINT ; Quand la fentre est déssinée ou redéssinée
; Deplacement de la croix rouge avec la fenetre
If IsWindow(#Croix)
ResizeWindow(#Croix, WindowX(#Window_Main) + DistanceCroixRougeX(1), WindowY(#Window_Main) + DistanceCroixRougeY(1), #PB_Ignore, #PB_Ignore)
SetActiveWindow(#Croix) ; C'EST LA QU'EST L'OS
EndIf
PaintDesktop_(BeginPaint_(Hwnd, ps.PAINTSTRUCT))
EndPaint_(Hwnd, ps)
Case #WM_SIZING,#WM_MOVING ; Quand la fenetre est bougée ou déformée
InvalidateRect_(Hwnd, 0, 1)
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
Bonne journée