Sign in to follow this  
Followers 0
ShawnW

[Solved] Cannot get this function to work...

6 posts in this topic

#1 ·  Posted (edited)

Here is my list view declaration.

$ConList = GUICtrlCreateListView("Conditions", 30, 90, 285, 119, BitOR($WS_VSCROLL,$WS_BORDER,$LVS_SHOWSELALWAYS), 0)

Here is how I add items to the list. When the proper button is pressed this code runs. AddCondition() just creates a 2nd form dialog box to gather info and returns a string. This part works in adding items to the list.

$ListItem = AddCondition()
If $ListItem <> "" Then
    _ArrayAdd($ConListItems,_GUICtrlListView_AddItem($ConList,$ListItem))
    _GUICtrlListView_SetColumnWidth($ConList,0,$LVSCW_AUTOSIZE)
    $ConListItems[0] += 1
EndIf

And here is how I am trying to delete item(s) selected when another button is pressed, but nothing seems to happen other than the item actually gets deselected.

_GUICtrlListView_DeleteItemsSelected($ConList)

Could use some suggestions on how to get this to work.

Thanks,

Shawn

Edited by ShawnW

Share this post


Link to post
Share on other sites



ShawnW,

You have been here long enough to know that you need to provide some working code if you want help on a problem like this. ;)

No-one is going to code a whole GUI to fit around your snippets - which are probably not the cause anyway. ;)

So go and write a nice short reproducer script that we can run and debug and then you might stand a chance of someone helping. :)

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

#3 ·  Posted (edited)

ShawnW,

You have been here long enough to know that you need to provide some working code if you want help on a problem like this. ;)

No-one is going to code a whole GUI to fit around your snippets - which are probably not the cause anyway. ;)

So go and write a nice short reproducer script that we can run and debug and then you might stand a chance of someone helping. :)

M23

Your right I should know, here ya go.

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>

$InstallBuilder = GUICreate("Install Builder", 345, 240)
; Create Run Conditions group
Local $ConListItems[1] = [0]
$RunConditions = GUICtrlCreateGroup(" Run Conditions ", 15, 15, 315, 210)
$RCAdd = GUICtrlCreateButton("Add Condition", 30, 60, 85, 25, $WS_GROUP)
$RCRemove = GUICtrlCreateButton("Remove Condition", 210, 60, 105, 25, $WS_GROUP)
$ConList = GUICtrlCreateListView("Conditions", 30, 90, 285, 119, BitOR($WS_VSCROLL,$WS_BORDER,$LVS_SHOWSELALWAYS), 0)
GUICtrlSetFont($RunConditions, 10, 800)
GUICtrlCreateGroup("", -99, -99, 1, 1)  ; Close Run Conditions group
GUISetState(@SW_SHOW, $InstallBuilder)  ; Show GUI

While True
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $RCAdd
            _ArrayAdd($ConListItems,_GUICtrlListView_AddItem($ConList,"Hello " & $ConListItems[0]))
            _GUICtrlListView_SetColumnWidth($ConList,0,$LVSCW_AUTOSIZE)
            $ConListItems[0] += 1
        Case $RCRemove
            _GUICtrlListView_DeleteItemsSelected($ConList)
    EndSwitch
WEnd

Edit: Took a couple unnecessary lines out of my example.

Edited by ShawnW

Share this post


Link to post
Share on other sites

Might be another case of mixing UDF functions with native controls. This works:

#include <Array.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <WindowsConstants.au3>

$InstallBuilder = GUICreate("Install Builder", 345, 240)
; Create Run Conditions group
Local $aConListItems[1] = [0]
$RunConditions = GUICtrlCreateGroup(" Run Conditions ", 15, 15, 315, 210)
$RCAdd = GUICtrlCreateButton("Add Condition", 30, 60, 85, 25, $WS_GROUP)
$RCRemove = GUICtrlCreateButton("Remove Condition", 210, 60, 105, 25, $WS_GROUP)
$hConList = _GUICtrlListView_Create($InstallBuilder, "Conditions", 30, 90, 285, 119)
GUICtrlSetFont($RunConditions, 10, 800)
GUICtrlCreateGroup("", -99, -99, 1, 1) ; Close Run Conditions group
GUISetState(@SW_SHOW, $InstallBuilder) ; Show GUI

While True
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $RCAdd
            $ListItem = "Hello " & $aConListItems[0]
            _ArrayAdd($aConListItems, _GUICtrlListView_AddItem($hConList, $ListItem))
            _GUICtrlListView_SetColumnWidth($hConList, 0, $LVSCW_AUTOSIZE)
            $aConListItems[0] += 1
        Case $RCRemove
            _GUICtrlListView_DeleteItemsSelected($hConList)
    EndSwitch
WEnd

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

That seems to be the problem, thanks PsaltyDS.

Share this post


Link to post
Share on other sites

PsaltyDS,

another case of mixing UDF functions with native controls

Becoming your speciality lately! :)

ShawnW,

Glad you got it sorted. ;)

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

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