Jump to content

Structs, Structs, and more Structs


Recommended Posts

When you delcare your struct it would be like:

$struct = DllStructCreate("uint;int;ptr;ptr;" & $RECT_Struct & ";int;ptr;int")
oÝ÷ Ùhbr(ºW[^±©jÆ®¶­s`¢b33c·7G'V7BÒFÆÅ7G'V7D7&VFRgV÷C·VçC¶çC·G#·G#¶çC¶çC¶çC¶çC¶çC·G#¶çBgV÷C²

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I figured out how to do:

$struct = DllStructCreate("uint;int;ptr;ptr;int;int[4];int;ptr;int")

simplifies my coding a little, but then again figured out that it is easier to grab the pointer to the tooltip text than it is to create your own tooltip.

Now I just need to get it to work in the primary script, instead of only working in my junk/test script.

PM me if you think you might be able to help. My topics get lost in the forums pretty fast.

Link to comment
Share on other sites

I figured out how to do:

$struct = DllStructCreate("uint;int;ptr;ptr;int;int[4];int;ptr;int")

simplifies my coding a little, but then again figured out that it is easier to grab the pointer to the tooltip text than it is to create your own tooltip.

Now I just need to get it to work in the primary script, instead of only working in my junk/test script.

PM me if you think you might be able to help. My topics get lost in the forums pretty fast.

Didn't want to confuse you with the int[4], but guess I don't have to worry about that.

If you have a working test/junk script, please post, would be willing to see if we can make it work with a larger script.

Gary

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Works: <Junk.au3>

Doesn't Work: <Track File Size.au3>

Only parts with problems in "Track File Size" are these:

WM_Notify_Events

I can't trace the array problem that I have currently.

(Most code that is commented out is either nonworking or debug code.)

To reproduce the array problem, add at least 2 items to the listview. <Track File Size.au3>

Junk.au3

Edited by amanda089
Link to comment
Share on other sites

The following will show you where the problem is, the ToolTip is working, just look at what is being set for the tip

For $i = 0 To (UBound($aSizeCalculations)-1) Step 1
                            If $aFileList[$__FileId][4] == $aSizeCalculations[$i][1] Then
                                $__FileFullSizeDesignation = $aSizeCalculations[$i][2]
                                If ($aFileList[$__FileId][3]/$aSizeCalculations[$i][0]) >= 1 Then $__FileFullSizeDesignation &= "s" ;Pluralize as needed
                                $TipString =    String($aFileList[$__FileId][1] & $aFileList[$__FileId][2] &@CRLF&  $aFileList[$__FileId][3] & " " & $__FileFullSizeDesignation)
                            EndIf
                        Next
                        ConsoleWrite("TipString: " & $TipString & @LF)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Made some minor changes:

Dim $aFileList[1][5]        ;Array of tracked files
$aFileList[0][0] = 0
oÝ÷ Ú)Ìj)ÚºÚ"µÍBBBBTQ[H    ÌÍØQ[SÝÕPÝ[
    ÌÍØQ[SÝ
JÌWVÍWBBBBBIÌÍØQ[SÝÌVÌH
ÏHBoÝ÷ ØÖ0Ú-ü½éí±«­¢+Ø(%1½°ÀÌØí}}¥±%ô±±MÑÉÕÑÑÑ ÀÌØíÑ°Ô¤¬ÄoÝ÷ Ù©Ýjëh×6
                    If $aFileList[0][0] > 0 Then

Now it works:

Gary

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Local $tmp = GUICtrlCreateListViewItem($sFile & "|" & StringFormat("%.2f",$aSize[0]) & "|" & $aSize[1],$listview)
oÝ÷ Ù«­¢+Ø($$$$$$$$ÀÌØíQ¥ÁMÑÉ¥¹ô%MÑÉ¥¹ ÀÌØí¥±1¥ÍÑlÀÌØí}}¥±%ulÅtµÀìÀÌØí¥±1¥ÍÑlÀÌØí}}¥±%ulÉtµÀí
I1µÀì%MÑÉ¥¹½ÉµÐ ÅÕ½Ðì¸ÉÅÕ½Ðì°ÀÌØí¥±1¥ÍÑlÀÌØí}}¥±%ulÍt¤µÀìÅÕ½ÐìÅÕ½ÐìµÀìÀÌØí}}¥±Õ±±M¥éÍ¥¹Ñ¥½¸¤

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Thanks

Now I just need to figure out how to code an adlib that can update the filesizes at least 10 times a second for 1-100+ files without a major performance impact.

yw, good job on the tooltip, thought of using the ToolTip handle also, but was determined to use LVM_SETINFOTIP.

Gary

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

lol, just take a look at my <Junk.au3>

Has all the code to create a custom ToolTip window and some code for setting the struct data.

BTW, Gary, is there any way to stop your _GUICtrlListViewSort() function from striping .00 from numerical item data?

Link to comment
Share on other sites

lol, just take a look at my <Junk.au3>

Has all the code to create a custom ToolTip window and some code for setting the struct data.

BTW, Gary, is there any way to stop your _GUICtrlListViewSort() function from striping .00 from numerical item data?

that's just a simple sort

suggest using GUICtrlRegisterListViewSort

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Cool, didn't even know that function was there.

Sidenote: Wish there was a way of encapsulating functions, like a class structure. Maybe then I wouldn't get lost in my code so much. But thats probably too much to wish for, and it would bring AutoIt into more of programming language instead of a macro language.

Link to comment
Share on other sites

I grabbed the example for GUICtrlRegisterListViewSort, and I have no idea how I am going to be able to correctly sort column 2 (0-based, KB/etc column) correctly (B, KB, MB, GB, TB) then sort by column 1 (size)...

Col 0: name, size, (B, KB, etc)

Col 1: size, (B, KB, etc), name

Col 2: (B, KB, etc), size, name

Link to comment
Share on other sites

Try:

; Our sorting callback funtion
Func LVSort($hWnd, $nItem1, $nItem2, $nColumn)
    Local $nSort

    ; Switch the sorting direction
    If $nColumn = $nCurCol Then
        If Not $bSet Then
            $nSortDir = $nSortDir * - 1
            $bSet = 1
        EndIf
    Else
        $nSortDir = 1
    EndIf
    $nCol = $nColumn

    $val1 = GetSubItemText($listview, $nItem1, $nColumn)
    $val2 = GetSubItemText($listview, $nItem2, $nColumn)
    $val3 = 0
    $val4 = 0

    ; If it is the 2nd colum (columns starts with 0)
    If $nColumn = 1 Then
        $val3 = GetSubItemText($listview, $nItem1, $nColumn + 1)
        $val4 = GetSubItemText($listview, $nItem2, $nColumn + 1)
    ElseIf $nColumn = 2 Then
        $val3 = GetSubItemText($listview, $nItem1, $nColumn - 1)
        $val4 = GetSubItemText($listview, $nItem2, $nColumn - 1)
    EndIf

    $nResult = 0        ; No change of item1 and item2 positions

    If $val1 < $val2 And $nColumn = 1 Then
        _CheckLessThan($val3, $val4, $nColumn, $nResult)
    ElseIf $val1 > $val2 And $nColumn = 1 Then
        _CheckGreaterThan($val3, $val4, $nColumn, $nResult)
    ElseIf $val3 < $val4 And $nColumn = 2 Then
        _CheckLessThan($val1, $val2, $nColumn, $nResult)
    ElseIf $val3 > $val4 And $nColumn = 2 Then
        _CheckGreaterThan($val1, $val2, $nColumn, $nResult)
    ElseIf $nColumn = 0 Then
        If $val1 < $val2 Then $nResult = -1
        If $val1 > $val2 Then $nResult = 1
    EndIf

    $nResult = $nResult * $nSortDir

    Return $nResult
EndFunc   ;==>LVSort

Func _CheckLessThan(ByRef $val1, ByRef $val2, ByRef $nColumn, ByRef $nResult)
    Switch $val1
        Case "KB"
            If $val2 = $val1 Then
                $nResult = -1
            Else
                $nResult = 1
            EndIf
        Case "MB"
            If $val2 = $val1 Then
                $nResult = -1
            Else
                $nResult = 1
            EndIf
        Case "GB"
            If $val2 = $val1 Then
                $nResult = -1
            Else
                $nResult = 1
            EndIf
        Case "TB"
            If $val2 = $val1 Then
                $nResult = -1
            Else
                $nResult = 1
            EndIf
    EndSwitch
EndFunc   ;==>_CheckLessThan

Func _CheckGreaterThan(ByRef $val1, ByRef $val2, ByRef $nColumn, ByRef $nResult)
    Switch $val1
        Case "KB"
            If $val2 = $val1 Then
                $nResult = 1
            Else
                $nResult = -1
            EndIf
            
        Case "MB"
            If $val2 = $val1 Then
                $nResult = 1
            Else
                $nResult = -1
            EndIf
        Case "GB"
            If $val2 = $val1 Then
                $nResult = 1
            Else
                $nResult = -1
            EndIf
        Case "TB"
            If $val2 = $val1 Then
                $nResult = 1
            Else
                $nResult = -1
            EndIf
    EndSwitch
EndFunc   ;==>_CheckGreaterThan

; Retrieve the text of a listview item in a specified column
Func GetSubItemText($nCtrlID, $nItemID, $nColumn)
    Local $stLvfi = DllStructCreate("uint;ptr;int;int[2];int")
    DllStructSetData($stLvfi, 1, $LVFI_PARAM)
    DllStructSetData($stLvfi, 3, $nItemID)

    Local $stBuffer = DllStructCreate("char[260]")

    $nIndex = GUICtrlSendMsg($nCtrlID, $LVM_FINDITEM, -1, DllStructGetPtr($stLvfi));

    Local $stLvi = DllStructCreate("uint;int;int;uint;uint;ptr;int;int;int;int")

    DllStructSetData($stLvi, 1, $LVIF_TEXT)
    DllStructSetData($stLvi, 2, $nIndex)
    DllStructSetData($stLvi, 3, $nColumn)
    DllStructSetData($stLvi, 6, DllStructGetPtr($stBuffer))
    DllStructSetData($stLvi, 7, 260)

    GUICtrlSendMsg($nCtrlID, $LVM_GETITEM, 0, DllStructGetPtr($stLvi));

    $sItemText = DllStructGetData($stBuffer, 1)

    $stLvi = 0
    $stLvfi = 0
    $stBuffer = 0

    Return $sItemText
EndFunc   ;==>GetSubItemText
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Hi,

I can see the value of learning all the dll calls; but not for this purpose.

I think you can just leave a numerical file size column (hidden in the listview), and reference that for the sort when you click on a file size column (say the one next to it..); then all your file sizes and "Mb" etc label columns are in order and you don't have to subsort? [or if you do, you can use a subsort which also references the file sizes as the second column (eg by simple vbs subsort as in Array2d) - and your formatting column will be sorted but not "touched"]

best, Randall

[PS This avoids "GUICtrlRegisterListViewSort" which i can get to be only super slow?...]

Edited by randallc
Link to comment
Share on other sites

I started this project to track the file size of unlimited files in close to real time. While making the script, I've had to do several things that required DLL calls, including tooltips per item in a listview. If I am able to learn enough about listviews while coding this script, I might be able to create a few additions to the listview udf that can help people who want/need a more "Explorer" style listview.

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...