Sign in to follow this  
Followers 0
enkriptix

Transparency?

12 posts in this topic

I want to know if, and how, I can create a completely invisible window that just shows the files and folders. I basically want it to be like you open a folder, and it looks like the contents are located on your desktop, but there is a border around it to show that it is in a folder. I also want to be able to get rid of the taskbar icon, and keep it behind all other windows. But I want people to be able to click on and open files/folders that are on it.


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites



you asking for at least 100+ lines of code here... GUISTYLES i would use like these

$WS_EX_TRANSPARENT

$WS_EX_TOOLWINDOW -> for the no taskbar

BitOr ($WS_POPUP, $WS_BORDER) -> for no titlebar

LOTS of options... GUIs are completely customizable if given enough code

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

That's simply.

If you want it fuly invisible you should use

GUISetState ( @SW_HIDE, $YourGUI )

this makes your GUI invisible and unable to find.

If you want to make it partly transparent, half or so something you should insert

WinSetTrans ( $YourGUI, $Value)

In this case $Value is anything between 0 to 255.

255 makes your GUI fully visible, 128 makes it half transparent, and 0 makes it invisible.

Edited by BNFTD

Share this post


Link to post
Share on other sites

That's simply.

If you want it fuly invisible you should use

GUISetState ( @SW_HIDE, $YourGUI )

this makes your GUI invisible and unable to find.

If you want to make it partly transparent, half or so something you should insert

WinSetTrans ( $YourGUI, $Value)

In this case $Value is anything between 0 to 255.

255 makes your GUI fully visible, 128 makes it half transparent, and 0 makes it invisible.

Thanks, that's what I was looking for except for one thing: I want the window fully invisible, but I want the contents fully visible, like showing the file/folder icon and the file/folder name.


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites

enkriptix,

A little searching (always a good idea ;-)) and a bit of modification produced this (with full credit to ProgAndy):

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WINAPI.au3>
#include <sendmessage.au3>

;Global Const $LWA_ALPHA = 0x2
;Global Const $LWA_COLORKEY = 0x1

HotKeySet("ESC", "_Exit")

$hGUI = GUICreate("Test", 500, 500, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)

GUICtrlCreateLabel("Click on the text to drag this transparent GUI" & @CRLF & "Press ESC to exit", 10, 10)

_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF, 250)

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            _SendMessage($hGUI, $WM_SYSCOMMAND, 0xF012, 0)
    EndSwitch

WEnd

Func _Exit()
    Exit
EndFunc

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
; #############################################
; You are NOT ALLOWED to remove the following lines
; Function Name: _WinAPI_SetLayeredWindowAttributes
; Author(s): Prog@ndy
; #############################################
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc  ;==>_WinAPI_SetLayeredWindowAttributes

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Adding on to Melba's post. I think this is what you are looking for.....It's a bit messy but it works.

filemanager.au3

Share this post


Link to post
Share on other sites

Thanks, that's just what I was looking for! Just one question: how can I allow users to open the files shown by double-clicking?


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites

Oh...I didn't know it had to work ^_^

Thought it was just the transparency you were after.

This script works with the mouse doubleclick. It's from the forum with only a few tweaks from myself. If someone can figure out how it make it respond to enter press that would be great.....

Anyways, enjoy.

#include <GuiImageList.au3>
#include <GUIListView.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include<Misc.au3>
$dll = DllOpen("user32.dll")
Global Const $tagSHFILEINFO = "dword hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];"
Global Const $SHGFI_USEFILEATTRIBUTES = 0x10
Global Const $SHGFI_SYSICONINDEX = 0x4000
Global Const $FILE_ATTRIBUTE_NORMAL = 0x80
Global Const $SHGFI_SMALLICON = 0x1
Global Const $SHGFI_LARGEICON = 0x0
Global $listison=1, $hListView1
Global Const $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, 0, 1)
Global Const $NOICON_ICON_INDEX = _GUIImageList_GetFileIconIndex("nb lgl", 0, 0)

Opt("GUIOnEventMode", 1)
Global $GUI_MAIN = GUICreate("File Manager", 388, 520, 193, 125, $WS_POPUP, $WS_EX_LAYERED)
GUISetOnEvent(-3,"GUI_Close")
GUISetBkColor(0xABCDEF,$GUI_MAIN)
Global $inpLocalDirectory = GUICtrlCreateInput("", 8, 0, 370, 20)
GUIctrlSetBkColor($inpLocalDirectory,0xABCDEF)
Global $hListView1 = GUICtrlCreateListView("Name|Date|Size", 8, 20, 370, 489)
GUIctrlSetBkColor($hListView1,0xABCDEF)
Global $SHELLLISTVIEWHANDLE = GUICtrlGetHandle($hListView1); Get the Handle

GUICtrlSendMsg($hListView1, 0x101E, 0, 200)
GUICtrlSendMsg($hListView1, 0x101E, 1, 75)
GUICtrlSendMsg($hListView1, 0x101E, 2, 50)
GUIRegisterMsg($WM_NOTIFY, "_SHLV_WM_NOTIFY")

_GUICtrlListView_SetImageList($hListView1, _GUIImageList_GetSystemImageList(), 1)
Global $DIRECTORY_LOCAL = ""; Start with Selection of drives smile.gif
_SHLV_PopulateLocalListView($SHELLLISTVIEWHANDLE,$DIRECTORY_LOCAL)
_WinAPI_SetLayeredWindowAttributes($GUI_MAIN, 0xABCDEF, 250)
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
            If _IsPressed("0D", $dll) and $listison=1 Then;enter pressed
                
            ElseIf _IsPressed("0D", $dll) and $listison=0 Then;enter pressed, inputbox selected
        EndIf
WEnd

Func GUI_Close()
    Exit
EndFunc

; Prog@ndy
Func _SHLV_PopulateLocalListView($hListView1,ByRef $DIRECTORY_LOCAL)
    If $DIRECTORY_LOCAL = "" Then
        Local $drives = DriveGetDrive("ALL")
        GUICtrlSetData($inpLocalDirectory, "Drive Selection")
        _GUICtrlListView_BeginUpdate($hListView1)
        _GUICtrlListView_DeleteAllItems($hListView1)
        For $i = 1 To $drives[0]
            _GUICtrlListView_AddItem($hListView1, StringUpper($drives[$i]) & "\", _GUIImageList_GetFileIconIndex($drives[$i] & "\"))
        Next
        _GUICtrlListView_EndUpdate($hListView1)
        Return
    EndIf
    If StringRight($DIRECTORY_LOCAL, 1) <> "\" Then $DIRECTORY_LOCAL &= "\"
    If DriveStatus(StringLeft($DIRECTORY_LOCAL, 3)) <> "READY" Then Return 0 * MsgBox(16 + 8192, 'Error on Drive Access', "Drive " & StringLeft($DIRECTORY_LOCAL, 3) & " not ready!")
    GUICtrlSetData($inpLocalDirectory, $DIRECTORY_LOCAL)
    $files = _SHLV__FileListToArray2($DIRECTORY_LOCAL, "*", 2)
    If UBound($files)==0 Then Return
    _GUICtrlListView_BeginUpdate($hListView1)
    _GUICtrlListView_DeleteAllItems($hListView1)
    _GUICtrlListView_SetItemCount($hListView1,$files[0])
    _GUICtrlListView_AddItem($hListView1, "[..]", 1)
    If IsArray($files) Then
        For $i = 1 To $files[0]
            $item = _GUICtrlListView_AddItem($hListView1, $files[$i], $FOLDER_ICON_INDEX)
            _GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FormatFilesize(DirGetSize($DIRECTORY_LOCAL & $files[$i], 2)), 2)
        Next
    EndIf
    Local $foldercount
    $files = _SHLV__FileListToArray2($DIRECTORY_LOCAL, "*", 1)
    _GUICtrlListView_EndUpdate($hListView1)
    _GUICtrlListView_BeginUpdate($hListView1)
    _GUICtrlListView_SetItemCount($hListView1,$files[0]+$foldercount)
    If IsArray($files) Then
        For $i = 1 To $files[0]
            $item = _GUICtrlListView_AddItem($hListView1, $files[$i], _GUIImageList_GetFileIconIndex($files[$i]))
            _GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FileDateString2Calc(FileGetTime($DIRECTORY_LOCAL & $files[$i], 0, 1)), 1)
            _GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FormatFilesize(FileGetSize($DIRECTORY_LOCAL & $files[$i])), 2)
        Next
    EndIf
    _GUICtrlListView_EndUpdate($hListView1)
EndFunc  ;==>_SHLV_PopulateLocalListView

; Prog@ndy
Func __SHLV_FormatFilesize($size)
    Select
        Case $size > 1000
            Return Round($size / 1024, 1) & " KB"
        Case $size > 1048500
            Return Round($size / 1048576, 1) & " MB"
        Case Else
            Return $size & " Byte"
    EndSelect
EndFunc  ;==>_FormatFilesize

; Prog@ndy
Func _GUIImageList_GetSystemImageList($bLargeIcons = False)
    Local $dwFlags, $hIml, $FileInfo = DllStructCreate($tagSHFILEINFO)
    $dwFlags = BitOR($SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX)
    If Not ($bLargeIcons) Then
        $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
    EndIf
    $hIml = _WinAPI_SHGetFileInfo(".txt", $FILE_ATTRIBUTE_NORMAL, _
            DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), $dwFlags)
    Return $hIml
EndFunc  ;==>_GUIImageList_GetSystemImageList

; Prog@ndy
Func _WinAPI_SHGetFileInfo($pszPath, $dwFileAttributes, $psfi, $cbFileInfo, $uFlags)
    Local $return = DllCall("shell32.dll", "DWORD*", "SHGetFileInfo", "str", $pszPath, "DWORD", $dwFileAttributes, "ptr", $psfi, "UINT", $cbFileInfo, "UINT", $uFlags)
    If @error Then Return SetError(@error, 0, 0)
    Return $return[0]
EndFunc  ;==>_WinAPI_SHGetFileInfo

; Prog@ndy
Func _GUIImageList_GetFileIconIndex($sFileSpec, $bLargeIcons = False, $bForceLoadFromDisk = False)
    Local $dwFlags, $FileInfo = DllStructCreate($tagSHFILEINFO)

    $dwFlags = $SHGFI_SYSICONINDEX
    If $bLargeIcons Then
        $dwFlags = BitOR($dwFlags, $SHGFI_LARGEICON)
    Else
        $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
    EndIf
    If Not $bForceLoadFromDisk Then
        $dwFlags = BitOR($dwFlags, $SHGFI_USEFILEATTRIBUTES)
    EndIf
    Local $lR = _WinAPI_SHGetFileInfo( _
            $sFileSpec, $FILE_ATTRIBUTE_NORMAL, DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), _
            $dwFlags _
            )

    If ($lR = 0) Then
        Return SetError(1, 0, -1)
    Else
        Return DllStructGetData($FileInfo, "iIcon")
    EndIf
EndFunc  ;==>_GUIImageList_GetFileIconIndex

; Author(s):   Prog@ndy
Func __SHLV_FileDateString2Calc($filedate)
    Return StringRegExpReplace($filedate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6")
EndFunc  ;==>_FileDateString2Calc
; Author(s):   Prog@ndy
Func __SHLV_CalcDate2FileDateString($calcdate)
    Return StringRegExpReplace($calcdate, "(\d{4})/(\d{2})/(\d{2}) (\d{2})sad.gif\d{2})sad.gif\d{2})", "$1$2$3$4$5$6")
EndFunc  ;==>_CalcDate2FileDateString

; Prog@ndy
Func _SHLV_WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hListView1 = $SHELLLISTVIEWHANDLE

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView1
            Switch $iCode
                Case $NM_DBLCLK; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    If _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index")) = "[..]" Then
                        Local $slash = StringInStr($DIRECTORY_LOCAL, "\", 1, -2)
                        If $slash Then
                            $DIRECTORY_LOCAL = StringLeft($DIRECTORY_LOCAL, $slash)
                        ElseIf StringRegExp($DIRECTORY_LOCAL, "\A[A-Za-z]:\\\Z") Then
                            $DIRECTORY_LOCAL = ""
                        EndIf
                        _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL)
                    ElseIf _GUICtrlListView_GetItemImage($hListView1, DllStructGetData($tInfo, "Index")) = $FOLDER_ICON_INDEX Then
                        $DIRECTORY_LOCAL &= _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"))
                        _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL)
                    ElseIf StringRegExp(_GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"), 0), "\A[A-Za-z]:\\\Z") Then
                        $DIRECTORY_LOCAL = _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"))
                        _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL)

                    else
                        ShellExecute($DIRECTORY_LOCAL&"\"&_GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index")))
                    EndIf
                   ; No return value
                Case $NM_KILLFOCUS
                    $listison=0
                Case $NM_SETFOCUS; The control has received the input focus
                    $listison=1
            EndSwitch
        EndSwitch



    Return $GUI_RUNDEFMSG
EndFunc  ;==>WM_NOTIFY

; Author ........: SolidSnake <MetalGX91 at GMail dot com>
; Modified by Prog@ndy
Func _SHLV__FileListToArray2($sPath, $sFilter = "*", $iFlag = 0)
    Local $hSearch, $sFile, $asFileList
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
    If (StringMid($sPath, StringLen($sPath), 1) = "\") Then $sPath = StringTrimRight($sPath, 1); needed for Win98 for x:\  root dir
    $hSearch = FileFindFirstFile($sPath & "\" & $sFilter)
    If $hSearch = -1 Then Return SetError(4, 4, "")
    While 1
        $sFile = FileFindNextFile($hSearch)
        If @error Then
            SetError(0)
            ExitLoop
        EndIf
        If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop
        If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop
        $asFileList &= $sFile & @CR
;~   ReDim $asFileList[UBound($asFileList) + 1]
;~   $asFileList[0] = $asFileList[0] + 1
;~   $asFileList[UBound($asFileList) - 1] = $sFile
    WEnd
    FileClose($hSearch)
    Return StringSplit(StringTrimRight($asFileList,1),@CR)
EndFunc  ;==>_SHLV__FileListToArray2

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
; #############################################
; You are NOT ALLOWED to remove the following lines
; Function Name: _WinAPI_SetLayeredWindowAttributes
; Author(s): Prog@ndy
; #############################################
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc ;==>_WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

Fantastic! Just what I was looking for! One more question... is there any way to remove the "Name Date Size" Header from view? Also, can I hide the file directory at the top? I just want it to show the files. Even if you can't, thanks for your help! I really appreciate it!


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
Share on other sites

This is about as transparent as you get.

Enjoy

#include <GuiImageList.au3>
#include <GUIListView.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include<Misc.au3>
$dll = DllOpen("user32.dll")
Global Const $tagSHFILEINFO = "dword hIcon; int iIcon; DWORD dwAttributes; CHAR szDisplayName[255]; CHAR szTypeName[80];"
Global Const $SHGFI_USEFILEATTRIBUTES = 0x10
Global Const $SHGFI_SYSICONINDEX = 0x4000
Global Const $FILE_ATTRIBUTE_NORMAL = 0x80
Global Const $SHGFI_SMALLICON = 0x1
Global Const $SHGFI_LARGEICON = 0x0
Global $listison=1, $hListView1
Global Const $FOLDER_ICON_INDEX = _GUIImageList_GetFileIconIndex(@SystemDir, 0, 1)
Global Const $NOICON_ICON_INDEX = _GUIImageList_GetFileIconIndex("nb lgl", 0, 0)

Opt("GUIOnEventMode", 1)
Global $GUI_MAIN = GUICreate("File Manager", 388, 520, 193, 125, $WS_POPUP, $WS_EX_LAYERED)
GUISetOnEvent(-3,"GUI_Close")
GUISetBkColor(0xABCDEF,$GUI_MAIN)
;Global $inpLocalDirectory = GUICtrlCreateInput("", 8, 0, 370, 20)
;GUIctrlSetBkColor($inpLocalDirectory,0xABCDEF)
Global $hListView1 = GUICtrlCreateListView("Name|Date|Size", 8, 20, 370, 489,$LVS_NOCOLUMNHEADER,$WS_EX_TRANSPARENT)
GUIctrlSetBkColor($hListView1,0xABCDEF)
Global $SHELLLISTVIEWHANDLE = GUICtrlGetHandle($hListView1); Get the Handle

GUICtrlSendMsg($hListView1, 0x101E, 0, 200)
GUICtrlSendMsg($hListView1, 0x101E, 1, 75)
GUICtrlSendMsg($hListView1, 0x101E, 2, 50)
GUIRegisterMsg($WM_NOTIFY, "_SHLV_WM_NOTIFY")

_GUICtrlListView_SetImageList($hListView1, _GUIImageList_GetSystemImageList(), 1)
Global $DIRECTORY_LOCAL = ""; Start with Selection of drives smile.gif
_SHLV_PopulateLocalListView($SHELLLISTVIEWHANDLE,$DIRECTORY_LOCAL)
_WinAPI_SetLayeredWindowAttributes($GUI_MAIN, 0xABCDEF, 250)
GUISetState(@SW_SHOW)


While 1
    Sleep(100)
            If _IsPressed("0D", $dll) and $listison=1 Then;enter pressed
                
            ElseIf _IsPressed("0D", $dll) and $listison=0 Then;enter pressed, inputbox selected
        EndIf
WEnd

Func GUI_Close()
    Exit
EndFunc

; Prog@ndy
Func _SHLV_PopulateLocalListView($hListView1,ByRef $DIRECTORY_LOCAL)
    If $DIRECTORY_LOCAL = "" Then
        Local $drives = DriveGetDrive("ALL")
;      GUICtrlSetData($inpLocalDirectory, "Drive Selection")
        _GUICtrlListView_BeginUpdate($hListView1)
        _GUICtrlListView_DeleteAllItems($hListView1)
        For $i = 1 To $drives[0]
            _GUICtrlListView_AddItem($hListView1, StringUpper($drives[$i]) & "\", _GUIImageList_GetFileIconIndex($drives[$i] & "\"))
        Next
        _GUICtrlListView_EndUpdate($hListView1)
        Return
    EndIf
    If StringRight($DIRECTORY_LOCAL, 1) <> "\" Then $DIRECTORY_LOCAL &= "\"
    If DriveStatus(StringLeft($DIRECTORY_LOCAL, 3)) <> "READY" Then Return 0 * MsgBox(16 + 8192, 'Error on Drive Access', "Drive " & StringLeft($DIRECTORY_LOCAL, 3) & " not ready!")
;   GUICtrlSetData($inpLocalDirectory, $DIRECTORY_LOCAL)
    $files = _SHLV__FileListToArray2($DIRECTORY_LOCAL, "*", 2)
    If UBound($files)==0 Then Return
    _GUICtrlListView_BeginUpdate($hListView1)
    _GUICtrlListView_DeleteAllItems($hListView1)
    _GUICtrlListView_SetItemCount($hListView1,$files[0])
    _GUICtrlListView_AddItem($hListView1, "[..]", 1)
    If IsArray($files) Then
        For $i = 1 To $files[0]
            $item = _GUICtrlListView_AddItem($hListView1, $files[$i], $FOLDER_ICON_INDEX)
            _GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FormatFilesize(DirGetSize($DIRECTORY_LOCAL & $files[$i], 2)), 2)
        Next
    EndIf
    Local $foldercount
    $files = _SHLV__FileListToArray2($DIRECTORY_LOCAL, "*", 1)
    _GUICtrlListView_EndUpdate($hListView1)
    _GUICtrlListView_BeginUpdate($hListView1)
    _GUICtrlListView_SetItemCount($hListView1,$files[0]+$foldercount)
    If IsArray($files) Then
        For $i = 1 To $files[0]
            $item = _GUICtrlListView_AddItem($hListView1, $files[$i], _GUIImageList_GetFileIconIndex($files[$i]))
            _GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FileDateString2Calc(FileGetTime($DIRECTORY_LOCAL & $files[$i], 0, 1)), 1)
            _GUICtrlListView_AddSubItem($hListView1, $item, __SHLV_FormatFilesize(FileGetSize($DIRECTORY_LOCAL & $files[$i])), 2)
        Next
    EndIf
    _GUICtrlListView_EndUpdate($hListView1)
EndFunc ;==>_SHLV_PopulateLocalListView

; Prog@ndy
Func __SHLV_FormatFilesize($size)
    Select
        Case $size > 1000
            Return Round($size / 1024, 1) & " KB"
        Case $size > 1048500
            Return Round($size / 1048576, 1) & " MB"
        Case Else
            Return $size & " Byte"
    EndSelect
EndFunc ;==>_FormatFilesize

; Prog@ndy
Func _GUIImageList_GetSystemImageList($bLargeIcons = False)
    Local $dwFlags, $hIml, $FileInfo = DllStructCreate($tagSHFILEINFO)
    $dwFlags = BitOR($SHGFI_USEFILEATTRIBUTES, $SHGFI_SYSICONINDEX)
    If Not ($bLargeIcons) Then
        $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
    EndIf
    $hIml = _WinAPI_SHGetFileInfo(".txt", $FILE_ATTRIBUTE_NORMAL, _
            DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), $dwFlags)
    Return $hIml
EndFunc ;==>_GUIImageList_GetSystemImageList

; Prog@ndy
Func _WinAPI_SHGetFileInfo($pszPath, $dwFileAttributes, $psfi, $cbFileInfo, $uFlags)
    Local $return = DllCall("shell32.dll", "DWORD*", "SHGetFileInfo", "str", $pszPath, "DWORD", $dwFileAttributes, "ptr", $psfi, "UINT", $cbFileInfo, "UINT", $uFlags)
    If @error Then Return SetError(@error, 0, 0)
    Return $return[0]
EndFunc ;==>_WinAPI_SHGetFileInfo

; Prog@ndy
Func _GUIImageList_GetFileIconIndex($sFileSpec, $bLargeIcons = False, $bForceLoadFromDisk = False)
    Local $dwFlags, $FileInfo = DllStructCreate($tagSHFILEINFO)

    $dwFlags = $SHGFI_SYSICONINDEX
    If $bLargeIcons Then
        $dwFlags = BitOR($dwFlags, $SHGFI_LARGEICON)
    Else
        $dwFlags = BitOR($dwFlags, $SHGFI_SMALLICON)
    EndIf
    If Not $bForceLoadFromDisk Then
        $dwFlags = BitOR($dwFlags, $SHGFI_USEFILEATTRIBUTES)
    EndIf
    Local $lR = _WinAPI_SHGetFileInfo( _
            $sFileSpec, $FILE_ATTRIBUTE_NORMAL, DllStructGetPtr($FileInfo), DllStructGetSize($FileInfo), _
            $dwFlags _
            )

    If ($lR = 0) Then
        Return SetError(1, 0, -1)
    Else
        Return DllStructGetData($FileInfo, "iIcon")
    EndIf
EndFunc ;==>_GUIImageList_GetFileIconIndex

; Author(s):   Prog@ndy
Func __SHLV_FileDateString2Calc($filedate)
    Return StringRegExpReplace($filedate, "(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})", "$1/$2/$3 $4:$5:$6")
EndFunc ;==>_FileDateString2Calc
; Author(s):   Prog@ndy
Func __SHLV_CalcDate2FileDateString($calcdate)
    Return StringRegExpReplace($calcdate, "(\d{4})/(\d{2})/(\d{2}) (\d{2})sad.gif\d{2})sad.gif\d{2})", "$1$2$3$4$5$6")
EndFunc ;==>_CalcDate2FileDateString

; Prog@ndy
Func _SHLV_WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $hListView1 = $SHELLLISTVIEWHANDLE

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hListView1
            Switch $iCode
                Case $NM_DBLCLK; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    If _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index")) = "[..]" Then
                        Local $slash = StringInStr($DIRECTORY_LOCAL, "\", 1, -2)
                        If $slash Then
                            $DIRECTORY_LOCAL = StringLeft($DIRECTORY_LOCAL, $slash)
                        ElseIf StringRegExp($DIRECTORY_LOCAL, "\A[A-Za-z]:\\\Z") Then
                            $DIRECTORY_LOCAL = ""
                        EndIf
                        _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL)
                    ElseIf _GUICtrlListView_GetItemImage($hListView1, DllStructGetData($tInfo, "Index")) = $FOLDER_ICON_INDEX Then
                        $DIRECTORY_LOCAL &= _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"))
                        _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL)
                    ElseIf StringRegExp(_GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"), 0), "\A[A-Za-z]:\\\Z") Then
                        $DIRECTORY_LOCAL = _GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index"))
                        _SHLV_PopulateLocalListView($hListView1,$DIRECTORY_LOCAL)

                    else
                        ShellExecute($DIRECTORY_LOCAL&"\"&_GUICtrlListView_GetItemText($hListView1, DllStructGetData($tInfo, "Index")))
                    EndIf
                  ; No return value
                Case $NM_KILLFOCUS
                    $listison=0
                Case $NM_SETFOCUS; The control has received the input focus
                    $listison=1
            EndSwitch
        EndSwitch



    Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY

; Author ........: SolidSnake <MetalGX91 at GMail dot com>
; Modified by Prog@ndy
Func _SHLV__FileListToArray2($sPath, $sFilter = "*", $iFlag = 0)
    Local $hSearch, $sFile, $asFileList
    If Not FileExists($sPath) Then Return SetError(1, 1, "")
    If (StringInStr($sFilter, "\")) Or (StringInStr($sFilter, "/")) Or (StringInStr($sFilter, ":")) Or (StringInStr($sFilter, ">")) Or (StringInStr($sFilter, "<")) Or (StringInStr($sFilter, "|")) Or (StringStripWS($sFilter, 8) = "") Then Return SetError(2, 2, "")
    If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "")
    If (StringMid($sPath, StringLen($sPath), 1) = "\") Then $sPath = StringTrimRight($sPath, 1); needed for Win98 for x:\  root dir
    $hSearch = FileFindFirstFile($sPath & "\" & $sFilter)
    If $hSearch = -1 Then Return SetError(4, 4, "")
    While 1
        $sFile = FileFindNextFile($hSearch)
        If @error Then
            SetError(0)
            ExitLoop
        EndIf
        If $iFlag = 1 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") <> 0 Then ContinueLoop
        If $iFlag = 2 And StringInStr(FileGetAttrib($sPath & "\" & $sFile), "D") = 0 Then ContinueLoop
        $asFileList &= $sFile & @CR
;~   ReDim $asFileList[UBound($asFileList) + 1]
;~   $asFileList[0] = $asFileList[0] + 1
;~   $asFileList[UBound($asFileList) - 1] = $sFile
    WEnd
    FileClose($hSearch)
    Return StringSplit(StringTrimRight($asFileList,1),@CR)
EndFunc ;==>_SHLV__FileListToArray2

Func _WinAPI_SetLayeredWindowAttributes($hwnd, $i_transcolor, $Transparency = 255, $dwFlages = 0x03, $isColorRef = False)
; #############################################
; You are NOT ALLOWED to remove the following lines
; Function Name: _WinAPI_SetLayeredWindowAttributes
; Author(s): Prog@ndy
; #############################################
    If $dwFlages = Default Or $dwFlages = "" Or $dwFlages < 0 Then $dwFlages = 0x03

    If Not $isColorRef Then
        $i_transcolor = Hex(String($i_transcolor), 6)
        $i_transcolor = Execute('0x00' & StringMid($i_transcolor, 5, 2) & StringMid($i_transcolor, 3, 2) & StringMid($i_transcolor, 1, 2))
    EndIf
    Local $Ret = DllCall("user32.dll", "int", "SetLayeredWindowAttributes", "hwnd", $hwnd, "long", $i_transcolor, "byte", $Transparency, "long", $dwFlages)
    Select
        Case @error
            Return SetError(@error, 0, 0)
        Case $Ret[0] = 0
            Return SetError(4, _WinAPI_GetLastError(), 0)
        Case Else
            Return 1
    EndSelect
EndFunc;==>_WinAPI_SetLayeredWindowAttributes

Share this post


Link to post
Share on other sites

thanks so much! this is great!


Free software reviews, suggestions, and computer help: The Free Man's Blog.

Share this post


Link to post
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
Sign in to follow this  
Followers 0