Puisque je n'ai pas de machine Mac, j'ai besoin d'un volontaire pour tester le code ci-dessous pour voir si la commande fonctionne et surtout si elle retourne bien la valeur de la couleur du fond de la fenêtre.
Merci à l'avance.
Guimauve
Code : Tout sélectionner
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : GetWindowBackgroundColor()
; File Name : GetWindowBackgroundColor.pb
; File version: 0.0.4
; Programmation : In Progress
; Programmed by : Guimauve
; Date : 19-02-2012
; Last Update : 22-02-2012
; PureBasic code : 4.60
; Plateform : Windows, Linux, MacOS X
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
ImportC ""
gtk_style_lookup_color(*style, ColorName.p-utf8, *Color)
EndImport
CompilerEndSelect
Procedure GetWindowBackgroundColor()
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
BackgroundColor.l = GetSysColor_(#COLOR_3DFACE)
CompilerCase #PB_OS_Linux
BtnGadget = ButtonGadget(#PB_Any,0,0,0,0,"") ; Il faut créer un bouton bidon pour récupérer la couleur
If BtnGadget <> #Null
ColorNameAscii.s = Space(Len("bg_color"))
PokeS(@ColorNameAscii, "bg_color", -1, #PB_UTF8)
gtk_widget_realize_(GadgetID(BtnGadget))
*style.GtkStyle = gtk_rc_get_style_(GadgetID(BtnGadget))
If gtk_style_lookup_color(*style, ColorNameAscii, @BGColor.GDKColor)
Red = (BGColor\red / 255) & $FF
Green = (BGColor\green / 255) & $FF
Blue = (BGColor\blue / 255) & $FF
Else
Red = 238
Green = 237
Blue = 236
EndIf
FreeGadget(BtnGadget) ; On se débarasse du bouton bidon
EndIf
BackgroundColor.l = RGB(Red, Green, Blue)
CompilerCase #PB_OS_MacOS
BackgroundColor.l = $EBEBEB
CompilerEndSelect
ProcedureReturn BackgroundColor
EndProcedure
; <<<<<<<<<<<<<<<<<<<<<<<
; <<<<< END OF FILE <<<<<
; <<<<<<<<<<<<<<<<<<<<<<<