找回密码
 加入
搜索
查看: 3498|回复: 5

[GUI管理] 如何读取GUICtrlCreateLabel控件的文字颜色是背景色?[已解决]

  [复制链接]
发表于 2012-3-8 04:32:19 | 显示全部楼层 |阅读模式
本帖最后由 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 

Until  GUIGetMsg() = -3
已经试过3恨的方法了读不出来
http://www.autoitx.com/forum.php ... F%D8%BC%FE%2B%B1%B3

评分

参与人数 2金钱 +50 收起 理由
anythinging + 30
afan + 20 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2012-3-8 11:58:04 | 显示全部楼层
貌似楼主认错人了吧,三恨前辈也是我仰慕的对象啊.
#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

评分

参与人数 3金钱 +50 贡献 +5 收起 理由
502762378 + 25 附上学费
wua0550 + 5 谢谢
afan + 25

查看全部评分

 楼主| 发表于 2012-3-8 16:16:42 | 显示全部楼层
回复 2# 3mile

谢谢,附上我认错人的歉意   。
发表于 2014-12-16 16:43:56 | 显示全部楼层
dddddddddddddddddddddddddddddddddddddddddddd
发表于 2015-10-22 17:08:16 | 显示全部楼层
很好,有参考价值
发表于 2017-3-31 12:40:10 | 显示全部楼层
效果不错,支持一下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-19 17:37 , Processed in 0.084402 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表