Page 2 sur 2

Re: SetWindowsTransparency

Publié : ven. 14/avr./2017 11:11
par JohnJohnsonSHERMAN
Bien sûr, c'est exactement ce que je fais avec mon Sherman volant :)
Il n'est pas transparent, mais bien sur fond rouge, c'est ce fond qui est effacé en utilisant le paramétre #LWA_COLORKEY associé à une couleur, ici ce rouge... En fait ce n'est qu'une fenêtre sans bordure avec un Sherman sur fond rouge dedans. Il te suffit en fait de modifier la couleur de la fenêtre, puis de filtrer cette couleur avec #LWA_COLORKEY dans SetLayeredWindowAttribues_

Bref voici un petit exemple de ce que tu veux :

Code : Tout sélectionner

#GWL_EXSTYLE = -20
#GWL_STYLE = -16
#WS_EX_LAYERED = 524288
#LWA_ALPHA = 2
#LWA_COLORKEY = 1

Prototype.i Proto_SetWindowLong_(hWnd,nIndex.i, NewLong.l)
Prototype.b Proto_SetLayeredWindowAttributes_(hWnd,ColorKey,Alpha.b,Flags.w)

OpenLibrary(1,"user32.dll")
Global SetWindowLong_.Proto_SetWindowLong_ = GetFunction(1,"SetWindowLongW") ;on charge la fonction
Global SetLayeredWindowAttributes_.Proto_SetLayeredWindowAttributes_ = GetFunction(1,"SetLayeredWindowAttributes")
CloseLibrary(1)

Procedure SetWindowTransparency(Window, Alpha)
  SetWindowLong_(WindowID(Window),#GWL_EXSTYLE, #WS_EX_LAYERED)
  SetLayeredWindowAttributes_(WindowID(Window), RGB(0,255,0),Alpha, #LWA_COLORKEY) ;On définit ici un masque de couleur avec #LWA_COLORKEY et on précise la couleur
                                                                                   ;Comme seule #LWA_COLORKEY est précisé, la transparence Alpha ne sera pas prise en compte
EndProcedure


width = 600
height = 400

OpenWindow(1,0,0,width,height,"Exemple de fenêtre avec colorkey",#PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ButtonGadget(1,10,10,100,30,"Bouton")
CheckBoxGadget(2,10,50,100,20,"Case à cocher")
ComboBoxGadget(3,200,10,150,30)
ExplorerTreeGadget(4,20,200,200,150,"")
ListIconGadget(5,300,100,250,250,"Liste de rien",100)

SetWindowColor(1,RGB(0,255,0)) ;On modifie le fond de la fenêtre sur la couleur qui sera filtré, ici vert

SetWindowTransparency(1,220)

Repeat
  event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow



Re: SetWindowsTransparency

Publié : ven. 14/avr./2017 16:46
par venom
Cool merci SHERMAN






@++