本帖最后由 xxoojoeooxx 于 2011-2-10 03:10 编辑
有点乱
将就用一下巴
#Include <WinAPI.au3>
#Include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Global $ButtunCount=10 ;按钮数量
Global $P[$ButtunCount+1][8]
Local $Pi[$ButtunCount]
GUIRegisterMsg($WM_PAINT, "MY_WM_PAINT")
_GDIPlus_StartUp ()
$hImage = _GDIPlus_ImageLoadFromFile ("001.png")
$hImage1 = _GDIPlus_ImageLoadFromFile ("002.png")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 450, 450)
;GUICtrlCreatePicB(文本,文本左侧,文本顶部,接下来就是GUICtrlCreatePic原来的参数
$Pi[0] = GUICtrlCreatePicB("1",5,5,"", 16, 24, 180, 36,$WS_CLIPSIBLINGS)
$Pi[1] = GUICtrlCreatePicB("2",5,5,"", 243, 24, 180, 36,$WS_CLIPSIBLINGS)
$Pi[2] = GUICtrlCreatePicB("3",5,5,"", 16, 82, 180, 36,$WS_CLIPSIBLINGS)
$Pi[3] = GUICtrlCreatePicB("4",5,5,"", 243, 82, 180, 36,$WS_CLIPSIBLINGS)
$Pi[4] = GUICtrlCreatePicB("5",5,5,"", 16, 140, 180, 36,$WS_CLIPSIBLINGS)
$Pi[5] = GUICtrlCreatePicB("6",5,5,"", 243, 140, 180, 36,$WS_CLIPSIBLINGS)
$Pi[6] = GUICtrlCreatePicB("7",5,5,"", 16, 198, 180, 36,$WS_CLIPSIBLINGS)
$Pi[7] = GUICtrlCreatePicB("8",5,5,"", 243, 198, 180, 36,$WS_CLIPSIBLINGS)
$Pi[8] = GUICtrlCreatePicB("9",5,5,"", 16, 256, 180, 36,$WS_CLIPSIBLINGS)
$Pi[9] = GUICtrlCreatePicB("0",5,5,"", 243, 256, 180, 36,$WS_CLIPSIBLINGS)
$Pic = _GDIPlus_GraphicsCreateFromHWND ($Form1)
_WinAPI_InvalidateRect(WinGetHandle($Form1))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
$Pos = GUIGetCursorInfo($Form1)
For $i=1 To $P[0][0] ;$P[0][0] 为GUICtrlCreatePicB建立按钮的数量 $i为按钮编号
If $Pos[4] = $Pi[$i-1] And $P[$i][4] = 0 Then
;If $Pos[2]=1 Then
;Else
_GDIPLus_GraphicsDrawImageRect($Pic, $hImage1, $P[$i][0], $P[$i][1], $P[$i][2], $P[$i][3])
_GDIPlus_GraphicsDrawString($Pic,$P[$i][5],$P[$i][0]+$P[$i][6], $P[$i][1]+$P[$i][7])
$P[$i][4] = 1
;Endif
ElseIf $Pos[4] <> $Pi[$i-1] And $P[$i][4]= 1 Then
_GDIPLus_GraphicsDrawImageRect($Pic, $hImage,$P[$i][0], $P[$i][1], $P[$i][2], $P[$i][3])
_GDIPlus_GraphicsDrawString($Pic,$P[$i][5],$P[$i][0]+$P[$i][6], $P[$i][1]+$P[$i][7])
$P[$i][4] = 0
EndIf
Next
WEnd
_GDIPlus_GraphicsDispose ($Pic)
_GDIPlus_ImageDispose ($hImage)
_GDIPlus_ImageDispose ($hImage1)
_GDIPlus_ShutDown ()
Func MY_WM_PAINT($hWnd, $msg, $wParam, $lParam)
_WinAPI_RedrawWindow($Form1, 0, 0, $RDW_UPDATENOW)
For $i=1 To $P[0][0]
_GDIPLus_GraphicsDrawImageRect($Pic, $hImage, $P[$i][0], $P[$i][1], $P[$i][2], $P[$i][3])
_GDIPlus_GraphicsDrawString($Pic,$P[$i][5],$P[$i][0]+$P[$i][6], $P[$i][1]+$P[$i][7])
Next
_WinAPI_RedrawWindow($Form1, 0, 0, $RDW_VALIDATE)
Return $GUI_RUNDEFMSG
EndFunc ;==>MY_WM_PAINT
Func GUICtrlCreatePicB($txt,$tx,$ty,$pic,$x,$y,$w=-1,$h=-1,$sy=-1,$ex=-1)
$P[0][0]+=1 ;按钮数量
$P[$P[0][0]][0]=$x ;左侧
$P[$P[0][0]][1]=$y ;顶部
$P[$P[0][0]][2]=$w ;宽度
$P[$P[0][0]][3]=$h ;高度
$P[$P[0][0]][4]=0 ;Hover
$P[$P[0][0]][5]=$txt ;文本
$P[$P[0][0]][6]=$tx ;文本左侧
$P[$P[0][0]][7]=$ty ;文本顶部
Return GUICtrlCreatePic($pic,$x,$y,$w,$h,$sy,$ex)
EndFunc
|