[已解决]问一下在GUICtrlCreateTreeView前面是不是可以加ICO图标
本帖最后由 chenronting 于 2010-4-26 08:52 编辑RT:
我在这里放上效果图。 我想仿一下这个软件安装器。
在此先谢过来看过的兄弟们
感谢 2楼水木子大大。。。 呵呵 。 谢谢 可以!用 GUICtrlSetImage
你只是问是不是可以加ICO图标,
所以只敢回答,可以. 可以加ICO图标...... 谢谢 3、4 楼。。 回复 2# 水木子
非常之感谢 。 呵呵 :face (35): 以前写的一个东西,未完成,你参考一下#Region ;**** 参数创建于 ACNWrapper_GUI ****
#AutoIt3Wrapper_icon=..\..\..\autoit3\Aut2Exe\Icons\Setup.ico
#AutoIt3Wrapper_outfile=E:\软件安装器\softins.exe
#AutoIt3Wrapper_Res_Comment=by 3mile
#EndRegion ;**** 参数创建于 ACNWrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#include <array.au3>
#include <GuiTreeView.au3>
#include <GuiButton.au3>
;#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\01.18传送\2.1\softins\Form1.kxf
$Form1 = GUICreate("3mile软件安装管理器", 868, 607, 97, 45)
$Pic1 = GUICtrlCreatePic("1.jpg", 0, 0, 868, 100)
Local $iStyle = BitOR($TVS_LINESATROOT, $TVS_NOHSCROLL, $TVS_NOTOOLTIPS, $TVS_FULLROWSELECT, $TVS_CHECKBOXES, $TVS_HASLINES)
$TreeView1 = GUICtrlCreateTreeView(0, 102, 300, 441, $iStyle, $WS_EX_CLIENTEDGE)
_GUICtrlTreeView_SetBkColor($TreeView1, 0x40e0d0)
_GUICtrlTreeView_SetLineColor($TreeView1, $COLOR_red)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
$ListView1 = GUICtrlCreateListView("1|2|3", 305, 104, 550, 411)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 60)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 200)
_GUICtrlListView_SetColumnWidth($ListView1, 2, 0)
$lable = GUICtrlCreateLabel("", 305, 520, 617, 21)
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
Dim $StatusBar1_PartsWidth =
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar1, "", 0)
_GUICtrlStatusBar_SetText($StatusBar1, "", 1)
_GUICtrlStatusBar_SetText($StatusBar1, "", 2)
$Button1 = GUICtrlCreateButton("Button1", 80, 552, 113, 33)
$Button2 = GUICtrlCreateButton("Button2", 272, 552, 145, 33)
$Button3 = GUICtrlCreateButton("Button3", 496, 552, 137, 33)
;GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$formsub = GUICreate("", 810, 30, 100, 680, $WS_POPUP, -1)
$pe = GUICtrlCreateProgress(10, 10, 800, 20)
GUISetState(@SW_HIDE, $formsub)
GUISetState(@SW_SHOW, $Form1)
$type = IniReadSection("softinst.ini", "type")
Local $number = UBound($type) - 1
$img = _GUIImageList_Create(32, 32, 5, 3)
For $x = 6 To 15
_GUIImageList_AddIcon($img, "shell32.dll", $x, True)
_GUICtrlTreeView_SetNormalImageList($TreeView1, $img)
Next
Local $hItem, $hImage, $listview, $hItemsub
_GUICtrlTreeView_BeginUpdate($TreeView1)
For $i = 1 To $type
$hItem[$i] = _GUICtrlTreeView_Add($TreeView1, 0, $type[$i], $img, $img)
$img = Random(0, 5, 1)
$subtype = IniReadSection("softinst.ini", $type[$i] & ".LIST")
For $b = 1 To $subtype
$img = Random(1, 5, 1)
$hItemsub[$b] = _GUICtrlTreeView_AddChild($TreeView1, $hItem[$i], $subtype[$b], $img, $img)
$subname = $subtype[$b]
$subcheck = IniRead("softinst.ini", $subname, "Checked", "error")
If $subcheck = 1 Then
_GUICtrlTreeView_SetChecked($TreeView1, _GUICtrlTreeView_FindItem($TreeView1, $subname), True)
EndIf
Next
Next
_GUICtrlTreeView_EndUpdate($TreeView1)
_GUICtrlTreeView_Expand($TreeView1)
_GUICtrlTreeView_SelectItem($TreeView1, 0)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
button()
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR
$hWndTreeView = GUICtrlGetHandle($TreeView1)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTreeView
Switch $iCode
Case -451
$item = _GUICtrlTreeView_GetSelection($hWndTreeView)
$root = $item
$txt = _GUICtrlTreeView_GetText($hWndTreeView, $item)
Do
$parent = _GUICtrlTreeView_GetParentHandle($hWndTreeView, $item)
If $parent <> 0 Then
$item = $parent
$info = IniRead("softinst.ini", $txt, "Description", "error")
GUICtrlSetData($lable, $info)
;$check1=_GUICtrlTreeView_GetChecked($hwndTreeView, $item)
;MsgBox(0,0,$check1)
EndIf
Until $parent = 0
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func button()
$delete=_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
;MsgBox(0,0,$delete)
Dim $arr
Dim $filename
For $check = 1 To $type
$chlidnumber = _GUICtrlTreeView_GetChildCount($TreeView1, $hItem[$check])
For $c = 1 To $chlidnumber
$key = _GUICtrlTreeView_GetItemByIndex($TreeView1, $hItem[$check], $c - 1)
If _GUICtrlTreeView_GetChecked($TreeView1, $key) Then
$soft = IniReadSection("softinst.ini", _GUICtrlTreeView_GetText($TreeView1, $key))
_ArrayAdd($filename, _GUICtrlTreeView_GetText($TreeView1, $key))
_ArrayAdd($arr, @ScriptDir & "\" & $soft)
EndIf
Next
Next
$arr = Number(UBound($arr) - 1)
$filename = Number(UBound($filename) - 1)
Dim $file2[$arr]
$ico = _GUIImageList_Create(1,25)
;_GUIImageList_AddIcon($ico, "cancel.ico")
;_GUIImageList_AddIcon($ico, "hot.ico")
_GUICtrlListView_SetImageList($listview1, $ico,1)
For $e = 1 To $arr
$file2[$e - 1] = "安装"
$file2[$e - 1] = $filename[$e]
$file2[$e - 1] = $arr[$e]
Next
For $p = 1 To $arr
;MsgBox(0,0,$file2[$p])
_GUICtrlListView_AddItem($ListView1, "安装", 1)
;_GUICtrlListView_AddSubItem($listview1,$p-1,$file2[$p-1],1)
_GUICtrlListView_AddSubItem($ListView1, $p - 1, $filename[$p], 1, 1)
_GUICtrlListView_AddSubItem($ListView1, $p - 1, $arr[$p],2,1)
Next
For $se = 1 To $arr
_GUICtrlListView_SetItemText($ListView1, $se - 1, "√", 0)
_GUICtrlListView_SetItemSelected($listview1,$se-1)
If $se>8 Then _GUICtrlListView_Scroll($listview1, 0, 15)
GUICtrlSetData($pe, $se * (100 / $arr))
;GUISetState(@SW_HIDE,$Form1)
GUISetState(@SW_SHOW, $formsub)
;MsgBox(0,0,_GUICtrlListView_GetItemText($listview1,$se-1)
Sleep(400)
;MsgBox(0,0,_GUICtrlListView_GetItemText($ListView1, $se - 1, 2),1)
;ShellExecuteWait(_GUICtrlListView_GetItemText($ListView1, $se - 1, 2),1)
Next
;GUISetState(@SW_SHOW,$Form1)
GUISetState(@SW_HIDE, $formsub)
;GUICtrlSetState($lable, $GUI_HIDE)
;GUICtrlSetState($ListView1, $GUI_show)
;MsgBox(0, 0, "完成")
EndFunc 又有例子了。.. 回复 7# 3mile
谢谢。:face (5): 回复 2# 水木子
水木子大哥,2楼上发的有没有代码吗?很想学习下 本帖最后由 水木子 于 2010-6-18 19:22 编辑
回复 10# minghui
是要这个吗?
这个是以前练习写的(写得不好,抱歉。),项目都是固定的,上次写过一个通过读取ini生成项目的。#include <GuiTreeView.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS, $TVS_CHECKBOXES)
$hGUI = GUICreate("Treeview", 400, 300)
$hTreeview = GUICtrlCreateTreeView(2, 2, 180, 294, $iStyle, $WS_EX_CLIENTEDGE)
GUICtrlSetImage(-1, 'shell32.dll', 14)
$hFitem01 = GUICtrlCreateTreeViewItem("项目1", $hTreeview)
$hSitem01 = GUICtrlCreateTreeViewItem("项目1-1", $hFitem01)
$hSitem02 = GUICtrlCreateTreeViewItem("项目1-2", $hFitem01)
$hSitem03 = GUICtrlCreateTreeViewItem("项目1-3", $hFitem01)
GUICtrlSetState($hFitem01, $GUI_EXPAND)
$hFitem02 = GUICtrlCreateTreeViewItem("项目2", $hTreeview)
$hSitem11 = GUICtrlCreateTreeViewItem("项目2-1", $hFitem02)
$hSitem12 = GUICtrlCreateTreeViewItem("项目2-2", $hFitem02)
$hSitem13 = GUICtrlCreateTreeViewItem("项目2-3", $hFitem02)
GUICtrlSetState($hFitem02, $GUI_EXPAND)
$hListBox1 = GUICtrlCreateList("", 185, 2, 213, 295)
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case - 3
Exit
Case $hFitem01, $hFitem02
If BitAND(GUICtrlRead($hFitem01), $GUI_CHECKED) Then
GUICtrlSetState($hSitem01, $GUI_CHECKED)
GUICtrlSetState($hSitem02, $GUI_CHECKED)
GUICtrlSetState($hSitem03, $GUI_CHECKED)
ElseIf BitAND(GUICtrlRead($hFitem01), $GUI_UNCHECKED) Then
GUICtrlSetState($hSitem01, $GUI_UNCHECKED)
GUICtrlSetState($hSitem02, $GUI_UNCHECKED)
GUICtrlSetState($hSitem03, $GUI_UNCHECKED)
EndIf
If BitAND(GUICtrlRead($hFitem02), $GUI_CHECKED) Then
GUICtrlSetState($hSitem11, $GUI_CHECKED)
GUICtrlSetState($hSitem12, $GUI_CHECKED)
GUICtrlSetState($hSitem13, $GUI_CHECKED)
ElseIf BitAND(GUICtrlRead($hFitem02), $GUI_UNCHECKED) Then
GUICtrlSetState($hSitem11, $GUI_UNCHECKED)
GUICtrlSetState($hSitem12, $GUI_UNCHECKED)
GUICtrlSetState($hSitem13, $GUI_UNCHECKED)
EndIf
Case $hSitem01, $hSitem02, $hSitem03, $hSitem11, $hSitem12, $hSitem13
If BitAND(GUICtrlRead($hSitem01), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem02), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem03), $GUI_CHECKED) = 1 Then
GUICtrlSetState($hFitem01, $GUI_CHECKED)
Else
GUICtrlSetState($hFitem01, $GUI_UNCHECKED)
EndIf
If BitAND(GUICtrlRead($hSitem11), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem12), $GUI_CHECKED) = 1 Or BitAND(GUICtrlRead($hSitem13), $GUI_CHECKED) = 1 Then
GUICtrlSetState($hFitem02, $GUI_CHECKED)
Else
GUICtrlSetState($hFitem02, $GUI_UNCHECKED)
EndIf
EndSwitch
WEnd 回复 11# 水木子
谢谢啊!刚入门学习AU3想多看看例子 回复 11# 水木子
还想问你一下,点选字项后怎么在 ListBox 窗口显示出来 回一下,备用谢谢 终于找到了,呵呵
页:
[1]