#include <GUIConstants.au3>
Global Const $ILC_MASK = 0x0001
Global Const $ILC_COLOR32 = 0x0020
Global Const $BCM_FIRST = 0x1600
Global Const $BCM_SETIMAGELIST = $BCM_FIRST + 0x0002
Global Const $BUTTON_IMAGELIST_ALIGN_LEFT = 0
Global Const $BUTTON_IMAGELIST_ALIGN_RIGHT = 1
Global Const $BUTTON_IMAGELIST_ALIGN_TOP = 2
Global Const $BUTTON_IMAGELIST_ALIGN_BOTTOM = 3
Global Const $BUTTON_IMAGELIST_ALIGN_CENTER = 4 ; Doesn't draw text
$GUI = GUICreate("My GUI")
$ic1 = GUICtrlCreateIcon("shell32.dll", 14, 13, 13, 16, 16)
$ic2 = GUICtrlCreateLabel("Au3论坛", 40, 16, 48, 13)
$b = GUICtrlCreateButton("Au3论坛", 10, 10, 90, 25)
Button_AddIcon($b, "shell32.dll", 14, $BUTTON_IMAGELIST_ALIGN_LEFT)
GUICtrlSetState(-1,$GUI_HIDE)
GUISetState()
While 1
$m = GUIGetMsg()
If $m = -3 then Exit
$c = GUIGetCursorInfo($GUI)
If $c[4] = $ic1 or $c[4] = $ic2 Then
GUICtrlSetState( $b, $GUI_SHOW)
GUICtrlSetState( $ic1, $GUI_HIDE)
GUICtrlSetState( $ic2, $GUI_HIDE)
$c = GUIGetCursorInfo($GUI)
While $c[4] = $b
If GUIGetMsg() = $b Then Do_Function()
$c = GUIGetCursorInfo($GUI)
WEnd
GUICtrlSetState( $b, $GUI_HIDE)
GUICtrlSetState( $ic1, $GUI_SHOW)
GUICtrlSetState( $ic2, $GUI_SHOW)
EndIf
WEnd
Func Do_Function()
MsgBox(0x0, "", "如何?", 3)
EndFunc
Func Button_AddIcon($nID, $sIconFile, $nIconID, $nAlign)
Local $hIL = ImageList_Create(16, 16, BitOr($ILC_MASK, $ILC_COLOR32), 0, 1)
Local $stIcon = DllStructCreate("int")
ExtractIconEx($sIconFile, $nIconID, DllStructGetPtr($stIcon), 0, 1)
ImageList_AddIcon($hIL, DllStructGetData($stIcon, 1))
DestroyIcon(DllStructGetData($stIcon, 1))
Local $stBIL = DllStructCreate("dword;int[4];uint")
DllStructSetData($stBIL, 1, $hIL)
DllStructSetData($stBIL, 2, 1, 1)
DllStructSetData($stBIL, 2, 1, 2)
DllStructSetData($stBIL, 2, 1, 3)
DllStructSetData($stBIL, 2, 1, 4)
DllStructSetData($stBIL, 3, $nAlign)
GUICtrlSendMsg($nID, $BCM_SETIMAGELIST, 0, DllStructGetPtr($stBIL))
EndFunc
Func ImageList_Create($nImageWidth, $nImageHeight, $nFlags, $nInitial, $nGrow)
Local $hImageList = DllCall('comctl32.dll', 'hwnd', 'ImageList_Create', _
'int', $nImageWidth, _
'int', $nImageHeight, _
'int', $nFlags, _
'int', $nInitial, _
'int', $nGrow)
Return $hImageList[0]
EndFunc
Func ImageList_AddIcon($hIml, $hIcon)
Local $nIndex = DllCall('comctl32.dll', 'int', 'ImageList_AddIcon', _
'hwnd', $hIml, _
'hwnd', $hIcon)
Return $nIndex[0]
EndFunc
Func ExtractIconEx($sIconFile, $nIconID, $ptrIconLarge, $ptrIconSmall, $nIcons)
Local $nCount = DllCall('shell32.dll', 'int', 'ExtractIconEx', _
'str', $sIconFile, _
'int', $nIconID, _
'ptr', $ptrIconLarge, _
'ptr', $ptrIconSmall, _
'int', $nIcons)
Return $nCount[0]
EndFunc
Func DestroyIcon($hIcon)
Local $bResult = DllCall('user32.dll', 'int', 'DestroyIcon', _
'hwnd', $hIcon)
Return $bResult[0]
EndFunc
LZ 看下这个么``这个是`以前收集的了` |