找回密码
 加入
搜索
查看: 5390|回复: 14

[GUI管理] 窗口上做网址超链接【已解决】

  [复制链接]
发表于 2015-1-13 10:47:32 | 显示全部楼层 |阅读模式
本帖最后由 deaph 于 2015-1-16 11:07 编辑

想要做一个窗口后在里面做网址链接并简单说明网址,搜索了2天没有找到相关内容,求位大大指条路!
发表于 2015-1-13 22:22:33 | 显示全部楼层
本帖最后由 李岸 于 2015-1-13 22:32 编辑
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <WinAPISys.au3>
#include <WinAPIRes.au3>
$iflg = 0
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Link", 279, 92, 192, 124)
$Label1 = GUICtrlCreateLabel("My Blog:", 48, 40, 64, 17)
$Label2 = GUICtrlCreateLabel("http://www.baidu.com", 112, 40, 120, 17)
GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
_WinAPI_SetClassLongEx(_WinAPI_GetDlgItem($Form1, $Label2), $GCL_HCURSOR, _WinAPI_LoadCursor(0, $IDC_HAND))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR")



Do
Until GUIGetMsg() = -3



Func WM_SETCURSOR($hWnd, $Msg, $wParam, $lParam)
        $MouseMsg = BitShift($lParam, 16) ; _WinAPI_HiWord 高位字

        If _WinAPI_GetDlgCtrlID($wParam) == $Label2 Then
                If Not $iflg Then
                        ToolTip("This site is my blog...")
                        $iflg = 1
                EndIf
                If $MouseMsg == 513 Then
                        Run(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE http://www.baidu.com", "", @SW_MAXIMIZE)
                EndIf
        Else
                If $iflg Then
                        ToolTip("")
                        $iflg = 0
                EndIf
        EndIf
        
EndFunc   ;==>WM_SETCURSOR

评分

参与人数 1金钱 +10 收起 理由
zhouhaijin + 10 感谢,先学习下

查看全部评分

发表于 2015-1-13 22:30:11 | 显示全部楼层
看来GUICtrlSetCursor(-1,0)函数,将label控件类化了。(因为在AU3中我也不会类化控件)
所以主窗口接收不到WM_SETCURSOR消息.所以使用了_WinAPI_*.
反正方法很多,这可能是最笨的一种,晚安~
 楼主| 发表于 2015-1-14 09:21:51 | 显示全部楼层
感谢,先学习下
 楼主| 发表于 2015-1-14 09:49:09 | 显示全部楼层
$MouseMsg = BitShift($lParam, 16) ; _WinAPI_HiWord 高位字
请问:这句看帮助是鼠标右移16,请问实现什么功能呐
If $MouseMsg == 513 Then
还有这句513完全等于$mousemsg是啥意思
看不太懂,我是新手求解惑!
发表于 2015-1-14 09:54:46 | 显示全部楼层
exe的帮助里有GUISysLink也许可用
 楼主| 发表于 2015-1-14 10:12:58 | 显示全部楼层
exe的帮助里有GUISysLink也许可用
netegg 发表于 2015-1-14 09:54



    没找到这个guisyslink的说明,直接在SciTE里输入按F1吗?还是用别的方式?
发表于 2015-1-14 11:56:33 | 显示全部楼层
谢谢分享。。。。。。。。。。。。。。
发表于 2015-1-14 12:39:55 | 显示全部楼层
lParam的高位是鼠标信息(当鼠标滑过高位为512d、当鼠标左键单击或者放下为513d和514d、右键为516d和517d)、lParam的低位是鼠标在客户区的位置ID

详见WM_SETCURSOR消息
发表于 2015-1-14 13:17:53 | 显示全部楼层
本帖最后由 李岸 于 2015-1-14 13:21 编辑

发现上面的代码用_winapi_setclasslongex修改过后,竟然所有悬停在label上的光标都变成了手型,原因是因为label都是基于一个类创建的。所以那么写是不正确的。
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <WinAPISys.au3>
#include <WinAPIRes.au3>
$iflg = 0
#Region ### START Koda GUI section ### Form=C:\Users\Administrator\Desktop\Form1.kxf
$Form1 = GUICreate("Link", 279, 92, 192, 124)
$Label1 = GUICtrlCreateLabel("My Blog:", 40, 40, 64, 17)
$Label2 = GUICtrlCreateLabel("http://www.baidu.com", 112, 40, 111, 17)
GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000FF)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_SETCURSOR, "WM_SETCURSOR")



Do
Until GUIGetMsg() = -3



Func WM_SETCURSOR($hWnd, $Msg, $wParam, $lParam)
        $MouseMsg = BitShift($lParam, 16) ; _WinAPI_HiWord 高位字
        ;划过LABEL2
        If _WinAPI_GetDlgCtrlID($wParam) == $Label2 And $MouseMsg == 512 Then
                If Not $iflg Then
                        ToolTip("This site is my blog...")
                        _WinAPI_SetClassLongEx(_WinAPI_GetDlgItem($Form1, $Label2), $GCL_HCURSOR, _WinAPI_LoadCursor(0, $IDC_HAND))
                        $iflg = 1
                EndIf
        EndIf
        ;其他控件
        If _WinAPI_GetDlgCtrlID($wParam) <> $Label2 Then
                If $iflg Then
                        ToolTip("")
                        _WinAPI_SetClassLongEx(_WinAPI_GetDlgItem($Form1, $Label2), $GCL_HCURSOR, _WinAPI_LoadCursor(0, $IDC_ARROW))
                        $iflg = 0
                EndIf
        EndIf
        ;点击LABEL2
        If _WinAPI_GetDlgCtrlID($wParam) == $Label2 And $MouseMsg == 513 Then
                Run(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE http://www.baidu.com", "", @SW_MAXIMIZE)
        EndIf
Return $GUI_RUNDEFMSG


EndFunc   ;==>WM_SETCURSOR

评分

参与人数 1金钱 +10 收起 理由
deaph + 10 钱不多,但是要感谢下!

查看全部评分

发表于 2015-1-14 13:22:59 | 显示全部楼层
最直接的方法还是类化,不过AU3里不会
发表于 2015-1-15 09:05:28 | 显示全部楼层
学习学习。。。。。。。。。。。。。。。。。。好例子
 楼主| 发表于 2015-1-15 09:14:32 | 显示全部楼层
大概懂了,非常感谢!
发表于 2015-1-16 18:53:28 | 显示全部楼层
本帖最后由 lanfengc 于 2015-1-16 19:19 编辑

回复 10# 李岸

回复 1# deaph


    直接使用

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Link", 279, 92, 192, 124)
$Label1 = GUICtrlCreateLabel("My Blog:", 40, 40, 64, 17)
$Label2 = GUICtrlCreateLabel("http://www.baidu.com", 112, 40, 111, 17)
GUICtrlSetFont(-1, 8, 400, 4, "MS Sans Serif")
GUICtrlSetCursor(-1,0)
GUICtrlSetColor(-1, 0x0000FF)
GUISetState(@SW_SHOW)

Do
        Local $controlID=GUIGetCursorInfo($Form1)
        If $controlID[4]=$Label2 Then
                ToolTip("this is my blog..")
        Else
                ToolTip("")
        EndIf
Until GUIGetMsg() = -3


就好了.

评分

参与人数 2金钱 +20 收起 理由
acbs + 10 学习了
李岸 + 10 虚心学习

查看全部评分

发表于 2015-1-17 14:23:48 | 显示全部楼层
本帖最后由 李岸 于 2015-1-17 14:25 编辑

回复 14# lanfengc
内置函数向上封了一层,一句就搞定,厉害!不过只是表象不同,本质没有变化。
虚心学习
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 15:39 , Processed in 0.118866 second(s), 30 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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