如何读取GUICtrlCreateLabel控件的文字颜色是背景色?[已解决]
本帖最后由 wua0550 于 2012-3-8 16:17 编辑#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form2 = GUICreate("窗体1", 413, 305, 302, 218)
$Label1 = GUICtrlCreateLabel("如何读取文字颜色和背景色?", 48, 88, 316, 33)
GUICtrlSetBkColor($Label1, 0xFFFFFF)
GUICtrlSetColor($Label1, 0xFFFF00)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
Do
UntilGUIGetMsg() = -3
已经试过3恨的方法了读不出来
http://www.autoitx.com/forum.php?mod=viewthread&tid=17419&highlight=%BF%D8%BC%FE%2B%B1%B3 貌似楼主认错人了吧,三恨前辈也是我仰慕的对象啊.
#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 回复 2# 3mile
谢谢,附上我认错人的歉意 。 dddddddddddddddddddddddddddddddddddddddddddd 很好,有参考价值 效果不错,支持一下
页:
[1]