Jump to content

Desktop listview Style


Recommended Posts

i'm curious.. i can't find it anywhere, i've gotten icons and text working, but on the same line, i would like to know if it is possible to make a ListViewItem like that of the Progman Listview? Icon above Text. is there a certain combination of styles? everything i have found only seems to work with single line of icon then text not icon above text.

Link to comment
Share on other sites

does anyone know how to make a Thumbnail view icon in a listview control?

Link to comment
Share on other sites

Thank you Kafu though.. that is kinda beyond me.. i'll look into it more later, here is a working example of what i have. - i'm wondering if the icons in this can be larger and Above the text with a simple change of a Listview style? instead of the objects... as the Msdn says i need to do.

#include <WindowsConstants.au3>
#include <GUIConstantsEX.au3>
#include <Misc.au3>
#include <string.au3>
#include <array.au3>
#include <winapi.au3>
#include <file.au3>
#Include <GuiListView.au3>
Opt ('Guioneventmode',1)
$hWnd_Tray = WinGetHandle ('[CLASS:Shell_TrayWnd]')
$CenterStyle = BitOR (0x01,0x0200)
$EdgeStyle = 0x00000001
$Style = 0x80000000
$ExStyle = 0x00000100
$DefBk1 = 0x313131
$DefBk2 = 0x212121
$DefBk3 = 0xFF0000
$DefBk4 = 0xC40000
        $GUI_bk = 0xFFFFFF
        $GUI_FontColor = 0x0
        $Ctrl_bk = 0x0
        $FontColor = 0xFFFFFF
$FontName = 'Tahoma'
$FontSize = 10
$FontWeight = 900
$DW = @DesktopWidth
$DH = @DesktopHeight
$DefW = Int ($DW/2)
$DefH = Int ($DH/2)
$chr = Chr (183)
$Trans = 200
$StartBarH = Int ($DH/20)
$chr_StartButton = Chr (216)
$hWnd_Explorer = _NewExplorer (@DesktopDir)
While 1
    If ControlGetText ($hWnd_Explorer,'','Static1') <> WinGetTitle ($hWnd_Explorer) Then
        ControlSetText ($hWnd_Explorer,'','Static1',WinGetTitle ($hWnd_Explorer))
    EndIf
    $dCtrlhWnd = ControlGetHandle ($hWnd_Explorer,'','SysListView321')
    $Dir = StringTrimLeft (StringTrimRight (WinGetTitle ($hWnd_Explorer),1),1)
    $dCtrlID = _WinAPI_GetDlgCtrlID ($dCtrlhWnd)
    $dCtrlCount = _GUICtrlListView_GetItemCount($dCtrlhWnd)
    $dFileCount = _FileListToArray ($Dir)
    If UBound ($dFileCount) - 1 <> $dCtrlCount Then
        _GUICtrlListView_DeleteAllItems ($dCtrlhWnd)
        For $ii = 1 To UBound ($dFileCount) - 1
            $ID = GUICtrlCreateListViewItem ($dFileCount[$ii],$dCtrlID)
            If FileGetAttrib ($Dir & '\' & $dFileCount[$ii]) = 'D' Then
                GUICtrlSetImage ($ID,@SystemDir & '\Shell32.dll',4)
            Else
                GUICtrlSetImage ($ID,@SystemDir & '\Shell32.dll',1)
            EndIf
            GUICtrlSetOnEvent ($ID,'_Explorer_Action')
        Next
    EndIf
    Sleep (100)
WEnd
;==========================================================================
;==========================================================================
Func _ListViewCreate ($x,$y,$w,$h)
    $CtrlID = GUICtrlCreateListView ('',$x,$y,$w,$h,BitOR (0x0000,0x0003,0x4000,0x0008), BitOR (0x00000008,0x00000010))
        GUICtrlSetFont ($CtrlID,$FontSize,$FontWeight,'',$FontName)
        GUICtrlSetBkColor ($CtrlID,$Ctrl_bk)
        GUICtrlSetColor ($CtrlID,$FontColor)
    Return $CtrlID
EndFunc
;==========================================================================
;==========================================================================
Func _NewExplorer ($Title)
    If DriveStatus ($Title) <> 'READY' Then  Return
    $hWnd = _WinCreate ($Title)
        $x = 20
        $y = 20
        $bw = $x*4
        $w = _WinAPI_GetWindowWidth ($hWnd)
        $h = _WinAPI_GetWindowHeight($hWnd)-($y*3)
        $ID = _ButtonCreate ('Previous',$x,$y*2,$bw,$y,$DefBk3,$DefBk4)
            GUICtrlSetOnEvent ($ID,'_Explorer_Back')
        $ID = GUICtrlCreateInput ('Go To Address...',$x+$bw,$y*2,$w-($bw*2)-($x*2),$y)
            GUICtrlSetFont ($ID,$FontSize,$FontWeight,'',$FontName)
            GUICtrlSetBkColor ($ID, $Ctrl_bk)
            GUICtrlSetColor ($ID,$FontColor)
        $ID = _ButtonCreate ('Go To',$w-$bw-$x,$y*2,$bw,$y,$DefBk3,$DefBk4)
            GUICtrlSetOnEvent ($ID,'_Explorer_GoTo')
        $ID = _ListViewCreate ($x,$y*3,$w-($x*2),$h-20)
        Return $hWnd
EndFunc
;==========================================================================
;==========================================================================
Func _Explorer_GoTo ()
    Local $Data = ControlGetText (@GUI_WinHandle,'','Edit1')
    If DriveStatus ($Data) = 'READY' Then
        If WinExists ($chr & $Data & $chr) Then Return
        WinSetTitle (@GUI_WinHandle,'',$chr & $Data & $chr)
    Else
        Return
    EndIf
EndFunc
;==========================================================================
;==========================================================================
Func _Explorer_Back ()
    Local $Data = StringTrimLeft (StringTrimRight (WinGetTitle (@GUI_WinHandle),1),1)
    Do
        $Data = StringTrimRight ($Data,1)
    Until StringRight ($Data,1) = '\' Or  StringLen ($Data) = 1
    If StringLen ($Data) = 1 Then Return
    $Data = StringTrimRight ($Data,1)
    WinSetTitle (@GUI_WinHandle,'',$chr & $Data & $chr)
EndFunc
;==========================================================================
;==========================================================================
Func _Explorer_Action ()
    Local $File, $Temp,$hWnd,$Ex
    $CtrlData = GUICtrlRead (@GUI_CtrlId)
    $File = StringTrimLeft (StringTrimRight (WinGetTitle ($hWnd),1),1) & '\' & $CtrlData
    If StringInStr (FileGetAttrib ($File),'D') Then
        If WinExists ($chr & $File & $chr) Then Return
        $hWnd = @GUI_WinHandle
        WinSetTitle ($hWnd,'',$chr & $File & $chr)
    Else
        If FileExists ($File) Then ShellExecute ($File)
        Return
    EndIf
    Return
EndFunc
;==========================================================================
;==========================================================================
Func _WinCreate ($Title,$w=$DefW,$h=$DefH)
    Local $hWnd,$ButtonWH,$hWnd_Parent
    $Title = $chr & $Title & $chr
    $TitleBarH = 30
    $ButtonWH = Int ($TitleBarH/1.5)
    $Pw = $w+($TitleBarH)
    $Ph = Int ($h+($TitleBarH*1.2))
    $hWnd = GUICreate ($Title,$w,$h,-1,-1,$Style,$ExStyle)
;~         ===================================================
        $ID = GUICtrlCreateLabel ($Title,0,0,$w-($ButtonWH*2),$ButtonWH*2,$CenterStyle,$GUI_WS_EX_PARENTDRAG)
            GUICtrlCreateLabel ('',0,$ButtonWH*2,$ButtonWH,$h-($ButtonWH*2),-1,$GUI_WS_EX_PARENTDRAG)
            GUICtrlCreateLabel ('',$w-$ButtonWH,$ButtonWH*2,$ButtonWH,$h-($ButtonWH*2),-1,$GUI_WS_EX_PARENTDRAG)
            GUICtrlCreateLabel ('',0,$h-$ButtonWH,$w,$h-($ButtonWH*3),-1,$GUI_WS_EX_PARENTDRAG)
        GUICtrlSetFont ($ID,$FontSize,$FontWeight,'',$FontName)
        GUICtrlSetColor ($ID,$GUI_FontColor)
;~         ===================================================
        $ID = _ButtonCreate ('_',$w-($ButtonWH*2),0,$ButtonWH,$ButtonWH,-1,-1)
        GUICtrlSetColor ($ID,$GUI_FontColor)
        GUICtrlSetOnEvent ($ID,'_WinMin')
        $ID = _ButtonCreate ('X',$w-$ButtonWH,0,$ButtonWH,$ButtonWH,-1,-1)
        GUICtrlSetColor ($ID,$GUI_FontColor)
        GUICtrlSetOnEvent ($ID,'_WinClose')
        
    GUISetBkColor ($GUI_bk,$hWnd_Parent)
    GUISetOnEvent ($GUI_EVENT_CLOSE,'_WinClose',$hWnd)
    GUISetState ()
    WinSetTrans ($hWnd,'',$Trans)
    Return $hWnd
EndFunc
;==========================================================================
;==========================================================================
Func _BackgroundCreate ($x,$y,$w,$h,$top=$DefBk1,$bottom=$DefBk2)
    Local $CtrlID
    $CtrlID = GUICtrlCreateLabel ('',$x,$y,$w,Int ($h/2))
    GUICtrlSetState ($CtrlID,$gui_disable)
    GUICtrlSetBkColor ($CtrlID,$top)
    $CtrlID = GUICtrlCreateLabel ('',$x,Int ($y+($h/2)),$w,Int ($h/2))
    GUICtrlSetState ($CtrlID,$gui_disable)
    GUICtrlSetBkColor ($CtrlID,$bottom)
    Return
EndFunc
;==========================================================================
;==========================================================================
Func _ButtonCreate ($Text,$x,$y,$w,$h,$top=$DefBk1,$bottom=$DefBk2)
    Local $CtrlID
    _BackgroundCreate ($x,$y,$w,$h,$top,$bottom)
    $CtrlID = GUICtrlCreateLabel ($Text,$x,$y,$w,$h,$CenterStyle)
    GUICtrlSetBkColor ($CtrlID,$GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetFont ($CtrlID,$FontSize,$FontWeight,'',$FontName)
    GUICtrlSetColor ($CtrlID,$FontColor)
    GUICtrlSetCursor ($CtrlID,0)
    Return $CtrlID
EndFunc
;==========================================================================
;==========================================================================
Func _WinMin ()
    Local $hWnd
    $hWnd = @GUI_WinHandle
    GUISetState (@SW_MINIMIZE,$hWnd)
    Return
EndFunc
;==========================================================================
;==========================================================================
Func _Closing_Transparency ($hWnd)
    For $count = $Trans To 0 Step -10
        WinSetTrans ($hWnd,'',$count)
        Sleep (10)
    Next
EndFunc
;==========================================================================
;==========================================================================
Func _WinClose ()
    Local $hWnd
    $hWnd = @GUI_WinHandle
    _Closing_Transparency ($hWnd)
    _Exit ()
EndFunc
;==========================================================================
;==========================================================================
Func _Exit ()
Exit
EndFunc

[edit] - irrelevant code

Edited by CodyBarrett
Link to comment
Share on other sites

well... using the _GuictrlListview_... functions.. and Imagelists.. i got the icon above the text working, though the icon is still as small as the first attempt i had was, even when the state of the icons are LARGE, it still looks small. AND i have a new problem, the icons are no longer working in OnEvent... :\ anyone know where i am going wrong?

EDIT: Okay.. i left it, and went back to it, i found out that adding a simple line "GUICtrlSetStyle($ID,0x0000) ;$LVS_ICON" was the issue, it works fine once i add that. :\ so much work and it was something so simple.. here is a working example.

#Include <WinAPI.au3>
Opt ('GuiOnEventMode',1)
$count = 0
$LastWindow = -1
_NewWindow ()
While True
WEnd
Func _WM_Active ($hWnd,$MsgID,$wParam,$lParam)
    Local $iIDFrom = BitAND($wParam, 0xFFFF)
    Local $iCode = BitShift($wParam, 16)
    Local $read
    If $LastWindow <> 0 And $LastWindow <> $hWnd Then
        WinSetTrans ($LastWindow,'',100)
        WinSetTrans ($hWnd,'',255)
        $LastWindow = $hWnd
    EndIf
EndFunc
Func _NewWindow ()
    Local $hWnd,$lhWnd,$GUI_CtrlID,$cIcon
    $cIcon = _WinAPI_ExtractIconEx (@SystemDir & '\Shell32.dll',-1,0,0,0)
    $count+=1
    GUICreate ('')
    $lhWnd = GUICtrlCreateListView ('',0,0,400,400)
        GUICtrlSetStyle($lhWnd, 0x0000)
    For $n = 1 To $cIcon
        $GUI_CtrlID = GUICtrlCreateListViewItem ($n,$lhWnd)
        GUICtrlSetImage ($GUI_CtrlID,@SystemDir & '\Shell32.dll',$n)
        GUICtrlSetOnEvent (-1,'_NewWindow')
    Next
    GUIRegisterMsg (0x0006,'_WM_Active')
    GUISetOnEvent (-3,'_CloseWindow')
    GUISetState ()
EndFunc
Func _CloseWindow ()
    $count -= 1
    GUIDelete (@GUI_WinHandle)
    If $count = 0 Then Exit
EndFunc
Edited by CodyBarrett
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...