Je vois. C'est pas très compliqué à réaliser. J'utilise beaucoup la technique de SubClassing. C'est extrêmement intéressant car il intercepte TOUS les messages d'un contrôle (pas seulement ceux de l'UDF que tu utilises). À court/moyen terme, tu vas constater à quel point c'est facile à mettre en place et très puissant. Mais comme toute chose, il y a une petite courbe d'apprentissage. Voici ce que ça donne dans ton cas :
Code : Tout sélectionner
#include <WinAPIShellEx.au3>
#include <WinAPISys.au3>
#include <GUIConstants.au3>
Global $hProc = DllCallbackRegister(SubClassProc, 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr')
Global $hGUI = GUICreate("Titre", 280, 170)
Global $bt1 = GUICtrlCreateLabel("BOUTON 1", 10, 20, 260, 55, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetCursor(-1, 0)
GUICtrlSetBkColor(-1, 0x4BA9DF)
_WinAPI_SetWindowSubclass(GUICtrlGetHandle($bt1), DllCallbackGetPtr($hProc), $bt1)
Global $bt2Cadre = GUICtrlCreateLabel("", 10, 90, 260, 55)
GUICtrlSetBkColor(-1, 0x4BA9DF)
GUICtrlSetCursor(-1, 0)
_WinAPI_SetWindowSubclass(GUICtrlGetHandle($bt2Cadre), DllCallbackGetPtr($hProc), $bt2Cadre)
Global $bt2 = GUICtrlCreateLabel("BOUTON 2", 15, 95, 250, 45, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0x4BA9DF)
GUISetState()
Global $idDummy = GUICtrlCreateDummy()
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $idDummy
If GUICtrlRead($idDummy) = 2 Then ExitLoop
SplashTextOn("test", "Affichage du texte", 460, 50)
Sleep(5000)
SplashOff()
EndSwitch
WEnd
_WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($bt1), DllCallbackGetPtr($hProc), $bt1)
_WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($bt2Cadre), DllCallbackGetPtr($hProc), $bt2Cadre)
DllCallbackFree($hProc)
Func SubClassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $iData)
Local Static $bHover = False
Switch $iMsg
Case $WM_MOUSEMOVE
If Not $bHover Then
_WinAPI_TrackMouseEvent($hWnd, $TME_LEAVE, 5)
GUICtrlSetBkColor($iID, $iID = $bt1 ? 0xB4D1E2 : 0x315CA2)
$bHover = True
EndIf
Case $WM_MOUSELEAVE
GUICtrlSetBkColor($iID, 0x4BA9DF)
$bHover = False
Case $WM_LBUTTONUP
GUICtrlSendToDummy($idDummy, $iID = $bt1 ? 1 : 2)
EndSwitch
Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam)
EndFunc ;==>SubClassProc
Par ailleurs, si ça peut t'intéresser, j'ai mis en place un UDF pour composer des GUIs avec des coins ronds.
Voir ici.