找回密码
 加入
搜索
查看: 4438|回复: 12

[AU3基础] ListView1为何不显示复选框

  [复制链接]
发表于 2015-3-29 13:24:43 | 显示全部楼层 |阅读模式
本帖最后由 dnvplj 于 2015-3-29 13:25 编辑

请问各位朋友,下面的代码为何不象下图中那样显示复选框,我以设置了,研究1天多了,也没整明白,望各位朋友指教,先谢谢了。
#Region
#AutoIt3Wrapper_UseX64=n
#EndRegion

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <ProgressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include <GuiListView.au3>
#include <File.au3>
#include <Array.au3>

#Region
Global $gu_Form1 = GUICreate("Form1", 615, 484, 192, 124)
Global $gu_Pic1 = GUICtrlCreatePic("", 0, 0, 609, 73)
Global $gu_ListView1 = GUICtrlCreateListView("", 5, 72, 603, 289, _
                BitOR($GUI_SS_DEFAULT_LISTVIEW, _
                $WS_HSCROLL, $WS_VSCROLL), _
                BitOR($WS_EX_CLIENTEDGE, $LVS_EX_GRIDLINES, _
                $LVS_EX_CHECKBOXES))

Global $gu_Button1 = GUICtrlCreateButton("Button1", 472, 448, 65, 25)
Global $gu_Button2 = GUICtrlCreateButton("Button2", 544, 448, 65, 25)

GUICtrlSetColor(-1, 0x000000)
Global $gu_Progress1 = GUICtrlCreateProgress(0, 400, 609, 13, $PBS_SMOOTH)

#EndRegion

_Main()
Exit

Func _Main()

        While 1

                _GUICtrlListView_AddColumn($gu_ListView1, "序号", 60)
                _GUICtrlListView_AddColumn($gu_ListView1, "子文件夹", 410)
                _GUICtrlListView_AddColumn($gu_ListView1, "大小", 70)
                                _GUICtrlListView_AddColumn($gu_ListView1, "版本", 70)
                GUICtrlSetData($gu_Progress1, 0)
                GUICtrlSetState($gu_Progress1, $GUI_HIDE)
                
                GUISetState(@SW_SHOW)
                
                Local $nMsg
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit
                                
                        Case $gu_Button2
                                Exit

                EndSwitch
        WEnd

EndFunc   ;==>_Main

本帖子中包含更多资源

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

×
发表于 2015-3-29 13:33:44 | 显示全部楼层
本帖最后由 netegg 于 2015-3-29 13:35 编辑

没加项的时候好像是不显示
还有可能是你创建的listview不支持扩展属性,那个好像需要用个函数来指定
 楼主| 发表于 2015-3-29 13:37:06 | 显示全部楼层
回复 2# netegg
谢谢“元老”的回复,怎么加项,能给一个小例子吗?
发表于 2015-3-29 13:41:41 | 显示全部楼层
回复  netegg
谢谢“元老”的回复,怎么加项,能给一个小例子吗?
dnvplj 发表于 2015-3-29 13:37



看看这个函数   _GUICtrlListView_CopyItems 的示例
发表于 2015-3-29 13:42:24 | 显示全部楼层
GUICtrlCreateListViewitem
 楼主| 发表于 2015-3-29 15:58:39 | 显示全部楼层
还是没有整明白,望高手给予解答为盼。
发表于 2015-3-31 20:26:12 | 显示全部楼层
listview是用来放一项一项内容的,没放内容当然什么都看不到。
Func _Main()
        _GUICtrlListView_AddColumn($gu_ListView1, "序号", 60)
        _GUICtrlListView_AddColumn($gu_ListView1, "子文件夹", 410)
        _GUICtrlListView_AddColumn($gu_ListView1, "大小", 70)
        _GUICtrlListView_AddColumn($gu_ListView1, "版本", 70)
         ; 添加项目.
    _GUICtrlListView_AddItem($gu_ListView1, "行 1: 列 1", 0)
    _GUICtrlListView_AddSubItem($gu_ListView1, 0, "行 1: 列 2", 1, 1)
    _GUICtrlListView_AddSubItem($gu_ListView1, 0, "行 1: 列 3", 2, 2)
    _GUICtrlListView_AddItem($gu_ListView1, "行 2: 列 1", 1)
    _GUICtrlListView_AddSubItem($gu_ListView1, 1, "行 2: 列 2", 1, 2)
    _GUICtrlListView_AddItem($gu_ListView1, "行 3: 列 1", 2)

        GUICtrlSetData($gu_Progress1, 0)
        GUICtrlSetState($gu_Progress1, $GUI_HIDE)

        GUISetState(@SW_SHOW)
        
        While 1
                Local $nMsg
                $nMsg = GUIGetMsg()
                Switch $nMsg
                        Case $GUI_EVENT_CLOSE
                                Exit

                        Case $gu_Button2
                                Exit

                EndSwitch
        WEnd
EndFunc   ;==>_Main
 楼主| 发表于 2015-3-31 23:13:34 | 显示全部楼层
回复 7# shqf

首先感谢“shqf ”朋友的回复,有3个问题请给予指导,一是:序号应添加1、2、3...列,二:复选框应添加到复选框栏列,三是:如何添加图标到复选框后列。
发表于 2015-4-1 08:49:46 | 显示全部楼层
回复 8# dnvplj
[au3]#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>

Opt('MustDeclareVars', 1)

Global $Debug_LV = False ; Check ClassName being passed to ListView functions, set to True and use a handle to another control to see it work

_Main()

Func _Main()
        Local $hImage, $hListView, $exStyles = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $lvs_ex_checkboxes)
       
        GUICreate("ListView Get Item Image", 400, 300)
        $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
        _GUICtrlListView_SetExtendedListViewStyle($hListView, $exStyles)
        GUISetState()

        ; Load images
        $hImage = _GUIImageList_Create()
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0xFF0000, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x00FF00, 16, 16))
        _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($hListView, 0x0000FF, 16, 16))
        _GUICtrlListView_SetImageList($hListView, $hImage, 1)

        ; Add columns
        _GUICtrlListView_AddColumn($hListView, "Column 1", 100)
        _GUICtrlListView_AddColumn($hListView, "Column 2", 100)
        _GUICtrlListView_AddColumn($hListView, "Column 3", 100)

        ; Add items
        _GUICtrlListView_AddItem($hListView, "", 0)
        _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1, 1)
        _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2, 2)
        _GUICtrlListView_AddItem($hListView, "", 1)
        _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1, 2)
        _GUICtrlListView_AddItem($hListView, "", 2)

        ; Set item 1, subitem 1 image
        _GUICtrlListView_SetItemImage($hListView, 1, 1, 1)
        MsgBox(4160, "Information", "Item 1, SubItem 1 Image: " & _GUICtrlListView_GetItemImage($hListView, 1, 1))

        ; Loop until user exits
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
EndFunc   ;==>_Main[/au3]
发表于 2015-4-1 21:19:52 | 显示全部楼层
回复 8# dnvplj


    不好意思,不太能理解你的三个问题,不过感觉问题一、二已不需其他listview(列表视图管理)知识就可以解决了,问题三从netegg的代码中也能找到解决的方法。
 楼主| 发表于 2015-4-1 22:24:48 | 显示全部楼层
回复 10# shqf
就是下面图片的效果

本帖子中包含更多资源

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

×
发表于 2015-4-2 09:34:20 | 显示全部楼层
回复 11# dnvplj
那和图片有什么关系,_GUICtrlListView_SetColumnOrderArray就行了
 楼主| 发表于 2015-4-2 12:42:17 | 显示全部楼层
回复 12# netegg

您好元老,10楼的朋友说,不明白我的意思,所以我给他上一张图。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-10 22:25 , Processed in 0.081454 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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