Tab 里面的 Graphic 背景色确实不能这么set
改用Label,2个问题一并解决如下#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Dim $CLA = 0, $CLA2 = 1, $color[2] = [0x9CD560, 0xFFFFFF]
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 320, 280, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
$Tab1 = GUICtrlCreateTab(8, 16, 289, 193)
$TabSheet1 = GUICtrlCreateTabItem("TabSheet1")
$Graphic = GUICtrlCreateLabel('悬停', 110, 120, 100, 30, 0x201 + 0x00800000)
$TabSheet2 = GUICtrlCreateTabItem("TabSheet2")
$TabSheet3 = GUICtrlCreateTabItem("TabSheet3")
$TabSheet4 = GUICtrlCreateTabItem("TabSheet4")
GUICtrlCreateTabItem("")
$Graphic2 = GUICtrlCreateLabel('点击', 110, 230, 100, 30, 0x201 + 0x00800000)
GUICtrlSetOnEvent(-1, "_click")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
GetPos()
Sleep(100)
WEnd
Func Form1Close()
Exit
EndFunc ;==>Form1Close
Func GetPos()
Local $a = GUIGetCursorInfo($Form1)
If $a[4] = $Graphic And $CLA = 0 Then
GUICtrlSetBkColor($Graphic, 0x9CD560)
$CLA = 1
ElseIf $a[4] <> $Graphic And $CLA = 1 Then
GUICtrlSetBkColor($Graphic, 0xFFFFFF)
$CLA = 0
EndIf
EndFunc ;==>GetPos
Func _click()
$CLA2 = Abs($CLA2 - 1)
GUICtrlSetBkColor($Graphic2, $color[$CLA2])
EndFunc ;==>_click
|