找回密码
 加入
搜索
查看: 3134|回复: 2

[GUI管理] _GUICtrlListView_AddItem 以及全选问题

[复制链接]
发表于 2010-2-20 23:37:04 | 显示全部楼层 |阅读模式
本帖最后由 yadmin 于 2010-2-20 23:43 编辑

_GUICtrlListView_AddItem 添加的内容
如何进行全选和反选呢?
怎样得到总共添加的条目数,和选择的条目数
还有能否实当超过20条后.添加的时候自动删除原第一条
代码如下
谢谢各位了,论坛里找了半天也未找到解决方案
#NoTrayIcon
#include <GuiListView.au3>
#include <GuiButton.au3>
#include <GuiStatusBar.au3>
#include <GuiTreeView.au3>
#include <StaticConstants.au3>
#include <Constants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### 
Local $aParts[3] = [150, 250, -1];定义状态栏
$Form1 = GUICreate("Form1", 429, 311,-1, -1)
$List1 = GUICtrlCreateListView("序号    |        内容       |", 8, 8, 409, 175,BitOR( $WS_VSCROLL, $WS_BORDER))
$Button1 = GUICtrlCreateButton("添加", 16, 200, 81, 33)
$Button2 = GUICtrlCreateButton("删除", 120, 200, 81, 33)
$Button3 = GUICtrlCreateButton("全选", 224, 200, 81, 33)
$Button4 = GUICtrlCreateButton("反选", 328, 200, 81, 33)

$StatusBar1 = _GUICtrlStatusBar_Create($Form1, $aParts)
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & "共有项目:" & @OSVersion, 0)
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & "已选择:" & @OSVersion, 1)
_GUICtrlStatusBar_SetText($StatusBar1, @TAB & "文件:" & @OSVersion, 2)
GUIRegisterMsg($WM_SIZE, "WM_SIZE");调整状态栏位置
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                         Exit
                Case $Button1
                        _Addlist()
                Case $Button2
                         _GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($List1))
                Case $Button3
                        
                Case $Button4
                        
                        Exit

        EndSwitch
WEnd


Func _Addlist()
GUISetState(@SW_DISABLE, $Form1)
        $Form2 = GUICreate("请输入需要添加的数据", 250, 150, -1, -1, BitOR ($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS))
        $Button11 = GUICtrlCreateButton("保存", 60, 100, 50, 30, $WS_GROUP)
        $Button12 = GUICtrlCreateButton("退出", 130, 100, 50, 30, $WS_GROUP)
        $Label1 = GUICtrlCreateLabel("数据A:", 20, 23, 55, 17)
        $Label2 = GUICtrlCreateLabel("数据B:", 20, 53, 55, 17)
        $Input1 = GUICtrlCreateInput("", 80, 20, 100, 21)
        $Input2 = GUICtrlCreateInput("", 80, 50, 100, 21)
                
        GUISetState(@SW_SHOW)

        While 1
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case -3, $Button12
                                GUISetState(@SW_ENABLE, $Form1) ;启用父窗口
                                GUIDelete($Form2) ;;删除指定窗口和它包含的所有控件.
                                ExitLoop;Exit
                                
                                                        Case $Button11
                                                                
                                                                $num1=GUICtrlRead($Input1)
                                                                $num2=GUICtrlRead($Input2)
                                                                $Number = _GUICtrlListView_GetItemCount($List1)
                                                                _GUICtrlListView_AddItem($List1, $num1, $Number)
                                                                _GUICtrlListView_AddSubItem($List1, $Number, $num2, 1)
                                                                


                EndSwitch
        WEnd

EndFunc   ;==>_Addlist



;调整状态栏位置
Func WM_SIZE($hWnd, $msg, $wParam, $lParam)
        _GUICtrlStatusBar_Resize($StatusBar1)
        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_SIZE
发表于 2010-2-21 01:46:23 | 显示全部楼层
update/add/delete
 楼主| 发表于 2010-2-21 02:09:55 | 显示全部楼层
本帖最后由 yadmin 于 2010-2-21 02:23 编辑

获取选择的数量和总数已经用
_GUICtrlListView_GetSelectedCount
_GUICtrlListView_GetItemCount

状态栏显示用_Timer_SetTimer 解决了.

剩下的明天再研究
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 14:10 , Processed in 0.078424 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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