Jump to content
Sign in to follow this  
dmorand

Trying to set column width of ListView and getting error

Recommended Posts

dmorand

I'm trying to set the column width of my ListView items so that users don't need to click on the columns to expand them.

Here is the code snipped:

$appList= GUICtrlCreateListView("Application|Version|Location|", 2, 2, 694, 268)
GUICtrlSendMsg($appList, $LVM_SETCOLUMNWIDTH, 0, 70)

Here are the messages I'm seeing:

\\appserver\DS_DM\Custom_Scripts\applauncher_v20.au3(47,45) : WARNING: $LVM_SETCOLUMNWIDTH: possibly used before declaration.

GUICtrlSendMsg($appList, $LVM_SETCOLUMNWIDTH,

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

\\appserver\DS_DM\Custom_Scripts\applauncher_v20.au3(47,45) : ERROR: $LVM_SETCOLUMNWIDTH: undeclared global variable.

GUICtrlSendMsg($appList, $LVM_SETCOLUMNWIDTH,

I didn't think I needed to declare the style variables........

Share this post


Link to post
Share on other sites
weaponx

#include <ListViewConstants.au3>

Share this post


Link to post
Share on other sites
dmorand

#include <ListViewConstants.au3>

Was that in the documentation anywhere? I must have missed it if it was.

Share this post


Link to post
Share on other sites
weaponx

Was that in the documentation anywhere? I must have missed it if it was.

Not verbatim but then again where is the code you posted in the help file?

If you look at the User Defined Functions for GuiListView you will see they all include "GuiListView.au3". "ListViewConstants.au3" is included by "GuiListView.au3".

Share this post


Link to post
Share on other sites
dmorand

I'm having some issues determining that the listview is being selected. I have multiple items being placed in my listview from an ini file.

I have a case statement checking if the listview was clicked, but it seems to only work on the column headers, not the items themselves. I'm assuming I need to have a case for each item, is that right?

$ini = "\\isops\analysts\_Application_Launcher\" & "launcher.ini"

$iniFile = readIniSections($ini)

func readIniSections($ini)
    $iniFile = IniReadSectionNames($ini)
    If @error Then 
        MsgBox(4096, "", "Error occurred, probably no INI file, or has been renamed.")
        Exit
    EndIf
    Return $iniFile
EndFunc

func createListView($iniFile,$ini,$appList,$formGroup)
    For $i = 1 to $iniFile[0]
        $desc = IniRead($ini,$iniFile[$i],"description","NotFound")
        $location = IniRead($ini,$iniFile[$i],"run","NotFound")
        $group = IniRead($ini,$iniFile[$i],"group","NotFound")
        If $group=$formGroup Then
            GUICtrlCreateListViewItem($desc & "|N/A" & "|" & $location, $appList)
        EndIf
    Next
EndFunc

$Form1 = GUICreate("Application Launcher - HealthAlliance Hospital", 725, 450, 192, 114)

$FileMenu = GUICtrlCreateMenu("File")
$QuitItem = GUICtrlCreateMenuItem("Quit", $FileMenu)

$MiscMenu= GUICtrlCreateMenu("Miscellaneous")
$BagelItem = GUICtrlCreateMenuItem("Bagel List", $MiscMenu)

$HelpMenu = GUICtrlCreateMenu("Help")
$ReleaseItem = GUICtrlCreateMenuItem("Release Notes", $HelpMenu)
$AboutItem = GUICtrlCreateMenuItem("About", $HelpMenu)

$web_group = GUICtrlCreateGroup("Web Applications", 4, 134, 705, 160)
$webList= GUICtrlCreateListView("Application|Version|Address", 8, 150, 694, 138,$LVS_SORTASCENDING)
GUICtrlSendMsg($webList, $LVM_SETCOLUMNWIDTH, 0, 200)
GUICtrlSendMsg($webList, $LVM_SETCOLUMNWIDTH, 2, 410)
createListView($iniFile,$ini,$webList,"web")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $QuitItem
            Exit
        Case $BagelItem
            Run('notepad \\isops\analysts\_Application_Launcher\bagel_list_v2.txt');
        Case $ReleaseItem
            Run('notepad \\ISOPS\Analysts\_Application_Launcher\Application_Launcher_help.txt');
[b]     Case $webList
            MsgBox(0,"Hello","Testing")
            $app_run = GUICtrlGetState($webList)
            MsgBox(0,"",$app_run)
            $app_run = GUICtrlRead(GuiCtrlRead($webList))
            MsgBox(0,"",$app_run)[/b]
    EndSwitch
WEnd
Edited by dmorand

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  

×