找回密码
 加入
搜索
查看: 2346|回复: 8

如何响应ITEM的点击?

  [复制链接]
发表于 2009-12-29 14:29:21 | 显示全部楼层 |阅读模式
本帖最后由 awfymwvf 于 2009-12-30 09:48 编辑

比如下面这个图:


我想在点击E盘这一行ITEM的时候。在一个文本框中或一个COMBO中输出这个ITEM的内容。比如我现在点E盘了。在文本框中显示E:,这个功能要怎么实现啊?谢谢大家了

评分

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

查看全部评分

发表于 2009-12-29 14:54:28 | 显示全部楼层
 楼主| 发表于 2009-12-30 09:48:29 | 显示全部楼层
谢谢landays ,问题已在你的指导下解决了
发表于 2009-12-30 15:43:25 | 显示全部楼层
本帖最后由 sanmoking 于 2010-1-2 02:40 编辑

不要用鼠标点击.......用检测更有效....
因为有的时候不是用鼠标来确定选择的条目.用上下箭头也能进行选择,这样你用点击来识别就不能用了不是.....

给你个例子..

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("Form1", 228, 226, 192, 124)
$ListView = GUICtrlCreateListView("#|用户|代码", 8, 8, 209, 137)
For $i = 1 To 10        
        GUICtrlCreateListViewItem ($i&"|"&"user"&$i&"|"&Random(1000000,9999999,1),$listview)
Next        
$Input1 = GUICtrlCreateInput("用户", 8, 152, 129, 21)
$Input2 = GUICtrlCreateInput("代码", 8, 184, 129, 21)
GUISetState(@SW_SHOW)
$shanchuidold = ""
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
        EndSwitch
        $shanchuid = ControlListView ($Form1, "", "SysListView321", "GetSelected", 0)
;       $mac1 = ControlListView ($Form1, "", "SysListView321", "GetText", $shanchuid, 1)
;       $mac2 = ControlListView ($Form1, "", "SysListView321", "GetText", $shanchuid, 2)
        
        if $shanchuid = "" and $shanchuid <> $shanchuidold  Then
        GUICtrlSetData($Input2,"")
        GUICtrlSetData($Input1,"")        
        ElseIf $shanchuid <> "" and $shanchuid <> $shanchuidold then
        $mac1 = ControlListView ($Form1, "", "SysListView321", "GetText", $shanchuid, 1)   ;放在这又会省下一点资源咯
        $mac2 = ControlListView ($Form1, "", "SysListView321", "GetText", $shanchuid, 2)
   
                GUICtrlSetData($Input2,$mac2)
                GUICtrlSetData($Input1,$mac1)               
        EndIf        
        $shanchuidold = $shanchuid
WEnd

大概是这样子的,

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2009-12-30 15:45:05 | 显示全部楼层
回复 3# awfymwvf


    哈哈 谁给个花吧?
发表于 2010-1-2 02:27:49 | 显示全部楼层
不要用鼠标点击.......用检测更有效....
因为有的时候不是用鼠标来确定选择的条目.用上下箭头也能进行选择 ...
sanmoking 发表于 2009-12-30 15:43



不错!
不过会不会很耗资源?
发表于 2010-1-2 02:39:00 | 显示全部楼层
不错!
不过会不会很耗资源?
wwwwffff 发表于 2010-1-2 02:27



    不会,因为有if来识别所选的条目是否变动。。。。只有你所选的条目有变动的话,才会更新input的文字。。。

多加一句ControlListView ($Form1, "", "SysListView321", "GetSelected", 0)不会占多大资源的。。
 楼主| 发表于 2010-1-3 09:00:43 | 显示全部楼层
收藏一下。以后备用。谢谢大家了
发表于 2012-1-2 21:49:50 | 显示全部楼层
感谢分享!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-1 01:29 , Processed in 0.102016 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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