Le 1er c'était juste pour que Dayvid constate qu'un fond transparent sur un ScrollAreaGadget est possible à condition de connaitre les
API Windows ainsi que les callbacks, et en la matière je suis plutôt novice.
Un ScrollAreaGadget avec un fond invisible n'est pas possible, pour le moment, en
natif avec Pure Basic.
La 2eme fenetre que tu as vu n'est qu'un container ou wrapper qui contient ton ScrollAreaGadget et sur lequel on va utiliser les fonctionnalités des API.
Essaye le code suivant et je pense qu'il répondra à tes attentes. (Windows Of Course:)
Code : Tout sélectionner
Enumeration
#Mainform
#MainWrapper
EndEnumeration
Procedure WndProc(hwnd, uMsg, wParam, lParam)
Protected X, Y, Width, Height
GetWindowRect_(WindowID(#MainForm), r.RECT)
result = #PB_ProcessPureBasicEvents
Select uMsg
Case #WM_SIZE,#WM_MOVE,#WM_PAINT
MoveWindow_(WindowID(#MainWrapper), r\left+20, r\top+100, 500, 300,1)
EndSelect
ProcedureReturn Result
EndProcedure
;Création du background de #MainForm
CreateImage(0, 800, 600)
StartDrawing(ImageOutput(0))
DrawingMode(#PB_2DDrawing_Gradient)
LinearGradient(0, 0, 800, 600)
GradientColor(0.00, $03FEFC)
GradientColor(0.25, $83FD7C)
GradientColor(1.00, $0803F7)
Box(0,0,800,600)
StopDrawing()
hBrush = CreatePatternBrush_(ImageID(0))
;Fenetre principale
hwnd = OpenWindow(#Mainform, 0, 0, 800, 600, "ScrollAreaGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetClassLongPtr_(WindowID(#Mainform), #GCL_HBRBACKGROUND, hBrush)
InvalidateRect_(WindowID(#Mainform), 0, 1)
;ScrollArea dans son wrapper
OpenWindow(#MainWrapper, 20, 100, 500, 300, "", #WS_POPUP, WindowID(#Mainform))
ScrollAreaGadget(0, 0, 0, 500, 300, 700, 400)
SetGadgetColor(0,#PB_Gadget_BackColor ,#White)
;SetWindowLongPtr_ : Modifie un attribut de la fenêtre spécifiée.
;GetWindowLongPtr_ : Récupère des informations à propos de la fenêtre spécifiée
SetWindowLongPtr_(WindowID(#MainWrapper),#GWL_EXSTYLE,GetWindowLongPtr_(WindowID(#MainWrapper),#GWL_EXSTYLE)|#WS_EX_LAYERED)
;SetLayeredWindowAttributes : Définit l'opacité et/ou la transparence
SetLayeredWindowAttributes_(WindowID(#MainWrapper),#White, 0, #LWA_COLORKEY)
TextGadget(11, 20, 30, 100, 30, "TextGadget")
SetGadgetColor(11,#PB_Gadget_BackColor ,#White)
ButtonGadget (12, 380, 50, 80, 30,"Test Button")
StringGadget(12, 20, 50, 200, 22,"Essai")
CloseGadgetList()
;SetWindowCallback(@WndProc(), #MainWrapper)
SetWindowCallback(@WndProc(), #Mainform)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
Tu remarqueras que les api sont exécutés uniquement sur le wrapper de la fenetre qui contient ton ScrollArrea et les gagets inclus dans cet area.
Le principe est de mettre de rendre transparents les fenetres et les gadgets colorés avec du blanc.
-Le wrapper (#MainWrapper) est coloré en blanc, le fond du gadget Textgadget est coloré en blanc etc ....
Attention ça ne fonctionne pas avec tous les gadgets.
Mais comme je l'ai dit, je ne suis pas un expert en API
J'ai corrigé GetWindowRect_(WindowID(0), r.RECT) en le remplaçant par GetWindowRect_(WindowID(#MainForm), r.RECT)