ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


3 posters

    การเพิ่มรูปเข้าไปใน Listbox

    avatar
    pureexe
    PSsix Member High Class
    PSsix Member High Class


    การเพิ่มรูปเข้าไปใน Listbox Empty
    จำนวนข้อความ : 73
    ความนิยม : 8
    เข้าร่วมเมื่อ : 27/04/2011

    การเพิ่มรูปเข้าไปใน Listbox Empty การเพิ่มรูปเข้าไปใน Listbox

    ตั้งหัวข้อ by pureexe 18/11/11, 04:53 pm

    ก็คือตอนนี้ผมเพิ่มรูปไม่เป็นเลยเอาคำว่า Folder ไปวางไว้ข้างหน้าก่อน แก้ขัด*-*
    ถ้าท่านผู้รู้รู้วิธีเอารูปfolderไปวางไว้ข้างหน้าบอกด้วยนะครับ
    Codeๆๆๆ


    #include <ButtonConstants.au3>
    #include <ComboConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <GUIListBox.au3>
    #include <StaticConstants.au3>
    #include <WindowsConstants.au3>
    #include <File.au3>

    Opt('MustDeclareVars', 1)
    Global $data,$ret,$file,$Folders,$btchk,$retx,$Foldersx,$fileold[200],$dataview,$uvx=0,$hListBox,$aItems,$iI,$ctopen=0,$ctopenstr="",$dirwrite="<---Folder---> ",$dirwritelen=StringLen($dirwrite),$filelen,$Label_1,$Combo_2,$Buttonback
    Global $backword=">--กลับไปก่อนหน้า--<"
    _Main()

    Func _Main()
    Local $Label_1, $Combo_2, $button1, $msg,$Button2
    #Region ### START Koda GUI section ### Form=
    $ret =""

    if $CmdLine[0]=0 Then
    MsgBox(4,"คำเตือน","ไม่พบการส่งค่าต้องการเลือกโฟลเดอร์เองหรือไม่")
    if $btchk<>7 Then
    FileSelectFolder("กรุณาเลือกfolderที่จะทำการดู","","","")
    Else
    Exit
    EndIf
    Else
    $file=$CmdLine[1]
    EndIf
    $Folders =_FileListToArray($file,"*.")
    for $i =1 to $Folders[0]
    $ret &=$Folders[$i] &"|"
    Next

    GUICreate("Explorer[Safe Mode]::Flash Drive Safe Check", 403, 470, -1, -1)
    $Label_1 = GUICtrlCreateLabel("Please select folder", -2, 0, 403, 21, $SS_SUNKEN)
    $Combo_2 = GUICtrlCreateCombo("", 0, 20, 402, 25)
    GUICtrlSetData($Combo_2, $ret)
    $hListBox = GUICtrlCreateList("", 0, 42, 404, 396, BitOR($LBS_SORT,$LBS_STANDARD,$LBS_EXTENDEDSEL,$WS_VSCROLL,$WS_BORDER))
    $Button2 = GUICtrlCreateButton("เปิดไฟล์", 72, 442, 122, 20, $WS_GROUP)
    $Buttonback = GUICtrlCreateButton("Back", 200, 442, 122, 20, $WS_GROUP)
    _readfileall()
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
    $msg = GUIGetMsg()
    Select

    Case $msg = $GUI_EVENT_CLOSE
    Exit
    Case $msg = $Combo_2
    $data = GUICtrlRead($Combo_2)
    $dataview=$data
    if $data = $backword And $uvx>0 then
    $file = ""
    $uvx=$uvx-1
    $data =$fileold[$uvx]
    $dataview=$fileold
    endif
    _readfileindir()
    GUICtrlSetData($Combo_2, "")
    GUICtrlSetData($Combo_2, $retx)
    GUICtrlSetData($Label_1, $dataview)
    Case $msg=$hListBox
    $aItems = _GUICtrlListBox_GetSelItemsText($hListBox)
    Local $stockaItems=""
    if $aItems[0]<>0 Then
    $filelen=StringLen($aItems[1])

    If StringMid($aItems[1],1,1)=StringMid($dirwrite,1,1) And StringMid($aItems[1],1,2)=StringMid($dirwrite,1,2) And StringMid($aItems[1],1,3)=StringMid($dirwrite,1,3) Then
    for $i=$dirwritelen+1 to $filelen
    $stockaItems&=StringMid($aItems[1],$i,1)
    Next
    $data=$stockaItems

    EndIf

    if $ctopenstr<>$aItems[1] Then
    $ctopen=0
    Endif
    $dataview=$data

    if $aItems[1] = $backword And $uvx>0 then
    $file = ""
    $uvx=$uvx-1
    $data =$fileold[$uvx]
    $dataview=$fileold
    _readfileindir()
    GUICtrlSetData($Label_1, $dataview)
    GUICtrlSetData($Combo_2, "")
    GUICtrlSetData($Combo_2, $retx)
    endif

    if $aItems[0]=1 And $ctopenstr=$aItems[1] And $ctopen=1 And StringMid($aItems[1],1,1)=StringMid($dirwrite,1,1) And StringMid($aItems[1],1,2)=StringMid($dirwrite,1,2) And StringMid($aItems[1],1,3)=StringMid($dirwrite,1,3)Then
    _readfileindir()
    GUICtrlSetData($Label_1, $dataview)
    GUICtrlSetData($Combo_2, "")
    GUICtrlSetData($Combo_2, $retx)
    ElseIf $aItems[0]=1 And $ctopenstr=$aItems[1] And $ctopen=1 And $aItems[1]=$backword Then
    $ctopenstr=""
    elseif $aItems[0]=1 And $ctopenstr=$aItems[1] And $ctopen=1 Then
    ShellExecute($file&"\"&$aItems[1])
    $ctopenstr=""
    EndIf
    if $aItems[0]=1 And $ctopenstr<>$aItems[1] And $ctopen=0 Then
    $ctopenstr=$aItems[1]
    $ctopen=1
    EndIf
    EndIf
    Case $msg=$Buttonback
    If $uvx>0 Then
    $file = ""
    $uvx=$uvx-1
    $data =$fileold[$uvx]
    $dataview=$fileold
    _readfileindir()
    GUICtrlSetData($Combo_2, "")
    GUICtrlSetData($Combo_2, $retx)
    GUICtrlSetData($Label_1, $dataview)
    Else
    MsgBox(64,"คำเตือน","ไม่สามารถกลับไปไกลได้มากกว่านี้อีกแล้ว")
    EndIf


    Case $msg=$Button2
    if $aItems[0]=0 Then
    MsgBox(64,"คำเตือน","คุณยังไม่ได้เลือกอะไรเลย")
    ElseIf (StringMid($aItems[1],1,1)=StringMid($dirwrite,1,1) And StringMid($aItems[1],1,2)=StringMid($dirwrite,1,2) And StringMid($aItems[1],1,3)=StringMid($dirwrite,1,3)) Then
    MsgBox(64,"คำเตือน","เพื่อความปลอดภัยจึงไม่สามารถเปิดfolderได้")
    Else
    For $iI = 1 To $aItems[0]
    ShellExecute($file&"\"&$aItems[$iI])
    Next
    EndIf

    EndSelect
    WEnd
    EndFunc

    Func _readfile()
    _GUICtrlListbox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
    _GUICtrlListBox_Dir($hListBox, $file&"\*.*")

    _GUICtrlListBox_EndUpdate($hListBox)
    _GUICtrlListBox_Sort($hListBox)
    EndFunc

    Func _readfileall()
    $ret =""
    $Folders =_FileListToArray($file,"*.*")
    $Foldersx =_FileListToArray($file,"*.")
    if $Foldersx="" Or $Folders="" Then
    Else

    For $i=1 To $Foldersx[0]
    $Foldersx[$i]=$dirwrite&$Foldersx[$i]
    Next
    EndIf

    _GUICtrlListBox_BeginUpdate($hListBox)
    _GUICtrlListBox_ResetContent($hListBox)
    _GUICtrlListBox_InitStorage($hListBox, 100, 4096)
    if $Foldersx="" Then
    _GUICtrlListBox_Dir($hListBox, $file&"\*.*")
    Else
    for $i =1 to $Foldersx[0]
    _GUICtrlListBox_InsertString($hListBox,$Foldersx[$i])
    Next
    _GUICtrlListBox_Dir($hListBox, $file&"\*.*")
    EndIf
    if $uvx>0 Then
    _GUICtrlListBox_InsertString($hListBox,$backword)
    EndIf
    _GUICtrlListBox_EndUpdate($hListBox)
    _GUICtrlListBox_Sort($hListBox)
    EndFunc
    Func _readfileindir()
    $retx=""


    if $file ="" Then
    $file =$data
    $fileold[$uvx]=$data
    else

    $fileold[$uvx]=$file
    $uvx=$uvx+1
    $file &="/"&$data
    EndIf

    $dataview=$file
    GUICtrlSetData($Label_1, $dataview)
    $Foldersx=""
    $Foldersx =_FileListToArray($file,"*.")
    if $Foldersx="" Then

    else
    for $i =1 to $Foldersx[0]
    $retx &=$Foldersx[$i] &"|"
    Next
    endif
    $retx&=$backword
    $retx &="|"
    GUICtrlSetData($Combo_2, "")
    GUICtrlSetData($Combo_2, $retx)
    _readfileall()
    EndFunc
    aut
    aut
    PSsix Powerful Scripting Class
    PSsix Powerful Scripting Class


    PSsix Game Coder
    จำนวนข้อความ : 472
    ความนิยม : 126
    เข้าร่วมเมื่อ : 24/07/2010

    การเพิ่มรูปเข้าไปใน Listbox Empty Re: การเพิ่มรูปเข้าไปใน Listbox

    ตั้งหัวข้อ by aut 18/11/11, 07:31 pm

    GUICtrlSetImage หาที่ใส่เอง ชินจัง
    POS
    POS
    PSsix
    PSsix


    การเพิ่มรูปเข้าไปใน Listbox Empty การเพิ่มรูปเข้าไปใน Listbox Empty การเพิ่มรูปเข้าไปใน Listbox Empty
    จำนวนข้อความ : 1152
    ความนิยม : 326
    เข้าร่วมเมื่อ : 19/07/2010

    การเพิ่มรูปเข้าไปใน Listbox Empty Re: การเพิ่มรูปเข้าไปใน Listbox

    ตั้งหัวข้อ by POS 19/11/11, 06:55 am

    ตัวอย่างสคริปต์ด้านล่างนี้ เอาไปดัดแปลงดูครับ

    Code:
    #include <WindowsConstants.au3>
    #include <GUIListBox.au3>
    #include <GuiListView.au3>
    #include <GuiImageList.au3>


    #region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("PSsix", 400, 300,-1,-1)
    $listview1 = GUICtrlCreateListView("", 2, 2, 394, 290, BitOR($WS_VSCROLL,$LBS_EXTENDEDSEL ), _
          BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))

    GUISetState(@SW_SHOW)
    #endregion ### END Koda GUI section ###

    $hImage = _GUIImageList_Create(16, 16, 5, 3)
    _GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 4)
    _GUICtrlListView_SetImageList($listview1, $hImage, 1)
    _GUICtrlListView_AddColumn($listview1, "xxxxxx", 350)


    $listF = @DesktopDir
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $listF = ' & $listF & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console


    SrFolder($listF)



    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
       EndSwitch
    WEnd

    Func SrFolder($listF)
       Local $search = FileFindFirstFile($listF & "\*.*")
       While 1
          $file = FileFindNextFile($search)
          If @error Or StringLen($file) < 1 Then ExitLoop
          If StringInStr(FileGetAttrib($listF & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then
    ;~             _GUICtrlListView_AddItem($listview1, $listF & "\" & $file, 0)
             _GUICtrlListView_AddItem($listview1, $file, 0)
    ;~          SrFolder($listF & "\" & $file)
          EndIf
       WEnd
    EndFunc  ;==>SrFolder

      เวลาขณะนี้ 08/05/24, 07:10 pm