Bouton avec image, texte et couleurs
Posté : mar. 14 nov. 2017 17:39
Bonjour.
Je m'appel Vincent, pas vraiment nouveau sur ce forum, mais Cashquy est un compte pour le boulot
J'espère que le titre sera assez claire.
Je souhaite faire un bouton avec une image à gauche, un texte, puis avoir une couleur de fond et une couleur de texte...
J'ai un début de script, mais pas fonctionnel dès qu'il y a la couleur.
Merci de votre retour.
Je m'appel Vincent, pas vraiment nouveau sur ce forum, mais Cashquy est un compte pour le boulot
J'espère que le titre sera assez claire.
Je souhaite faire un bouton avec une image à gauche, un texte, puis avoir une couleur de fond et une couleur de texte...
J'ai un début de script, mais pas fonctionnel dès qu'il y a la couleur.
#include <GUIConstantsEx.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
$couleurwhite = 0xffffff
$couleurgreen = 0x75b83c
$hGUI = GUICreate("Test", 150, 280)
;multi state image Bitmap
$cButton_1 = GUICtrlCreateButton("Changer", 30, 30, 90, 32)
GUICtrlSetTip(-1, "Multi state bitmap imagelist")
$hImageBtn_1 = _GUIImageList_Create(24, 24, 5, 5)
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 27, True) ;1 - Normal
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 77, True) ;2 - Hot (ie cursor over)
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 144, True) ;3 - Pressed
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 109, True) ;4 - Disabled
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 130, True) ;5 - Focus button (switches between 5 & 6 in Vista)
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 154, True) ;6 - Stylus Hot (tablet computers only)
_GUICtrlButton_SetImageList($cButton_1, $hImageBtn_1)
;GUICtrlSetBkColor(-1, $couleurwhite)
;GUICtrlSetColor(-1, $couleurgreen)
;GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
;single state image Bitmap
$cButton_2 = GUICtrlCreateButton("Disable", 30, 70, 90, 32)
GUICtrlSetTip(-1, "Single bitmap imagelist")
$hImageBtn_2 = _GUIImageList_Create(24, 24, 5, 1)
_GUIImageList_AddIcon($hImageBtn_2, "shell32.dll", 131, True)
_GUICtrlButton_SetImageList($cButton_2, $hImageBtn_2)
GUICtrlSetBkColor(-1, $couleurwhite)
GUICtrlSetColor(-1, $couleurgreen)
GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
;single state image Icon
$cButton_3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40)
GUICtrlSetTip(-1, "Single icon imagelist")
$hImageBtn_3 = _GUIImageList_Create(32, 32, 5, 2)
_GUIImageList_AddIcon($hImageBtn_3, "shell32.dll", 47, False)
_GUICtrlButton_SetImageList($cButton_3, $hImageBtn_3)
;GUICtrlSetBkColor(-1, $couleurwhite)
GUICtrlSetColor(-1, $couleurgreen)
;GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
;single state image Bitmap with overlay text
$cButton_4 = GUICtrlCreateButton("Help", 30, 160, 90, 90)
GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text")
GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS")
$hImageBtn_4 = _GUIImageList_Create(80, 80, 5, 4)
_GUIImageList_AddIcon($hImageBtn_4, "shell32.dll", 116, True)
_GUICtrlButton_SetImageList($cButton_4, $hImageBtn_4, 4)
GUICtrlSetBkColor(-1, $couleurwhite)
;GUICtrlSetColor(-1, $couleurgreen)
;GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
GUISetState()
While 1
$sMsg = GUIGetMsg()
Switch $sMsg
Case $GUI_EVENT_CLOSE
Exit
Case $cButton_2
GUICtrlSetState($cButton_1, $GUI_DISABLE)
Case $cButton_3
GUICtrlSetState($cButton_1, $GUI_ENABLE)
EndSwitch
WEnd
#include <GuiButton.au3>
#include <GuiImageList.au3>
$couleurwhite = 0xffffff
$couleurgreen = 0x75b83c
$hGUI = GUICreate("Test", 150, 280)
;multi state image Bitmap
$cButton_1 = GUICtrlCreateButton("Changer", 30, 30, 90, 32)
GUICtrlSetTip(-1, "Multi state bitmap imagelist")
$hImageBtn_1 = _GUIImageList_Create(24, 24, 5, 5)
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 27, True) ;1 - Normal
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 77, True) ;2 - Hot (ie cursor over)
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 144, True) ;3 - Pressed
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 109, True) ;4 - Disabled
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 130, True) ;5 - Focus button (switches between 5 & 6 in Vista)
_GUIImageList_AddIcon($hImageBtn_1, "shell32.dll", 154, True) ;6 - Stylus Hot (tablet computers only)
_GUICtrlButton_SetImageList($cButton_1, $hImageBtn_1)
;GUICtrlSetBkColor(-1, $couleurwhite)
;GUICtrlSetColor(-1, $couleurgreen)
;GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
;single state image Bitmap
$cButton_2 = GUICtrlCreateButton("Disable", 30, 70, 90, 32)
GUICtrlSetTip(-1, "Single bitmap imagelist")
$hImageBtn_2 = _GUIImageList_Create(24, 24, 5, 1)
_GUIImageList_AddIcon($hImageBtn_2, "shell32.dll", 131, True)
_GUICtrlButton_SetImageList($cButton_2, $hImageBtn_2)
GUICtrlSetBkColor(-1, $couleurwhite)
GUICtrlSetColor(-1, $couleurgreen)
GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
;single state image Icon
$cButton_3 = GUICtrlCreateButton("Unlock", 30, 110, 90, 40)
GUICtrlSetTip(-1, "Single icon imagelist")
$hImageBtn_3 = _GUIImageList_Create(32, 32, 5, 2)
_GUIImageList_AddIcon($hImageBtn_3, "shell32.dll", 47, False)
_GUICtrlButton_SetImageList($cButton_3, $hImageBtn_3)
;GUICtrlSetBkColor(-1, $couleurwhite)
GUICtrlSetColor(-1, $couleurgreen)
;GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
;single state image Bitmap with overlay text
$cButton_4 = GUICtrlCreateButton("Help", 30, 160, 90, 90)
GUICtrlSetTip(-1, "Single bitmap imagelist with overlayed text")
GUICtrlSetFont(-1, 14, 800, -1, "Comic Sans MS")
$hImageBtn_4 = _GUIImageList_Create(80, 80, 5, 4)
_GUIImageList_AddIcon($hImageBtn_4, "shell32.dll", 116, True)
_GUICtrlButton_SetImageList($cButton_4, $hImageBtn_4, 4)
GUICtrlSetBkColor(-1, $couleurwhite)
;GUICtrlSetColor(-1, $couleurgreen)
;GUICtrlSetFont(-1, 16, 400)
GUICtrlSetCursor(-1, 0)
GUISetState()
While 1
$sMsg = GUIGetMsg()
Switch $sMsg
Case $GUI_EVENT_CLOSE
Exit
Case $cButton_2
GUICtrlSetState($cButton_1, $GUI_DISABLE)
Case $cButton_3
GUICtrlSetState($cButton_1, $GUI_ENABLE)
EndSwitch
WEnd