找回密码
 加入
搜索
查看: 3103|回复: 13

[AU3基础] Label鼠标效应问题

  [复制链接]
发表于 2014-6-13 12:01:09 | 显示全部楼层 |阅读模式
想鼠标经过Label的时候,Label控件有反应,像Labe2-11一样。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2014-6-13 12:55:20 | 显示全部楼层
像Labe2-11一样处理每个Lable
 楼主| 发表于 2014-6-13 13:07:30 | 显示全部楼层
回复 2# seniors
没有简洁的写法吗
发表于 2014-6-13 13:15:19 | 显示全部楼层
2楼的意思就是你代码!重复调用就行了!你效应这么写就这么调用!
发表于 2014-6-13 13:57:44 | 显示全部楼层
本帖最后由 水木子 于 2014-6-13 14:01 编辑

回复 1# qsy666888
这是我很久以前写的东东,不知道是不是你要的效果。
源码我就不贴上来了,论坛上有,你直接搜索下。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2014-6-13 14:05:11 | 显示全部楼层
回复 4# f4李文杨
重复调用没有写出来
发表于 2014-6-13 14:06:50 | 显示全部楼层
1、一般多个相同处理可以做成一个函数
2、或者控件子类化
3、自制控件
发表于 2014-6-13 14:13:25 | 显示全部楼层
回复 6# qsy666888

#include <Array.au3>

Global $aTest[5]
Global $hWndb
Global $bTfa = True, $bTfb = True

$MyGui = GUICreate('www.AutoItx.com', 400, 300)
$aTest[0] = GUICtrlCreateLabel('www.AutoItx.com', 50, 30, 100, 17)
$aTest[1] = GUICtrlCreateLabel('www.AutoItx.com', 50, 80, 100, 17)
$aTest[2] = GUICtrlCreateLabel('www.AutoItx.com', 50, 130, 100, 17)
$aTest[3] = GUICtrlCreateLabel('www.AutoItx.com', 50, 180, 100, 17)
$aTest[4] = GUICtrlCreateLabel('www.AutoItx.com', 50, 230, 100, 17)
GUISetState()

While 1
        $Pos = GUIGetCursorInfo($MyGui)
        If Not @error Then _Hyperlink($Pos[4])
        
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit

        EndSwitch
WEnd

Func _Hyperlink($hWnda)
        If _ArraySearch($aTest, $hWnda) <> -1 Then
                If $bTfb = True Then
                        GUICtrlSetFont($hWnda, 9, 400, 4)
                        GUICtrlSetColor($hWnda, 0x0080CC)
                        $hWndb = $hWnda
                        $bTfb = False
                        $bTfa = False
                EndIf
        Else
                If $bTfa = False Then
                        GUICtrlSetFont($hWndb, 9)
                        GUICtrlSetColor($hWndb, 0x000000)
                        $bTfa = True
                        $bTfb = True
                EndIf
        EndIf
EndFunc   ;==>_Hyperlink
 楼主| 发表于 2014-6-13 14:13:49 | 显示全部楼层
回复 7# seniors
才开始学,太深奥了,没有这方面的例子
 楼主| 发表于 2014-6-13 14:24:00 | 显示全部楼层
回复 8# 水木子
不知说什么好,就送你五个字吧,你太强悍了。
发表于 2014-6-13 14:38:40 | 显示全部楼层
回复 10# qsy666888

呵呵!还以为被无视了呢!是你要的就好。
发表于 2014-6-13 20:05:50 | 显示全部楼层
回复 8# 水木子
你这段代码,当二个超链接有重合的话,会不变色,我修改成这样了

#include <Array.au3>

Global $aTest[5]
Global $hWndb
Global $bTfa = True, $bTfb = True

$MyGui = GUICreate('www.AutoItx.com', 400, 300)
$aTest[0] = GUICtrlCreateLabel('www.AutoItx.com', 50, 30, 100, 17)
$aTest[1] = GUICtrlCreateLabel('www.AutoItx.com', 80, 40, 100, 17)
$aTest[2] = GUICtrlCreateLabel('www.AutoItx.com', 50, 130, 100, 17)
$aTest[3] = GUICtrlCreateLabel('www.AutoItx.com', 50, 180, 100, 17)
$aTest[4] = GUICtrlCreateLabel('www.AutoItx.com', 50, 230, 100, 17)
GUISetState()

While 1
        $Pos = GUIGetCursorInfo($MyGui)
        If Not @error Then _Hyperlink($Pos[4])

        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit

        EndSwitch
WEnd

Func _Hyperlink($hWnda)
        If _ArraySearch($aTest, $hWnda) <> -1 Then
                If $hWndb <> $hWnda Then
                        GUICtrlSetFont($hWndb, 9)
                        GUICtrlSetColor($hWndb, 0x000000)
                        GUICtrlSetFont($hWnda, 9, 400, 4)
                        GUICtrlSetColor($hWnda, 0x0080CC)
                        $hWndb = $hWnda
                        $bTfa = False
                EndIf
        Else
                If $bTfa = False Then
                        GUICtrlSetFont($hWndb, 9)
                        GUICtrlSetColor($hWndb, 0x000000)
                        $hWndb = 0
                        $bTfa = True
                EndIf
        EndIf
EndFunc   ;==>_Hyperlink
 楼主| 发表于 2014-6-13 22:34:13 | 显示全部楼层
回复 12# seniors
厉害
发表于 2014-6-14 08:50:11 | 显示全部楼层
各种大神们好,路过,那个分,看看强悍的东西
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-7-8 10:50 , Processed in 0.075482 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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