Jump to content
Sign in to follow this  
jeansaad

List View Column Resizing

Recommended Posts

Does anyone know how to resize columns based on the ListViewItem data so that everything in the ListView shows on the screen?

When I resize the columns the GUI gets distorted and doesn't refresh properly... The ListViews are in tabs...

#include <GuiConstants.au3>
#NoTrayIcon
; ----------------------------------------------------------------------------
; Create the GUI features
; ---------------------------------------------------------------------------- 
$WinTitle = 'FindStuff!'
$WinWidth = 650
$WinHeight = 600

;GUI
GUICreate($WinTitle, $WinWidth, $WinHeight)
GuiSetIcon('icon.ico', 0)

;FILE MENU
$FileMenu = GuiCtrlCreateMenu ("File")
$ExitItem = GuiCtrlCreateMenuitem ("Exit", $FileMenu)
$HelpMenu = GuiCtrlCreateMenu ("Help")
$AboutItem = GuiCtrlCreateMenuitem ("About", $HelpMenu)

;TAB
GuiCtrlCreateTab(0, 0, $WinWidth, $WinHeight)

$findini = "findstuff.ini"
$tabsectionread = IniReadSection ($findini,"Tabs")
Dim $tabnames[UBound($tabsectionread)-1]

For $k = 1 To (UBound($tabnames))
    Dim $tempn = IniReadSection($findini,$tabsectionread[$k][1])
    For $i = 1 To $tempn[0][0]
        If $i = 1 Then
            $tabnames[$k-1] = IniRead($findini, $tabsectionread[$k][1], "TabName", "NoTabNameError")
            GuiCtrlCreateTabItem($tabnames[$k-1])
            Dim $listView = GuiCtrlCreateListView("Name|Detection|Type|Key", 0, 20, $WinWidth, $WinHeight - 40, $LVS_NOSORTHEADER, $LVS_EX_FULLROWSELECT )
        Else
            $SplitStringy = StringSplit($tempn[$i][1],",")
            
        ;Registry Check
            If $SplitStringy[1] = "rc" Or $SplitStringy[1] = "RC" Then
                If $SplitStringy[4] = RegRead($SplitStringy[3],$SplitStringy[2]) Then           
                    GUICtrlCreateListViewItem ($tempn[$i][0] & "|" & "Installed" & "|" & "Registry Check" & "|"  & $SplitStringy[2], $listView)
                Else
                    GUICtrlCreateListViewItem ($tempn[$i][0] & "|" & "Not Installed" & "|" & "Registry Check" & "|" & $SplitStringy[2], $listView)  
                EndIf
            EndIf
            
        ;File Version Check
            If $SplitStringy[1] = "fvc" Or $SplitStringy[1] = "FVC" Then 
                If $SplitStringy[4] = FileGetVersion ($SplitStringy[3] & "\" & $SplitStringy[2]) Then
                    GUICtrlCreateListViewItem ($tempn[$i][0] & "|" & "Installed" & "|" & "File Version Check" &  $SplitStringy[2], $listView)
                Else
                    GUICtrlCreateListViewItem ($tempn[$i][0] & "|" & "Not Installed" & "|" & "File Version Check" & "|" & $SplitStringy[2], $listView)
                EndIf
            EndIf
            
        ;File Date Check
            If $SplitStringy[1] = "fdc" Or $SplitStringy[1] = "FDC" Then
                If $SplitStringy[4] = FileGetTime ($SplitStringy[3] & "\" & $SplitStringy[2], 1, 1) Then
                    GUICtrlCreateListViewItem ($tempn[$i][0] & "|" & "Installed" & "|" & "File Date Check" & "|" & $SplitStringy[2], $listView)
                Else
                    GUICtrlCreateListViewItem ($tempn[$i][0] & "|" & "Not Installed" & "|" & "File Date Check" & "|" & $SplitStringy[2], $listView)
                EndIf
            EndIf
        EndIf
    Next
Next

; ----------------------------------------------------------------------------
; Set the operations for program events
; ---------------------------------------------------------------------------- 

GuiSetState()
While 1
$Event = GuiGetMsg()
Select
    Case $Event = -3 Or $Event = -1 or $Event = $ExitItem
        ExitLoop
    
    Case $Event = $AboutItem
        $iniversion = IniRead($findini, "Version", "DATFiles", "INIKeyNotFound")
        MsgBox(0, "Welcome to FindStuff!", "Welcome to FindStuff!" & @CRLF & @CRLF & @CRLF & "Find stuff is an INI-based detector program intended to display the currently installed software on a machine." & @CRLF & "Currently installed DAT Files Version " & $iniversion) 
EndSelect
WEnd
GUIDelete()

; ----------------------------------------------------------------------------
; Exit the Program
; ---------------------------------------------------------------------------- 

Exit

INI File it reads from...

[Version]
Version=1.0
DATFiles=.11

[MainCheck]
TabName=Windows Information
Service Pack 4=rc,CSDVersion,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion,Service Pack 4

[MSPatchesCheck]
TabName=MS Patches
Windows 2000 Hotfix - KB328237=rc,Description,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB328237,Windows 2000 Hotfix - KB328237
Windows 2000 Hotfix - KB823182=rc,Description,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB823182,Windows 2000 Hotfix - KB823182
Windows 2000 Hotfix - KB823353=rc,Description,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB823353,Windows 2000 Hotfix - KB823353
Windows 2000 Hotfix - KB823559=rc,Description,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB823559,Windows 2000 Hotfix - KB823559
Windows 2000 Hotfix - KB823559=rc,Description,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Updates\Windows 2000\SP5\KB824105,Windows 2000 Hotfix - KB823559

[Tabs]
Tab1=MainCheck
Tab2=MSPatchesCheck

Any help is appreciated...

Share this post


Link to post
Share on other sites

The latest BETA's have a range of _GUICtrlListViewXXXXXX() functions, 43 in total I think. Using these functions all your list view dreams will come true :(, including setting/hiding a column.

DL Beta here...


qq

Share this post


Link to post
Share on other sites

Thanks very much i think this will do the trick... However I have to find a way to make it relatively resize every column of the listview... Shouldn't be too hard... But thanks again...

Share this post


Link to post
Share on other sites

Thanks very much i think this will do the trick... However I have to find a way to make it relatively resize every column of the listview... Shouldn't be too hard... But thanks again...

<{POST_SNAPBACK}>

Just an idea:

Normally, pressing Control and Keypad Plus while the focus is on a ListView will auto-size te columns. Maybe you could try to send that key combination to the control.

Share this post


Link to post
Share on other sites

I want to adjust column width in a ListView, i try the following code :

$listview = GUICtrlCreateListView("Agent|Adresse IP", 5, 5, 190, 190, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))

_GUICtrlListViewSetColumnWidth ($listview, 0, $LVSCW_AUTOSIZE)

but nothing changes in the column ...

Am i forgetting anything ?

Thanks for ur help !

Share this post


Link to post
Share on other sites

I want to adjust column width in a ListView, i try the following code :

$listview = GUICtrlCreateListView("Agent|Adresse IP", 5, 5, 190, 190, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))

_GUICtrlListViewSetColumnWidth ($listview, 0, $LVSCW_AUTOSIZE)

but nothing changes in the column ...

Am i forgetting anything ?

Thanks for ur help !

What are you expecting?

Auto size may not need to change to the width.

If you want a different witdh, put a number in there instead.


SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites

What are you expecting?

Auto size may not need to change to the width.

If you want a different witdh, put a number in there instead.

sorry i'm a bit lost ... doesn't this $LVSCW_AUTOSIZE parameter mean that the column width fits the content of the "largest" item of this column ?

with the code i used some parts of my items remain hidden ... which is for me unexpected ...

Share this post


Link to post
Share on other sites

sorry i'm a bit lost ... doesn't this $LVSCW_AUTOSIZE parameter mean that the column width fits the content of the "largest" item of this column ?

with the code i used some parts of my items remain hidden ... which is for me unexpected ...

try applying that after adding data.


SciTE for AutoItDirections for Submitting Standard UDFs

 

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

 

Share this post


Link to post
Share on other sites

try applying that after adding data.

that's what i did (i think) :

1] i create the lisview with :

$listview = GUICtrlCreateListView("Agent|Adresse IP", 5, 5, 190, 190, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER), BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT))

2] i populate it with a loop containing an :

GUICtrlCreateListViewItem($c[1]&"|"&$c[2], $listview)

3] then i set the "auto-size" property ... :

_GUICtrlListViewSetColumnWidth ($listview, 1, $LVSCW_AUTOSIZE)

but i doesn't work as expected ...

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...