貌似楼主认错人了吧,三恨前辈也是我仰慕的对象啊.
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIEx.au3>
#region ### START Koda GUI section ### Form=
$Form2 = GUICreate("窗体1", 413, 305, 302, 218)
$Label1 = GUICtrlCreateLabel("如何读取文字颜色和背景色?", 48, 88, 316, 33)
GUICtrlSetBkColor($Label1, 0xFF00FF)
GUICtrlSetColor($Label1, 0xFFFF00)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
$Button= GUICtrlCreateButton("Read BkColor",60,200)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$msg=GUIGetMsg()
Switch $msg
Case -3
Exit
Case $Button
MsgBox(0,"BkColor",__WinAPI_GetBkColor($Label1))
EndSwitch
WEnd
Func __WinAPI_GetBkColor($hWnd)
Local $aResult, $hDC, $Res
If Not IsHWnd($hWnd) Then $hWnd = ControlGetHandle("", "", $hWnd)
Local $hParent = _WinAPI_GetParent($hWnd)
$hDC = _WinAPI_GetDC($hWnd)
Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC)
_WinAPI_ReleaseDC($hWnd, $hDC)
Local $hBrush = _SendMessage($hParent, $WM_CTLCOLORSTATIC, $hMemDC, $hWnd)
Local $iMode = _WinAPI_GetBkMode($hMemDC)
$BGR = _WinAPI_GetBkColor($hMemDC)
$iRet = BitOR(BitShift(BitAND($BGR, 0x0000FF), -16), BitAND($BGR, 0x00FF00), BitShift(BitAND($BGR, 0xFF0000), 16))
_WinAPI_DeleteDC($hMemDC)
_WinAPI_ReleaseDC($hWnd, $hDC)
Return Hex($iRet,6)
EndFunc ;==>_WinAPI_GetBkColor
|