找回密码
 加入
搜索
查看: 2422|回复: 4

[AU3基础] 【已解决】怎么使鼠标移动到标签控件时改变标签控件的样式

[复制链接]
发表于 2012-9-19 21:22:46 | 显示全部楼层 |阅读模式
本帖最后由 虎虎虎 于 2012-9-20 21:54 编辑

怎么使鼠标移动到标签控件时改变标签控件的样式

比如到鼠标移动到标签控件时字体变色并显示下划线,类似于超链接的效果,应该怎么实现?

如图效果:

本帖子中包含更多资源

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

×
发表于 2012-9-19 22:51:42 | 显示全部楼层
_WinAPI_GetCursorInfo
_WinAPI_LoadCursor
_WinAPI_SetCursor
这三个UDF可能可以帮助你实现你要的功能,你去看看他们的例子。
发表于 2012-9-20 08:48:35 | 显示全部楼层
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include 'GUICtrlSetOnHover_UDF.au3'
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 307, 194)
$Label1 = GUICtrlCreateLabel("测试文本", 100, 60, 80, 20)
GUICtrlSetOnHover(-1, "_hover", "Leave_Hover_Func")
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $Label1
                        MsgBox(0, "test", "你点击了测试文本。")
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd

Func _hover($ctrlid)
        If $ctrlid = $Label1 Then
                GUICtrlSetCursor($Label1, 0)
                GUICtrlSetColor($Label1, 0x0000ff)
                GUICtrlSetFont($Label1, 15, Default, 6)
        EndIf

EndFunc   ;==>_hover

Func Leave_Hover_Func($ctrlid)
        If $ctrlid = $Label1 Then
                GUICtrlSetColor($Label1, 0x000000)
                GUICtrlSetFont($Label1, 11)
        EndIf
EndFunc   ;==>Leave_Hover_Func
'GUICtrlSetOnHover_UDF.au3'见附件

本帖子中包含更多资源

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

×

评分

参与人数 2金钱 +20 收起 理由
xiehuahere + 10 不错,收了
xyhqqaa + 10 谢谢分享。。。2003系统显示没效果

查看全部评分

 楼主| 发表于 2012-9-20 21:38:58 | 显示全部楼层
谢谢楼上,感觉不是太完美。
发表于 2012-9-21 17:23:53 | 显示全部楼层
回复 3# pcbar


这个用定时器的方法可以看做“多线程”?
我用了下这个UDF,下面这个例子里,鼠标在靠近label下边界的时候,label会闪个不停,不知是何原因?
能否帮忙瞧一眼?
#include <GUIConstants.au3>
#include <WindowsConstants.au3>
#include "GUICtrlSetOnHover_UDF.au3"
 
Opt("GUIOnEventMode", 1) 
Local Const $iWidth = 230, $iHeight = 45
Local $hGUI
 
$hGUI = GUICreate("", $iWidth, $iHeight, -1, -1, BitOR($WS_BORDER, $WS_POPUP), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW))
GUISetBkColor(0x19619C)
$BtnClose = GUICtrlCreateLabel("×", $iWidth - 16, 1, 12, 12)
GUICtrlSetFont(-1, 11, 400, 0, "Arial")
GUICtrlSetColor(-1, 0xE8E8E8)
GUICtrlSetTip(-1, "Close")
GUICtrlSetOnEvent(-1, "_Exit")
GUICtrlSetOnHover(-1, "_Hover", "_Leave_Hover")
GUISetState()
 
While 1
        Sleep(100)
WEnd
 
Func _Hover($ctrlId)
        If $ctrlId = $BtnClose Then
                GUICtrlSetColor(-1, 0xFF0000)
                GUICtrlSetPos($BtnClose, $iWidth - 16, 0)
        EndIf
EndFunc

Func _Leave_Hover($ctrlId)
        If $ctrlId = $BtnClose Then
                GUICtrlSetColor(-1, 0xE8E8E8)
                GUICtrlSetPos($BtnClose, $iWidth - 16, 1)
        EndIf
EndFunc
 
Func _Exit()
        Exit
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 23:43 , Processed in 0.080027 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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