Jouer avec Aéro

Partagez votre expérience de PureBasic avec les autres utilisateurs.
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Jouer avec Aéro

Message par Le Soldat Inconnu »

Salut,

J'ouvre ce sujet pour discuter et proposer des codes pour jouer avec le thème Aéro sur Window 7 et Vista.

Actuellement, j'arrive à :
- retirer Aéro sur une fenêtre
- agrandir les bordures à l'intérieur de la fenêtre comme le fait l'explorateur Windows par exemple.

Je continue de fouiller pour trouver d'autre truc rigolo :mrgreen:

Poster les vôtres :D

Code à jour du 26/04/2011 à 20h51

Code : Tout sélectionner

Enumeration 1
	#DWMWA_NCRENDERING_ENABLED
	#DWMWA_NCRENDERING_POLICY
	#DWMWA_TRANSITIONS_FORCEDISABLED
	#DWMWA_ALLOW_NCPAINT
	#DWMWA_CAPTION_BUTTON_BOUNDS
	#DWMWA_NONCLIENT_RTL_LAYOUT
	#DWMWA_FORCE_ICONIC_REPRESENTATION
	#DWMWA_FLIP3D_POLICY
	#DWMWA_EXTENDED_FRAME_BOUNDS
	#DWMWA_HAS_ICONIC_BITMAP
	#DWMWA_DISALLOW_PEEK
	#DWMWA_EXCLUDED_FROM_PEEK
	#DWMWA_LAST
EndEnumeration
Enumeration
	#DWMNCRP_USEWINDOWSTYLE
	#DWMNCRP_DISABLED
	#DWMNCRP_ENABLED
	#DWMNCRP_LAST
EndEnumeration

Procedure DWM_DisableWindowRendering(hWnd.i, State.i)
	Protected Library
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		If State
			State = #DWMNCRP_DISABLED
		Else
			State = #DWMNCRP_ENABLED
		EndIf
		
		CallFunction(Library, "DwmSetWindowAttribute", hWnd, #DWMWA_NCRENDERING_POLICY, @State, SizeOf(Long))
		
		CloseLibrary(Library)
	EndIf
	
EndProcedure

Procedure DWM_WindowExtendFrame(hWnd.i, *Frame.RECT)
	Protected Frame.RECT, Library

	Frame\top = *Frame\right
	Frame\Bottom = *Frame\Bottom
	Frame\left = *Frame\left
	Frame\right = *Frame\top
	
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library

		CallFunction(Library, "DwmExtendFrameIntoClientArea", hWnd, @Frame)
		
		CloseLibrary(Library)
	EndIf
	
EndProcedure

Procedure DWM_GetColorizationColor()
	Protected Library, Color.l, Opaque.b
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		CallFunction(Library, "DwmGetColorizationColor", @Color, @Opaque)
		
		CloseLibrary(Library)
	EndIf
	
	ProcedureReturn Color
EndProcedure

OpenWindow(0, 0, 0, 256, 256, "DWM", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)

SetWindowColor(0, 0)

Aero = 0
Define Marge.RECT

ButtonGadget(0, 24, 24, 96, 24, "Aero")
ButtonGadget(1, 24, 24 * 2, 96, 24, "Bordure interne")
ButtonGadget(2, 24, 24 * 3, 96, 24, "Fond complet")

Couleur = DWM_GetColorizationColor()
TextGadget(3, 24, 24 * 4, 256 - 48, 32, "Couleur utilisée pour Aéro :" + Chr(10) + "RGBA(" + Str(Red(Couleur)) + ", "  + Str(Green(Couleur)) + ", "  + Str(Blue(Couleur)) + ", "  + Str(Alpha(Couleur)) + ")") 

Repeat
	Event = WaitWindowEvent()
	
	Select Event
		Case #PB_Event_Gadget
			Select EventGadget()
					
				Case 0
					Aero = 1 - Aero
					DWM_DisableWindowRendering(WindowID(0), Aero)
					
				Case 1
					If Marge\top = 0 And Marge\Bottom = 0 And Marge\left = 0 And Marge\right = 0
						Marge\top = 16
						Marge\Bottom = 24
						Marge\left = 8
						Marge\right = 4
					Else
						Marge\top = 0
						Marge\Bottom = 0
						Marge\left = 0
						Marge\right = 0
					EndIf
					DWM_WindowExtendFrame(WindowID(0), @Marge)
					
				Case 2
					If Marge\top >= 0 And Marge\Bottom >= 0 And Marge\left >= 0 And Marge\right >= 0
						Marge\top = -1
						Marge\Bottom = -1
						Marge\left = -1
						Marge\right = -1
					Else
						Marge\top = 0
						Marge\Bottom = 0
						Marge\left = 0
						Marge\right = 0
					EndIf
					DWM_WindowExtendFrame(WindowID(0), @Marge)
					
			EndSelect
	EndSelect
	
Until Event = #PB_Event_CloseWindow
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Jouer avec Aéro

Message par falsam »

J'ai testé et j'adopte :) Merci pour ce code.
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%
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Jouer avec Aéro

Message par Le Soldat Inconnu »

Par contre, j'ai pas encore compris comment dessiner sur la bordure étendu, quand on place un gadget, le noir prend la couleur du rendu aéro. du coup, c'est moche

Code : Tout sélectionner

Enumeration 1
	#DWMWA_NCRENDERING_ENABLED
	#DWMWA_NCRENDERING_POLICY
	#DWMWA_TRANSITIONS_FORCEDISABLED
	#DWMWA_ALLOW_NCPAINT
	#DWMWA_CAPTION_BUTTON_BOUNDS
	#DWMWA_NONCLIENT_RTL_LAYOUT
	#DWMWA_FORCE_ICONIC_REPRESENTATION
	#DWMWA_FLIP3D_POLICY
	#DWMWA_EXTENDED_FRAME_BOUNDS
	#DWMWA_HAS_ICONIC_BITMAP
	#DWMWA_DISALLOW_PEEK
	#DWMWA_EXCLUDED_FROM_PEEK
	#DWMWA_LAST
EndEnumeration
Enumeration
	#DWMNCRP_USEWINDOWSTYLE
	#DWMNCRP_DISABLED
	#DWMNCRP_ENABLED
	#DWMNCRP_LAST
EndEnumeration

Procedure DWM_DisableWindowRendering(hWnd.i, State.i)
	Protected Library
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		If State
			State = #DWMNCRP_DISABLED
		Else
			State = #DWMNCRP_ENABLED
		EndIf
		
		CallFunction(Library, "DwmSetWindowAttribute", hWnd, #DWMWA_NCRENDERING_POLICY, @State, SizeOf(Long))
		
		CloseLibrary(Library)
	EndIf
	
EndProcedure

Procedure DWM_WindowExtendFrame(hWnd.i, *Frame.RECT)
	Protected Frame.RECT, Library

	Frame\top = *Frame\right
	Frame\Bottom = *Frame\Bottom
	Frame\left = *Frame\left
	Frame\right = *Frame\top
	
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library

		CallFunction(Library, "DwmExtendFrameIntoClientArea", hWnd, @Frame)
		
		CloseLibrary(Library)
	EndIf
	
EndProcedure

Procedure DWM_GetColorizationColor()
	Protected Library, Color.l, Opaque.l
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		CallFunction(Library, "GetColorizationColor", hWnd, @Color, @Opaque)
		
		CloseLibrary(Library)
	EndIf
	
	ProcedureReturn Color
EndProcedure

OpenWindow(0, 0, 0, 256, 256, "DWM", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)

Couleur = DWM_GetColorizationColor()

SetWindowColor(0, Couleur)

Aero_Actif = 0
Define Marge.RECT
Marge_Active = 0

ButtonGadget(0, 24, 24, 96, 24, "Aero")
ButtonGadget(1, 24, 48, 96, 24, "Frame")

TextGadget(10, 0, 0, 256, 16, "Un petit texte pour tester", #PB_Text_Center)
; SetGadgetColor(10, #PB_Gadget_BackColor, Couleur)

Repeat
	Event = WaitWindowEvent()
	
	Select Event
		Case #PB_Event_Gadget
			Select EventGadget()
				Case 0
					Aero_Actif = 1 - Aero_Actif
					DWM_DisableWindowRendering(WindowID(0), Aero_Actif)
				Case 1
					Marge_Active = 1 - Marge_Active
					If Marge_Active
						Marge\top = 16
						Marge\Bottom = 8
						Marge\left = 4
						Marge\right = 24
					Else
						Marge\top = 0
						Marge\Bottom = 0
						Marge\left = 0
						Marge\right = 0
					EndIf
					DWM_WindowExtendFrame(WindowID(0), @Marge)
			EndSelect
	EndSelect
	
Until Event = #PB_Event_CloseWindow
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Jouer avec Aéro

Message par Le Soldat Inconnu »

On peut remplir l'ensemble de la fenêtre dans le style Aéro avec un paramètre -1 dans les marge
Par contre, mes gadgets deviennent très laid, il doit falloir activer qlqchose en plus mais je ne sais pas encore quoi :) je fouille

Code : Tout sélectionner

Enumeration 1
	#DWMWA_NCRENDERING_ENABLED
	#DWMWA_NCRENDERING_POLICY
	#DWMWA_TRANSITIONS_FORCEDISABLED
	#DWMWA_ALLOW_NCPAINT
	#DWMWA_CAPTION_BUTTON_BOUNDS
	#DWMWA_NONCLIENT_RTL_LAYOUT
	#DWMWA_FORCE_ICONIC_REPRESENTATION
	#DWMWA_FLIP3D_POLICY
	#DWMWA_EXTENDED_FRAME_BOUNDS
	#DWMWA_HAS_ICONIC_BITMAP
	#DWMWA_DISALLOW_PEEK
	#DWMWA_EXCLUDED_FROM_PEEK
	#DWMWA_LAST
EndEnumeration
Enumeration
	#DWMNCRP_USEWINDOWSTYLE
	#DWMNCRP_DISABLED
	#DWMNCRP_ENABLED
	#DWMNCRP_LAST
EndEnumeration

Procedure DWM_DisableWindowRendering(hWnd.i, State.i)
	Protected Library
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		If State
			State = #DWMNCRP_DISABLED
		Else
			State = #DWMNCRP_ENABLED
		EndIf
		
		CallFunction(Library, "DwmSetWindowAttribute", hWnd, #DWMWA_NCRENDERING_POLICY, @State, SizeOf(Long))
		
		CloseLibrary(Library)
	EndIf
	
EndProcedure

Procedure DWM_WindowExtendFrame(hWnd.i, *Frame.RECT)
	Protected Frame.RECT, Library

	Frame\top = *Frame\right
	Frame\Bottom = *Frame\Bottom
	Frame\left = *Frame\left
	Frame\right = *Frame\top
	
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library

		CallFunction(Library, "DwmExtendFrameIntoClientArea", hWnd, @Frame)
		
		CloseLibrary(Library)
	EndIf
	
EndProcedure

Procedure DWM_GetColorizationColor()
	Protected Library, Color.l, Opaque.l
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		CallFunction(Library, "GetColorizationColor", hWnd, @Color, @Opaque)
		
		CloseLibrary(Library)
	EndIf
	
	ProcedureReturn Color
EndProcedure

OpenWindow(0, 0, 0, 256, 256, "DWM", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)

Couleur = DWM_GetColorizationColor()

SetWindowColor(0, Couleur)

Aero_Actif = 0
Define Marge.RECT
Marge_Active = 0

ButtonGadget(0, 24, 24, 96, 24, "Aero")
ButtonGadget(1, 24, 48, 96, 24, "Frame")

Repeat
	Event = WaitWindowEvent()
	
	Select Event
		Case #PB_Event_Gadget
			Select EventGadget()
				Case 0
					Aero_Actif = 1 - Aero_Actif
					DWM_DisableWindowRendering(WindowID(0), Aero_Actif)
				Case 1
					Marge_Active = 1 - Marge_Active
					If Marge_Active
						Marge\top = -1
						Marge\Bottom = -1
						Marge\left = -1
						Marge\right = -1
					Else
						Marge\top = 0
						Marge\Bottom = 0
						Marge\left = 0
						Marge\right = 0
					EndIf
					DWM_WindowExtendFrame(WindowID(0), @Marge)
			EndSelect
	EndSelect
	
Until Event = #PB_Event_CloseWindow
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Re: Jouer avec Aéro

Message par nico »

Après multiples recherches, il semble que cela ne soit pas possible comme avec updatelayeredwindow, toutefois on peut rendre la fenêtre transparente avec un couleur et ça marche bien sauf que (bien sûr) lorsqu'on se trouve avec le curseur sur la fenêtre en dehors d'un gadget, on clique au travers ce qui est normal mais très embêtant.

Faudrait regarder de ce coté là, peut être qu'en rajoutant une fenêtre derrière transparente qui suit la première résoudrait en partie le problème.
nico
Messages : 3702
Inscription : ven. 13/févr./2004 0:57

Re: Jouer avec Aéro

Message par nico »

Voici un code fonctionnel, reste à savoir si ça fonctionne pour tout le monde car je trouve que la fonction SetLayeredWindowAttributes n'est pas très fiable.

N'hésiter pas à faire des retours!

Code : Tout sélectionner

Enumeration 1
  #DWMWA_NCRENDERING_ENABLED
  #DWMWA_NCRENDERING_POLICY
  #DWMWA_TRANSITIONS_FORCEDISABLED
  #DWMWA_ALLOW_NCPAINT
  #DWMWA_CAPTION_BUTTON_BOUNDS
  #DWMWA_NONCLIENT_RTL_LAYOUT
  #DWMWA_FORCE_ICONIC_REPRESENTATION
  #DWMWA_FLIP3D_POLICY
  #DWMWA_EXTENDED_FRAME_BOUNDS
  #DWMWA_HAS_ICONIC_BITMAP
  #DWMWA_DISALLOW_PEEK
  #DWMWA_EXCLUDED_FROM_PEEK
  #DWMWA_LAST
EndEnumeration
Enumeration
  #DWMNCRP_USEWINDOWSTYLE
  #DWMNCRP_DISABLED
  #DWMNCRP_ENABLED
  #DWMNCRP_LAST
EndEnumeration

Procedure DWM_DisableWindowRendering(hWnd.i, State.i)
  Protected Library
  Library = OpenLibrary(#PB_Any, "dwmapi.dll")
  If Library
    
    If State
      State = #DWMNCRP_DISABLED
    Else
      State = #DWMNCRP_ENABLED
    EndIf
    
    CallFunction(Library, "DwmSetWindowAttribute", hWnd, #DWMWA_NCRENDERING_POLICY, @State, SizeOf(Long))
    
    CloseLibrary(Library)
  EndIf
  
EndProcedure

Procedure DWM_WindowExtendFrame(hWnd.i, *Frame.RECT)
  Protected Frame.RECT, Library
  
  Frame\top = *Frame\right
  Frame\Bottom = *Frame\Bottom
  Frame\left = *Frame\left
  Frame\right = *Frame\top
  
  Library = OpenLibrary(#PB_Any, "dwmapi.dll")
  If Library
    
    CallFunction(Library, "DwmExtendFrameIntoClientArea", hWnd, @Frame)
    
    CloseLibrary(Library)
  EndIf
  
EndProcedure

Procedure DWM_GetColorizationColor()
  Protected Library, Color.l, Opaque.l
  Library = OpenLibrary(#PB_Any, "dwmapi.dll")
  If Library
    
    CallFunction(Library, "GetColorizationColor", hWnd, @Color, @Opaque)
    
    CloseLibrary(Library)
  EndIf
  
  ProcedureReturn Color
EndProcedure

If   OpenWindow(1, 0, 0, 256, 256, "", #PB_Window_BorderLess| #PB_Window_ScreenCentered|#PB_Window_Invisible)
  
  If OpenWindow(0, 0, 0, 256, 256, "DWM", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)
    SetParent_(WindowID(1),WindowID(0))
    SetActiveWindow(0)
    
    SetWindowColor(0, RGB(254,0,255))
    
    Aero_Actif = 0
    Define Marge.RECT
    Marge_Active = 0
    
    ButtonGadget(0, 24, 24, 96, 24, "Aero")
    ButtonGadget(1, 24, 48, 96, 24, "Frame")
    
    Repeat
      Event = WaitWindowEvent()
      
      Select Event
        Case #WM_LBUTTONDOWN
          SendMessage_(WindowID(0),#WM_NCLBUTTONDOWN,#HTCAPTION,0)
          
        Case #PB_Event_Gadget
          Select EventGadget()
            Case 0
              Aero_Actif = 1 - Aero_Actif
              DWM_DisableWindowRendering(WindowID(0), Aero_Actif)
            Case 1
              Marge_Active = 1 - Marge_Active
              If Marge_Active
                Marge\top = -1
                Marge\Bottom = -1
                Marge\left = -1
                Marge\right = -1
                SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE) | #WS_EX_LAYERED)
                SetLayeredWindowAttributes_(WindowID(0), RGB(254,0,255), 0, #LWA_COLORKEY)
              Else
                Marge\top = 0
                Marge\Bottom = 0
                Marge\left = 0
                Marge\right = 0
                SetWindowLong_(WindowID(0),#GWL_EXSTYLE,GetWindowLong_(WindowID(0),#GWL_EXSTYLE) & ~#WS_EX_LAYERED)
                
              EndIf
              DWM_WindowExtendFrame(WindowID(0), @Marge)
          EndSelect
      EndSelect
      
    Until Event = #PB_Event_CloseWindow
  EndIf 
EndIf  
boddhi
Messages : 604
Inscription : lun. 26/avr./2010 16:14
Localisation : S 48° 52' 31'' / O 123° 23' 33''

Re: Jouer avec Aéro

Message par boddhi »

Fonctionne correctement sous Vista 32b
Avatar de l’utilisateur
falsam
Messages : 7324
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Jouer avec Aéro

Message par falsam »

ça permet de faire des effets de style intéressants. Merci pour ce partage :)
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%
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Jouer avec Aéro

Message par Le Soldat Inconnu »

Cool :D
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Le Soldat Inconnu
Messages : 4312
Inscription : mer. 28/janv./2004 20:58
Localisation : Clermont ferrand OU Olsztyn
Contact :

Re: Jouer avec Aéro

Message par Le Soldat Inconnu »

J'ai complété ton astuce :D

Code : Tout sélectionner

Enumeration 1
	#DWMWA_NCRENDERING_ENABLED
	#DWMWA_NCRENDERING_POLICY
	#DWMWA_TRANSITIONS_FORCEDISABLED
	#DWMWA_ALLOW_NCPAINT
	#DWMWA_CAPTION_BUTTON_BOUNDS
	#DWMWA_NONCLIENT_RTL_LAYOUT
	#DWMWA_FORCE_ICONIC_REPRESENTATION
	#DWMWA_FLIP3D_POLICY
	#DWMWA_EXTENDED_FRAME_BOUNDS
	#DWMWA_HAS_ICONIC_BITMAP
	#DWMWA_DISALLOW_PEEK
	#DWMWA_EXCLUDED_FROM_PEEK
	#DWMWA_LAST
EndEnumeration
Enumeration
	#DWMNCRP_USEWINDOWSTYLE
	#DWMNCRP_DISABLED
	#DWMNCRP_ENABLED
	#DWMNCRP_LAST
EndEnumeration

Procedure DWM_DisableWindowRendering(hWnd.i, State.i)
	Protected Library
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		If State
			State = #DWMNCRP_DISABLED
		Else
			State = #DWMNCRP_ENABLED
		EndIf
		
		CallFunction(Library, "DwmSetWindowAttribute", hWnd, #DWMWA_NCRENDERING_POLICY, @State, SizeOf(Long))
		
		CloseLibrary(Library)
	EndIf
	
EndProcedure

Procedure DWM_WindowExtendFrame(hWnd.i, *Frame.RECT)
	Protected Frame.RECT, Library.i
	Static WindowBackColor.i, PreviousWindowBackColor.i, Container.RECT, Client.RECT
	
	OldGadgetList = UseGadgetList(hWnd)
	
	Frame\top = *Frame\right
	Frame\Bottom = *Frame\Bottom
	Frame\left = *Frame\left
	Frame\right = *Frame\top
	
	If WindowBackColor
		DeleteObject_(WindowBackColor)
		SetClassLongPtr_(hWnd, #GCL_HBRBACKGROUND, PreviousWindowBackColor)
		WindowBackColor = 0
	EndIf
	If Container\top And IsGadget(Container\top)
		FreeGadget(Container\top)
		Container\top = 0
	EndIf
	If Container\Bottom And IsGadget(Container\Bottom)
		FreeGadget(Container\Bottom)
		Container\Bottom = 0
	EndIf
	If Container\left And IsGadget(Container\left)
		FreeGadget(Container\left)
		Container\left = 0
	EndIf
	If Container\right And IsGadget(Container\right)
		FreeGadget(Container\right)
		Container\right = 0
	EndIf
	
	If Frame\left = 0 And Frame\right = 0 And Frame\top = 0 And Frame\Bottom = 0
		SetWindowLong_(hWnd, #GWL_EXSTYLE, GetWindowLong_(hWnd, #GWL_EXSTYLE) & ~#WS_EX_LAYERED)
	ElseIf Frame\left = -1 Or Frame\right = -1 Or Frame\top = -1 Or Frame\Bottom = -1
		PreviousWindowBackColor = GetClassLongPtr_(hWnd, #GCL_HBRBACKGROUND)
		WindowBackColor = CreateSolidBrush_($FE00FF)
		SetClassLongPtr_(hWnd, #GCL_HBRBACKGROUND, WindowBackColor)
		SetWindowLong_(hWnd, #GWL_EXSTYLE, GetWindowLong_(hWnd, #GWL_EXSTYLE) | #WS_EX_LAYERED)
		SetLayeredWindowAttributes_(hWnd, $FE00FF, 0, #LWA_COLORKEY)
	Else
		PreviousWindowBackColor = GetClassLongPtr_(hWnd, #GCL_HBRBACKGROUND)
		WindowBackColor = CreateSolidBrush_($FE00FF)
		GetClientRect_(hWnd, @Client.RECT)
		Hight = Client\Bottom - Client\top
		Width = Client\right - Client\left
		Container\left = ContainerGadget(#PB_Any, 0, 0, Frame\left, Hight, #PB_Container_BorderLess) : CloseGadgetList()
		SetClassLongPtr_(GadgetID(Container\left), #GCL_HBRBACKGROUND, WindowBackColor)
		Container\right = ContainerGadget(#PB_Any, Width - Frame\top, 0, Frame\top, Hight, #PB_Container_BorderLess) : CloseGadgetList()
		SetClassLongPtr_(GadgetID(Container\right), #GCL_HBRBACKGROUND, WindowBackColor)
		Container\top = ContainerGadget(#PB_Any, Frame\left, 0, Width - Frame\left - Frame\top, Frame\right, #PB_Container_BorderLess) : CloseGadgetList()
		SetClassLongPtr_(GadgetID(Container\left), #GCL_HBRBACKGROUND, WindowBackColor)
		Container\Bottom = ContainerGadget(#PB_Any, Frame\left, Hight - Frame\Bottom, Width - Frame\left - Frame\top, Frame\Bottom, #PB_Container_BorderLess) : CloseGadgetList()
		SetClassLongPtr_(GadgetID(Container\Bottom), #GCL_HBRBACKGROUND, WindowBackColor)
		SetWindowLong_(hWnd, #GWL_EXSTYLE, GetWindowLong_(hWnd, #GWL_EXSTYLE) | #WS_EX_LAYERED)
		SetLayeredWindowAttributes_(hWnd, $FE00FF, 0, #LWA_COLORKEY)
	EndIf
	
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		CallFunction(Library, "DwmExtendFrameIntoClientArea", hWnd, @Frame)
		
		CloseLibrary(Library)
	EndIf
	
	RedrawWindow_(hWnd, 0, 0, #RDW_ERASE | #RDW_INVALIDATE)
	UseGadgetList(OldGadgetList)
	
EndProcedure

Procedure DWM_GetColorizationColor()
	Protected Library, Color.l, Opaque.b
	Library = OpenLibrary(#PB_Any, "dwmapi.dll")
	If Library
		
		CallFunction(Library, "DwmGetColorizationColor", @Color, @Opaque)
		
		CloseLibrary(Library)
	EndIf
	
	ProcedureReturn Color
EndProcedure

OpenWindow(0, 0, 0, 256, 256, "DWM", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget | #PB_Window_SizeGadget)

Aero = 0
Define Marge.RECT

ButtonGadget(0, 24, 24, 96, 24, "Aero")
ButtonGadget(1, 24, 24 * 2, 96, 24, "Bordure interne")
ButtonGadget(2, 24, 24 * 3, 96, 24, "Fond complet")

Couleur = DWM_GetColorizationColor()
TextGadget(3, 24, 24 * 4, 256 - 48, 32, "Couleur utilisée pour Aéro :" + Chr(10) + "RGBA(" + Str(Red(Couleur)) + ", " + Str(Green(Couleur)) + ", " + Str(Blue(Couleur)) + ", " + Str(Alpha(Couleur)) + ")")

Repeat
	Event = WaitWindowEvent()
	
	Select Event
		Case #WM_LBUTTONDOWN
			SendMessage_(WindowID(0), #WM_NCLBUTTONDOWN, #HTCAPTION, 0)
			
		Case #PB_Event_Gadget
			Select EventGadget()
					
				Case 0
					Aero = 1 - Aero
					DWM_DisableWindowRendering(WindowID(0), Aero)
					
				Case 1
					If Marge\top = 0 And Marge\Bottom = 0 And Marge\left = 0 And Marge\right = 0
						Marge\top = 16
						Marge\Bottom = 24
						Marge\left = 8
						Marge\right = 4
					Else
						Marge\top = 0
						Marge\Bottom = 0
						Marge\left = 0
						Marge\right = 0
					EndIf
					DWM_WindowExtendFrame(WindowID(0), @Marge)
					
				Case 2
					If Marge\top >= 0 And Marge\Bottom >= 0 And Marge\left >= 0 And Marge\right >= 0
						Marge\top = -1
						Marge\Bottom = -1
						Marge\left = -1
						Marge\right = -1
					Else
						Marge\top = 0
						Marge\Bottom = 0
						Marge\left = 0
						Marge\right = 0
					EndIf
					DWM_WindowExtendFrame(WindowID(0), @Marge)
					
			EndSelect
	EndSelect
	
Until Event = #PB_Event_CloseWindow
Je ne suis pas à moitié Polonais mais ma moitié est polonaise ... Vous avez suivi ?

[Intel quad core Q9400 2.66mhz, ATI 4870, 4Go Ram, XP (x86) / 7 (x64)]
Répondre