Sign in to follow this  
Followers 0
Influx

movable controls, getting app icons

10 posts in this topic

Ok well i want to first be able to get the icon of a file.

Then i want to place a label under it with the file's name, and i want them to be grouped together so they move as one control.(could this be done by maybe drawing some sort of custom control with GDI? i am very unexperienced with GDI so i dont know)

now the real toughy. I am trying to make a mock desktop, and i am using on event mode.

I want to replicate a desktop and alllow the icons to be moved.

Thanks,

Influx.

Share this post


Link to post
Share on other sites



Ok well i want to first be able to get the icon of a file.

Then i want to place a label under it with the file's name, and i want them to be grouped together so they move as one control.(could this be done by maybe drawing some sort of custom control with GDI? i am very unexperienced with GDI so i dont know)

now the real toughy. I am trying to make a mock desktop, and i am using on event mode.

I want to replicate a desktop and alllow the icons to be moved.

Thanks,

Influx.

all of that can be done with listviews (try the style $LVS_ICON)


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites

thanks. =] now i just have to firue out how to make them movable.

Share this post


Link to post
Share on other sites

no... i lied i haveno idea how to place icons with names under them.

Ok so i get that i have to get all the filesto an array, but them how do i put them in the listview and make them movable and give the list view a transparent background.

Share this post


Link to post
Share on other sites

help anyone?

Share this post


Link to post
Share on other sites

Hi, here's a really poor snippet I ripped from one of my prior projects.

Sorry it's not commented, it's poorly written and messy..

But maybe you can sift through the mess of it and compare against AuoIt's help file and peice together the info you need to get your task done.

#Include <GuiConstantsEx.au3>
#Include <WindowsConstants.au3>
#include <Constants.au3>
#Include <GuiListView.au3>
#Include <GuiImageList.au3>
#include <WinAPI.au3>
#include <File.au3>


Opt("GUIOnEventMode", 1)

Global $apw = @DesktopWidth, $aph = @DesktopHeight, $GIP
Global $DeskBkClr = 0x000000, $TextClr = 0xffffff
Global $GetIconOrg = GetIconPos(), $Desktop, $hImage, $aDrag[3], $DragState
$aDrag[0] = -1

$Gui = GuiCreate("", $apw, $aph, 0, 0, $WS_POPUP);, $WS_EX_TOPMOST
GuiSetBkColor($DeskBkClr, $Gui)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event", $Gui)
GUISetOnEvent($GUI_EVENT_SECONDARYDOWN, "Event", $Gui)
GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "Event", $Gui)
GUISetOnEvent($GUI_EVENT_PRIMARYUP, "Event", $Gui)
GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "Event", $Gui)

$Desktop = _GUICtrlListView_Create ($Gui, "", 0, 0, $apw, $aph, BitOR($LVS_ICON,$LVS_SINGLESEL,$LVS_NOSCROLL))
_GUICtrlListView_SetExtendedListViewStyle ($Desktop, $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER)
_GUICtrlListView_SetBkColor($Desktop, $DeskBkClr)
_GUICtrlListView_SetTextColor($Desktop, $TextClr)
_GUICtrlListView_SetTextBkColor($Desktop, $CLR_NONE)

$hImage = _GUIImageList_Create (32, 32, 5, 3)
_AddIcon($hImage, @SystemDir & "\shell32.dll", 15);My Computer 0
_AddIcon($hImage, @SystemDir & "\shell32.dll", 17);My Network Places 1
_AddIcon($hImage, @SystemDir & "\shell32.dll", 31);Recycle Empty 2
_AddIcon($hImage, @SystemDir & "\shell32.dll", 126);My Docs 3
_AddIcon($hImage, @SystemDir & "\shell32.dll", 32);Recycle Full 4
_GUICtrlListView_SetImageList ($Desktop, $hImage, 0)

LoadSCOrg()
GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    Sleep(10)
WEnd

Func Event()
    Switch @GUI_CtrlId
        Case $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            If $aDrag[0] <> -1  Then
                $DragState = 1
                _GUICtrlListView_DrawDragImage($Desktop, $aDrag)
            EndIf
        Case $GUI_EVENT_MOUSEMOVE
            If $DragState Then _GUICtrlListView_DrawDragImage($Desktop, $aDrag)
        Case $GUI_EVENT_PRIMARYUP
            If $DragState Then
                $DragState = 0
                Local $MGP = MouseGetPos()
                If $MGP[0] > ($apw - 54) Then $MGP[0] = ($apw - 54)
                If $MGP[1] > ($aph -80) Then $MGP[1] = ($aph -80)               
                _GUICtrlListView_BeginUpdate($Desktop)
                _GUICtrlListView_SetItemPosition32($Desktop, _GUICtrlListView_GetNextItem($Desktop) , $MGP[0], $MGP[1])
                _GUICtrlListView_EndUpdate($Desktop)
                $aDrag[0] = -1
            EndIf
    EndSwitch
EndFunc

Func LoadSCOrg()
    Local $SPIN = StringSplit("My Computer|My Network Places|Recycle Bin|My Documents", "|")
    _GUICtrlListView_BeginUpdate($Desktop)
    For $i = 1 To $SPIN[0]
        For $j = 1 To $GetIconOrg[0][0]
            If $GetIconOrg[$j][0] = $SPIN[$i] Then 
                _GUICtrlListView_AddItem($Desktop, $GetIconOrg[$j][0], $i - 1)
                Local $FT = _GUICtrlListView_FindText($Desktop, $GetIconOrg[$j][0], -1, FALSE)
                _GUICtrlListView_SetItemPosition32($Desktop, $FT, $GetIconOrg[$j][1], $GetIconOrg[$j][2])   
  
            EndIf
        Next
    Next
    For $j = 1 To $GetIconOrg[0][0]    
        If $GetIconOrg[$j][3] <> "" Then
                Local $FGS = FileGetShortcut($GetIconOrg[$j][3])
                If Not @error Then
                    ConsoleWrite($FGS[0] & @LF)
                    If StringRight($FGS[0], 4) = ".exe" Or StringRight($FGS[0], 4) = ".dll" Then
                    _AddIcon($hImage, $FGS[0], 0)
                    _GUICtrlListView_AddItem($Desktop, $GetIconOrg[$j][0], _GUIImageList_GetImageCount($hImage) - 1)
                    Local $FT = _GUICtrlListView_FindText($Desktop, $GetIconOrg[$j][0], -1, FALSE)
                   _GUICtrlListView_SetItemPosition32($Desktop, $FT, $GetIconOrg[$j][1], $GetIconOrg[$j][2])
                   EndIf
               EndIf
           EndIf
    Next       
    _GUICtrlListView_EndUpdate($Desktop)
EndFunc 

Func _AddIcon($hWnd, $sFile, $iIndex = 0)
    Local $pIcon, $tIcon, $iResult, $hIcon
    $tIcon = DllStructCreate("int Icon")
    $pIcon = DllStructGetPtr($tIcon)
    $iResult = _WinAPI_ExtractIconEx ($sFile, $iIndex, $pIcon, 0, 1)
    $hIcon = DllStructGetData($tIcon, "Icon")
    $iResult = _GUIImageList_ReplaceIcon ($hWnd, -1, $hIcon)
    _WinAPI_DestroyIcon($hIcon)
EndFunc

Func GetIconPos()
    Local $hWnd = ControlGetHandle("Program Manager", "", "[CLASS:SysListView32; INSTANCE:1]")
    If @error Then Return 0
    Dim $GIP[_GUICtrlListView_GetItemCount($hWnd)+1][6]
    If Not IsArray($GIP) Then Return 0 
    $GIP[0][0] = UBound($GIP) -1
    For $i = 1 To $GIP[0][0]
        $GIP[$i][0] = _GUICtrlListView_GetItemText($hWnd, $i -1)
        $GIP[$i][1] = _GUICtrlListView_GetItemPositionX($hWnd, $i -1)
        $GIP[$i][2] = _GUICtrlListView_GetItemPositionY($hWnd, $i -1)
    Next
    ShortCutCompare(@DesktopDir, $GIP)
    ShortCutCompare(@DesktopCommonDir, $GIP)
    Return $GIP
EndFunc

Func ShortCutCompare($iPath, ByRef $aComp)
    Local $FL2A = _FileListToArray($iPath, "*")
    If Not @error Then
        For $i = 1 To $FL2A[0]
            For $j = 1 To $GIP[0][0]
                If $aComp[$j][0] = StringTrimRight($FL2A[$i], 4) Or $GIP[$j][0] = $FL2A[$i] Then
                    $aComp[$j][3] = $iPath & "\" & $FL2A[$i]
                EndIf
            Next
        Next
    EndIf
EndFunc
    
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $Desktop
    If Not IsHWnd($Desktop) Then $hWndListView = GUICtrlGetHandle($Desktop)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndListView
            Switch $iCode
                Case $LVN_BEGINDRAG
                    Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    $aDrag = _GUICtrlListView_CreateDragImage ($Desktop, DllStructGetData($tInfo, "Item"))
                    Return 0
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
The above code I've only run in English XP SP3 x86 with Autoit v3.2.12.1.

Cheers

Share this post


Link to post
Share on other sites

I think he's gonna love you for that. Maybe even... you know.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

HAHAHAHAHA

THANK YOU THANKS THANK YOU THANK YOU =D

Ok, when i use a image(even if i use disable and place it before everything else)

no icons show up, what am i doing wrong, also, these icons arnt supposed to work, correct?

one last thing, how would i make the backgrounds transparent (for using images as the background)

Edit: also the icnons leave what appears to be a copy of themselves below the place where they are dropped(looks as if the lines arround the text got stuck there) if you want will shot a screen shot.

Edited by Influx

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

HAHAHAHAHA

THANK YOU THANKS THANK YOU THANK YOU =D

Ok, when i use a image(even if i use disable and place it before everything else)

no icons show up, what am i doing wrong, also, these icons arnt supposed to work, correct?

one last thing, how would i make the backgrounds transparent (for using images as the background)

Edit: also the icnons leave what appears to be a copy of themselves below the place where they are dropped(looks as if the lines arround the text got stuck there) if you want will shot a screen shot.

Your welcome, but as I said the snippet of code I posted is messy and poorly written..

The idea of me posting the snippet was so that you could maybe get some ideas and a starting point on how to tackle what your trying to do.

To use an image as a wallpaper you will need to set the co-initialize flag to true in _GUICtrlListView_Create().

Then you can use _GUICtrlListView_SetBkImage() to set an image as a backdrop.

It'd be best to start looking in autoit's help file under the "User Defined Functions -> GuiListView Management" and see what you can come up with.

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

thanks, does autoit suport transparent GIF files? i want a background for the desktop and the list view items to be transparent (just have icon and text and eb on a desktop that has a background) lol, will do some testing, but ight now i dont have photoshop so can someone supply with a transparent .gif file?

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