Jump to content

GUIListViewEx UDF acting up


Recommended Posts

Trying to convert over to using the UDF.

Followed the examples yet I get unexpected results such that numbers are put into the first column.

Not sure where I went wrong since not that many lines of code were added.

;Autoit Options
; #NoTrayIcon ;No Tray Icon
Opt("GUIOnEventMode", 1)
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("GUICloseOnESC", 0) ;1=ESC  closes, 0=ESC won't close
Opt("GUIResizeMode", 802)
; Opt("GUIResizeMode", 1)


#Include <String.au3>
#include <Date.au3>
#Include <WinAPI.au3>
#include <File.au3>
#include <GuiTab.au3>
;#include <GDIPlus.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>

; Constants includes
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <ToolbarConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

; Tab groups
Global Const $L_VOLUNTEERS =    "  Volunteers  "
Global Const $L_VOLUNTEER =    "Volunteer"
Global Const $L_EVENTS =        "  Events  "
Global Const $L_EVENT =        "Event"

; Tab items
Global Const $T_Event =        0
Global Const $T_Volunteer =    1

;Versions Info
Global $ProgName = "Volunteer Coordinator"
Global $VersionBuild = "20130213"     ;YEAR|MON|DAY
Global $ProgVersion = "0.1"
GLOBAL $AboutVersion = "2013.02.13 (" & $ProgVersion & ")"

Global $ProgWidth =1024, $ProgHeight = 720

Local $sWidth = 400, $sHeight = 350
Local $hToolbar = 40, $hStatus = 40, $hTabs = $hToolbar+30, $hLists = ($ProgHeight - $hTabs - $hStatus - $hToolbar)

#Region ### START Koda GUI section ### Form=R:\AutoIt Examples\koda_2008-09-03\Forms\VolunteerCoordinator.kxf
Global $MainForm = GUICreate($ProgName, $ProgWidth, $ProgHeight, (@DesktopWidth - $ProgWidth) / 2, (@DesktopHeight - $ProgHeight) / 2, $WS_SIZEBOX + $WS_SYSMENU )
GUISetState(@SW_HIDE)
GUISetBkColor(0xA6CAF0)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESTORE, "")
Global $TabVol = GUICtrlCreateTab(1, $hTabs-$hToolbar, $ProgWidth-2, $hToolbar, $TCS_TABS)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

Global $TabSheetEvents = GUICtrlCreateTabItem($L_EVENTS)
Global $ListViewEvents = GUICtrlCreateListView( _
        "Date                          |Type           |Volunteers                                                                   ", _
        2, $hTabs, $ProgWidth-4, $hLists, $LVS_SHOWSELALWAYS, $LVS_SORTDESCENDING)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
$iLV_Events = _GUIListViewEx_Init($ListViewEvents, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Events)
EventFullList()
;GUICtrlSetOnEvent(-1, "ListViewEventsClick")
_GUICtrlListView_SetColumnWidth($ListViewEvents, 0, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewEvents, 1, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewEvents, 2, $LVSCW_AUTOSIZE_USEHEADER )
;_GUICtrlListView_RegisterSortCallBack($ListViewEvents, True, True)

Global $ListEventsVol = GUICtrlCreateList("", 819, $hTabs, 202, 618)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
;GUICtrlSetOnEvent(-1, "ListEventsVolClick")

Global $TabSheetVolunteers = GUICtrlCreateTabItem($L_VOLUNTEERS)
Global $ListViewVolunteers = GUICtrlCreateListView( _
        "Name               |Type        |Home      |Work       |Cell       |Address                 |City      |Prov|Postal|Notes                             ", _
        2, $hTabs, $ProgWidth-4, $hLists, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_SORTASCENDING))
GUICtrlSetFont($ListViewVolunteers, 10, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
;$iLV_Volunteers = _GUIListViewEx_Init($ListViewVolunteers, $ListOfVolunteers, 0, 0, True, True)
$iLV_Volunteers = _GUIListViewEx_Init($ListViewVolunteers, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Volunteers)
VolunteerFullList()
;GUICtrlSetOnEvent(-1, "ListViewVolunteersClick")
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 0, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 1, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 2, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 3, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 4, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 6, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 9, $LVSCW_AUTOSIZE_USEHEADER)
;_GUICtrlListView_RegisterSortCallBack($ListViewVolunteers, False, True)

GUICtrlCreateTabItem("")    ;end of tabs
sleep(500)
_GUICtrlTab_SetCurFocus($TabVol, $T_Event)
; _GUICtrlTab_SetCurFocus($ListViewEvents, $T_Event)

Global $StatusBar = _GUICtrlStatusBar_Create($MainForm)
_GUICtrlStatusBar_SetSimple($StatusBar)
_GUICtrlStatusBar_SetText($StatusBar, "Simple status bar window text goes here.")
_GUICtrlStatusBar_SetMinHeight($StatusBar, $hStatus)

GUISetFont(10, 400, 0, "MS Sans Serif", $MainForm)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
;GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_PRIMARYdown')
GUISetOnEvent($GUI_EVENT_RESTORE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESIZED, "")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

#EndRegion ### END Koda GUI section ###

GUISwitch($MainForm)
GUISetState(@SW_SHOW)

; Set the Events ListView as active
_GUIListViewEx_SetActive($iLV_Events)

;GUISetState(@SW_SHOW, $MainForm)
While 1
    sleep(100)
WEnd

GUISetState(@SW_HIDE)
GUIDelete()
;_GUICtrlListView_UnRegisterSortCallBack($ListViewEvents)
;_GUICtrlListView_UnRegisterSortCallBack($ListViewVolunteers)
_GUIListViewEx_Close($iLV_Events)
_GUIListViewEx_Close($iLV_Volunteers)
GUIRegisterMsg($WM_NOTIFY, "")
Exit

Func MainFormClose()
  Exit
EndFunc   ;==>MainFormClose

Func EventFullList()
;~     GUICtrlCreateListViewItem("February 12, 2013|All Day||", $ListViewEvents)
;~     GUICtrlCreateListViewItem("February 13, 2013|AM||", $ListViewEvents)
;~     GUICtrlCreateListViewItem("February 13, 2013|PM||", $ListViewEvents)
;~     GUICtrlCreateListViewItem("February 15, 2013|From|11:00|18:00", $ListViewEvents)

    _GUIListViewEx_Insert("February 13, 2013|AM|Sheila Blue,Dan Black")
    _GUIListViewEx_Insert("February 13, 2013|Afternoon|Dan Black,Paul Green")
    _GUIListViewEx_Insert("February 12, 2013|All Day|Mary Pigment,Dan Black,Sheila Blue,Paul Green")
    _GUIListViewEx_Insert("February 15, 2013|11:00-18:00|Sheila Blue,Dan Black,Paul Green")
    _GUIListViewEx_Insert("February 14, 2013|Evening|Mary Pigment,Dan Black,Paul Green")
EndFunc   ;==>EventFullList

Func VolunteerFullList()
;~     GUICtrlCreateListViewItem("Dan Black|Parent|(514)345-6789|(514)345-9876|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator", $ListViewVolunteers)
;~     GUICtrlCreateListViewItem("Mary Pigment|Staff|(519)242-2020|(519)356-0176|(519)675-1201|21st Avenue|London|ON|J7S5M9|Principal", $ListViewVolunteers)
;~     GUICtrlCreateListViewItem("Paul Green|Friend/Family|(514)349-6699|(514)349-5555|(514)698-9857|423 Happle / Apt 12|Montreal|QC|H2N5L1|", $ListViewVolunteers)
;~     GUICtrlCreateListViewItem("Sheila Blue|Other|(514)345-7733|(514)655-4562|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator", $ListViewVolunteers)

    _GUIListViewEx_Insert("Dan Black|Parent|(514)345-6789|(514)345-9876|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator")
    _GUIListViewEx_Insert("Mary Pigment|Staff|(519)242-2020|(519)356-0176|(519)675-1201|21st Avenue|London|ON|J7S5M9|Principal")
    _GUIListViewEx_Insert("Paul Green|Friend/Family|(514)349-6699|(514)349-5555|(514)698-9857|423 Happle / Apt 12|Montreal|QC|H2N5L1|")
    _GUIListViewEx_Insert("Sheila Blue|Other|(514)345-7733|(514)655-4562|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator")
EndFunc   ;==>VolunteerFullList

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

    $hWndListView1 = GUICtrlGetHandle($ListViewEvents)
    $hWndListView2 = GUICtrlGetHandle($ListViewVolunteers)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView1
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
                Case $LVN_ITEMCHANGING ; An item is changing
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    Return True ; prevent the change
                    ;Return False ; allow the change
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You clicked on: " & $text)
;                    _GUICtrlListView_SetItemSelected($ListViewEvents, DllStructGetData($tInfo, "Index"))
Return $GUI_RUNDEFMSG
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
Return $GUI_RUNDEFMSG
; DO EDIT HERE
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    $text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You hit ENTER on: " & $text)
            EndSwitch

        Case $hWndListView2
            Switch $iCode
                Case $LVN_COLUMNCLICK ; A column was clicked
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    ; Kick off the sort callback
                    _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
                Case $LVN_ITEMCHANGING ; An item is changing
                    $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    Return True ; prevent the change
                    ;Return False ; allow the change
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You clicked on: " & $text)
;                    _GUICtrlListView_SetItemSelected($ListViewVolunteers, DllStructGetData($tInfo, "Index"))

;Return $GUI_RUNDEFMSG
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
;Return $GUI_RUNDEFMSG
                    ; No return value
; DO EDIT HERE
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    $text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You hit ENTER on: " & $text)
                    ; No return value
; DO EDIT HERE
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

It took some doing (I wrote that UDF a long time ago!) but I have found the problem and fixed it for your script. I am now checking to make sure that the fix has no knock-on effects in other cases and then I will release a new version in the UDF thread. :)

Thanks for reporting the bug. It was obvious what was happening - the delimited string was being split and the wrong elements were being read into the ListView - but I needed to track down why this was happening. It turned out that it was the particular case of the UDF adding a delimited string to an originally empty native ListView with multiple columns. That is what happens when you try to deal with so many options (native or UDF ListView, originally empty or filled, single or multiple columns, data insert as string or array). :wacko:

M23

Edited by Melba23
Added an option

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

The new release is out now - you can get it from the link in my sig. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Testing - your fix got it working on the first tab but the second tab has two blank lines followed by two good lines.

Here's the new code with the proper handling to make your UDF sorting work.

Do you see any reason why the Case $NM_RETURN doesn't work when Click and Double-Click work?

;Autoit Options
; #NoTrayIcon ;No Tray Icon
Opt("GUIOnEventMode", 1)
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("GUICloseOnESC", 0) ;1=ESC closes, 0=ESC won't close
Opt("GUIResizeMode", 802)
; Opt("GUIResizeMode", 1)


#Include <String.au3>
#include <Date.au3>
#Include <WinAPI.au3>
#include <File.au3>
#include <GuiTab.au3>
;#include <GDIPlus.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>

; Constants includes
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <ToolbarConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

; Tab groups
Global Const $L_VOLUNTEERS = " Volunteers "
Global Const $L_VOLUNTEER = "Volunteer"
Global Const $L_EVENTS = " Events "
Global Const $L_EVENT = "Event"

; Tab items
Global Const $T_Event = 0
Global Const $T_Volunteer = 1

;Versions Info
Global $ProgName = "Volunteer Coordinator"
Global $VersionBuild = "20130213" ;YEAR|MON|DAY
Global $ProgVersion = "0.1"
GLOBAL $AboutVersion = "2013.02.13 (" & $ProgVersion & ")"

Global $ProgWidth =1024, $ProgHeight = 720

Local $sWidth = 400, $sHeight = 350
Local $hToolbar = 40, $hStatus = 40, $hTabs = $hToolbar+30, $hLists = ($ProgHeight - $hTabs - $hStatus - $hToolbar)

#Region ### START Koda GUI section ### Form=R:\AutoIt Examples\koda_2008-09-03\Forms\VolunteerCoordinator.kxf
Global $MainForm = GUICreate($ProgName, $ProgWidth, $ProgHeight, (@DesktopWidth - $ProgWidth) / 2, (@DesktopHeight - $ProgHeight) / 2, $WS_SIZEBOX + $WS_SYSMENU )
GUISetState(@SW_HIDE)
GUISetBkColor(0xA6CAF0)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESTORE, "")
Global $TabVol = GUICtrlCreateTab(1, $hTabs-$hToolbar, $ProgWidth-2, $hToolbar, $TCS_TABS)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

Global $TabSheetEvents = GUICtrlCreateTabItem($L_EVENTS)
Global $ListViewEvents = GUICtrlCreateListView( _
"Date                        |Type       |Volunteers                                                                     ", _
2, $hTabs, $ProgWidth-4, $hLists, $LVS_SHOWSELALWAYS, $LVS_SORTDESCENDING)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
$iLV_Events = _GUIListViewEx_Init($ListViewEvents, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Events)
EventFullList()
;GUICtrlSetOnEvent(-1, "ListViewEventsClick")
_GUICtrlListView_SetColumnWidth($ListViewEvents, 0, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewEvents, 1, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewEvents, 2, $LVSCW_AUTOSIZE_USEHEADER )
;_GUICtrlListView_RegisterSortCallBack($ListViewEvents, True, True)

Global $ListEventsVol = GUICtrlCreateList("", 819, $hTabs, 202, 618)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
;GUICtrlSetOnEvent(-1, "ListEventsVolClick")

Global $TabSheetVolunteers = GUICtrlCreateTabItem($L_VOLUNTEERS)
Global $ListViewVolunteers = GUICtrlCreateListView( _
"Name            |Type       |Home   |Work   |Cell   |Address                |City   |Prov|Postal|Notes                          ", _
2, $hTabs, $ProgWidth-4, $hLists, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_SORTASCENDING))
GUICtrlSetFont($ListViewVolunteers, 10, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
;$iLV_Volunteers = _GUIListViewEx_Init($ListViewVolunteers, $ListOfVolunteers, 0, 0, True, True)
$iLV_Volunteers = _GUIListViewEx_Init($ListViewVolunteers, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Volunteers)
VolunteerFullList()
;GUICtrlSetOnEvent(-1, "ListViewVolunteersClick")
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 0, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 1, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 2, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 3, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 4, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 6, $LVSCW_AUTOSIZE_USEHEADER )
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 9, $LVSCW_AUTOSIZE_USEHEADER)
;_GUICtrlListView_RegisterSortCallBack($ListViewVolunteers, False, True)

GUICtrlCreateTabItem("") ;end of tabs
sleep(500)
_GUICtrlTab_SetCurFocus($TabVol, $T_Event)
; _GUICtrlTab_SetCurFocus($ListViewEvents, $T_Event)

Global $StatusBar = _GUICtrlStatusBar_Create($MainForm)
_GUICtrlStatusBar_SetSimple($StatusBar)
_GUICtrlStatusBar_SetText($StatusBar, "Simple status bar window text goes here.")
_GUICtrlStatusBar_SetMinHeight($StatusBar, $hStatus)

GUISetFont(10, 400, 0, "MS Sans Serif", $MainForm)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
;GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_PRIMARYdown')
GUISetOnEvent($GUI_EVENT_RESTORE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESIZED, "")

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

#EndRegion ### END Koda GUI section ###

GUISwitch($MainForm)
GUISetState(@SW_SHOW)

; Set the Events ListView as active
_GUIListViewEx_SetActive($iLV_Events)

;GUISetState(@SW_SHOW, $MainForm)
While 1
sleep(100)
WEnd

GUISetState(@SW_HIDE)
GUIDelete()
;_GUICtrlListView_UnRegisterSortCallBack($ListViewEvents)
;_GUICtrlListView_UnRegisterSortCallBack($ListViewVolunteers)
_GUIListViewEx_Close($iLV_Events)
_GUIListViewEx_Close($iLV_Volunteers)
GUIRegisterMsg($WM_NOTIFY, "")
Exit

Func MainFormClose()
Exit
EndFunc ;==>MainFormClose

Func EventFullList()
;~ GUICtrlCreateListViewItem("February 12, 2013|All Day||", $ListViewEvents)
;~ GUICtrlCreateListViewItem("February 13, 2013|AM||", $ListViewEvents)
;~ GUICtrlCreateListViewItem("February 13, 2013|PM||", $ListViewEvents)
;~ GUICtrlCreateListViewItem("February 15, 2013|From|11:00|18:00", $ListViewEvents)

_GUIListViewEx_Insert("February 13, 2013|AM|Sheila Blue,Dan Black")
_GUIListViewEx_Insert("February 13, 2013|Afternoon|Dan Black,Paul Green")
_GUIListViewEx_Insert("February 12, 2013|All Day|Mary Pigment,Dan Black,Sheila Blue,Paul Green")
_GUIListViewEx_Insert("February 15, 2013|11:00-18:00|Sheila Blue,Dan Black,Paul Green")
_GUIListViewEx_Insert("February 14, 2013|Evening|Mary Pigment,Dan Black,Paul Green")
EndFunc ;==>EventFullList

Func VolunteerFullList()
;~ GUICtrlCreateListViewItem("Dan Black|Parent|(514)345-6789|(514)345-9876|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator", $ListViewVolunteers)
;~ GUICtrlCreateListViewItem("Mary Pigment|Staff|(519)242-2020|(519)356-0176|(519)675-1201|21st Avenue|London|ON|J7S5M9|Principal", $ListViewVolunteers)
;~ GUICtrlCreateListViewItem("Paul Green|Friend/Family|(514)349-6699|(514)349-5555|(514)698-9857|423 Happle / Apt 12|Montreal|QC|H2N5L1|", $ListViewVolunteers)
;~ GUICtrlCreateListViewItem("Sheila Blue|Other|(514)345-7733|(514)655-4562|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator", $ListViewVolunteers)

_GUIListViewEx_Insert("Dan Black|Parent|(514)345-6789|(514)345-9876|(608)345-1234|253 Temple Drive|Montreal|QC|H2N3M4|Coordinator")
_GUIListViewEx_Insert("Mary Pigment|Staff|(519)242-2020|(519)356-0176|(519)675-1201|21st Avenue|London|ON|J7S5M9|Principal")
_GUIListViewEx_Insert("Paul Green|Friend/Family|(514)349-6699|(514)349-5555|(514)698-9857|423 Happle / Apt 12|Montreal|QC|H2N5L1|")
_GUIListViewEx_Insert("Sheila Blue|Other|(514)345-7733|(514)655-4562|(608)345-1234|123 Templeton|Montreal|QC|H2N3M4|Old Coordinator")
EndFunc ;==>VolunteerFullList

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

$hWndListView1 = GUICtrlGetHandle($ListViewEvents)
$hWndListView2 = GUICtrlGetHandle($ListViewVolunteers)

$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")

Switch $hWndFrom
Case $hWndListView1
Switch $iCode
;            Case $LVN_COLUMNCLICK ; A column was clicked
;                $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
;                ; Kick off the sort callback
;                _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
; No return value
;            Case $LVN_ITEMCHANGING ; An item is changing
;                $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
;                Return True ; prevent the change
                 ;Return False ; allow the change
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
_GUICtrlStatusBar_SetText($StatusBar, "You clicked on: " & $text)
; _GUICtrlListView_SetItemSelected($ListViewEvents, DllStructGetData($tInfo, "Index"))
Return $GUI_RUNDEFMSG
; No return value
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
_GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
Return $GUI_RUNDEFMSG
; DO EDIT HERE
; No return value
             Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
$text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
_GUICtrlStatusBar_SetText($StatusBar, "You hit ENTER on: " & $text)
EndSwitch

Case $hWndListView2
Switch $iCode
;            Case $LVN_COLUMNCLICK ; A column was clicked
;                $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                 ; Kick off the sort callback
;                _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                 ; No return value
;            Case $LVN_ITEMCHANGING ; An item is changing
;                $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
;                Return True ; prevent the change
                 ;Return False ; allow the change
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
_GUICtrlStatusBar_SetText($StatusBar, "You clicked on: " & $text)
; _GUICtrlListView_SetItemSelected($ListViewVolunteers, DllStructGetData($tInfo, "Index"))

;Return $GUI_RUNDEFMSG
; No return value
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
_GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
;Return $GUI_RUNDEFMSG
; No return value
; DO EDIT HERE
             Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
$text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
_GUICtrlStatusBar_SetText($StatusBar, "You hit ENTER on: " & $text)
                 ; No return value
; DO EDIT HERE
EndSwitch
EndSwitch

; And here we call the UDF WM_NOTIFY handler
_GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $iwParam, $ilParam)
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Edited by Garp99HasSpoken
Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

I am looking into the problem with the second ListView - interesting result. :huh2:

As to the sorting - you had not registered the GUIListViewEx_WM_NOTIFY_Handler function so the UDF did not have the correct code to sort. Either do it via the UDF function like this:

_GUIListViewEx_DragRegister(True, False, False)

or add the function to your handler like this:

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

_GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam)

EndFunc

It is always a good idea to read the UDF headers when the author has taken the trouble to write them: ;)

_GUIListViewEx_DragRegister
; Description ...: Registers Windows messages needed for the UDF
[...]
; Remarks .......: If other handlers already registered, then call the relevant handler function from within that handler
; If no dragging is required, only the WM_NOTIFY handler needs to be registered
[...]

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Figured out the problem is if you don't add extended options like in this line

Global $ListViewVolunteers = GUICtrlCreateListView( _

"Name |Type |Home |Work |Cell |Address |City |Prov|Postal|Notes ", _

2, $hTabs, $ProgWidth-4, $hLists, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_SORTASCENDING))

You'll notice that I made a mistake in the first tab by not using BitOr and so the 2nd part is taken as extended item and the list works.

Change the line to

2, $hTabs, $ProgWidth-4, $hLists, $LVS_SINGLESEL, $LVS_SORTASCENDING)

and it works

As for previous post, I did make the correction in the last code posted.

Edited by Garp99HasSpoken
Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

I resolved the problem. Again through trying to offer too many options I ended up trying to insert an array into an empty native ListView with multiple columns - at least I knew my way around the UDF this time. What I do not understand is why the third and fourth inserts worked at all - at least they all do now for me. :wacko:

Does it for you?

Now testing to see if there are any knock-on effects. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

Good. The fix did indeed introduce a further small problem but I have now resolved that. I will put out a new release shortly - you will need to update again when I do. ;)

And do not think I am annoyed by you finding these problems - on the contrary I am most grateful. No point in having a UDF if there are problems with it. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Not so quick :shifty:

New problem -- trying to implement hidden column, I added the keys and adjusted the columns, now you'll see that Events tab has duplicates.

If you click on the item, you'll see in status bar the item is indeed a duplicate key selected.

;Autoit Options
; #NoTrayIcon ;No Tray Icon
Opt("GUIOnEventMode", 1)
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("GUICloseOnESC", 0) ;1=ESC  closes, 0=ESC won't close
Opt("GUIResizeMode", 802)
; Opt("GUIResizeMode", 1)


#Include <String.au3>
#include <Date.au3>
#Include <WinAPI.au3>
#include <File.au3>
#include <GuiTab.au3>
;#include <GDIPlus.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>

; Constants includes
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <ToolbarConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

; Tab groups
Global Const $L_VOLUNTEERS =    "  Volunteers  "
Global Const $L_VOLUNTEER =    "Volunteer"
Global Const $L_EVENTS =        "  Events  "
Global Const $L_EVENT =        "Event"

; Tab items
Global Const $T_Event =        0
Global Const $T_Volunteer =    1

;Versions Info
Global $ProgName = "Volunteer Coordinator"
Global $VersionBuild = "20130213"     ;YEAR|MON|DAY
Global $ProgVersion = "0.1"
GLOBAL $AboutVersion = "2013.02.13 (" & $ProgVersion & ")"

Global $ProgWidth =1024, $ProgHeight = 720

Local $sWidth = 400, $sHeight = 350
Local $hToolbar = 40, $hStatus = 40, $hTabs = $hToolbar+30, $hLists = ($ProgHeight - $hTabs - $hStatus - $hToolbar)

#Region ### START Koda GUI section ### Form=R:\AutoIt Examples\koda_2008-09-03\Forms\VolunteerCoordinator.kxf
Global $MainForm = GUICreate($ProgName, $ProgWidth, $ProgHeight, (@DesktopWidth - $ProgWidth) / 2, (@DesktopHeight - $ProgHeight) / 2, $WS_SIZEBOX + $WS_SYSMENU )
GUISetState(@SW_HIDE)
GUISetBkColor(0xA6CAF0)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESTORE, "")
Global $TabVol = GUICtrlCreateTab(1, $hTabs-$hToolbar, $ProgWidth-2, $hToolbar, $TCS_TABS)
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

Global $TabSheetEvents = GUICtrlCreateTabItem($L_EVENTS)
Global $ListViewEvents = GUICtrlCreateListView( _
        "|Date                         |Type           |Volunteers                                                                                                   ", _
        2, $hTabs, $ProgWidth-4, $hLists, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_SORTDESCENDING))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
$iLV_Events = _GUIListViewEx_Init($ListViewEvents, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Events)
EventFullList()
;GUICtrlSetOnEvent(-1, "ListViewEventsClick")
_GUICtrlListView_SetColumnWidth($ListViewEvents, 0, 0)    ; hidden
For $i=1 To 3
    _GUICtrlListView_SetColumnWidth($ListViewEvents, $i, $LVSCW_AUTOSIZE_USEHEADER)
Next
;_GUICtrlListView_RegisterSortCallBack($ListViewEvents, True, True)

Global $TabSheetVolunteers = GUICtrlCreateTabItem($L_VOLUNTEERS)
Global $ListViewVolunteers = GUICtrlCreateListView( _
        "|Name              |Type        |Home      |Work       |Cell       |Address                 |City      |Prov|Postal|Notes                             ", _
        2, $hTabs, $ProgWidth-4, $hLists, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL, $LVS_SORTASCENDING))
GUICtrlSetFont($ListViewVolunteers, 10, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
;$iLV_Volunteers = _GUIListViewEx_Init($ListViewVolunteers, $ListOfVolunteers, 0, 0, True, True)
$iLV_Volunteers = _GUIListViewEx_Init($ListViewVolunteers, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Volunteers)
VolunteerFullList()
;GUICtrlSetOnEvent(-1, "ListViewVolunteersClick")
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 0, 0)    ; hidden
For $i=1 To 10
    _GUICtrlListView_SetColumnWidth($ListViewVolunteers, $i, $LVSCW_AUTOSIZE_USEHEADER)
Next
;_GUICtrlListView_RegisterSortCallBack($ListViewVolunteers, False, True)

GUICtrlCreateTabItem("")    ;end of tabs
sleep(500)
_GUICtrlTab_SetCurFocus($TabVol, $T_Event)
; _GUICtrlTab_SetCurFocus($ListViewEvents, $T_Event)

Global $StatusBar = _GUICtrlStatusBar_Create($MainForm)
_GUICtrlStatusBar_SetSimple($StatusBar)
_GUICtrlStatusBar_SetText($StatusBar, "Simple status bar window text goes here.")
_GUICtrlStatusBar_SetMinHeight($StatusBar, $hStatus)

GUISetFont(10, 400, 0, "MS Sans Serif", $MainForm)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
;GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, '_PRIMARYdown')
GUISetOnEvent($GUI_EVENT_RESTORE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESIZED, "")

_GUIListViewEx_DragRegister(True, False, False)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

#EndRegion ### END Koda GUI section ###

GUISwitch($MainForm)
GUISetState(@SW_SHOW)

; Set the Events ListView as active
_GUIListViewEx_SetActive($iLV_Events)

;GUISetState(@SW_SHOW, $MainForm)
While 1
    sleep(100)
WEnd

GUISetState(@SW_HIDE)
GUIDelete()
;_GUICtrlListView_UnRegisterSortCallBack($ListViewEvents)
;_GUICtrlListView_UnRegisterSortCallBack($ListViewVolunteers)
_GUIListViewEx_Close($iLV_Events)
_GUIListViewEx_Close($iLV_Volunteers)
GUIRegisterMsg($WM_NOTIFY, "")
Exit

Func MainFormClose()
  Exit
EndFunc   ;==>MainFormClose

Func EventFullList()
;~     GUICtrlCreateListViewItem("February 12, 2013|All Day||", $ListViewEvents)
;~     GUICtrlCreateListViewItem("February 13, 2013|AM||", $ListViewEvents)
;~     GUICtrlCreateListViewItem("February 13, 2013|PM||", $ListViewEvents)
;~     GUICtrlCreateListViewItem("February 15, 2013|From|11:00|18:00", $ListViewEvents)

    _GUIListViewEx_Insert("1|September 23, 2012|AM|Sheila Blue,Dan Black")
    _GUIListViewEx_Insert("2|December  3, 2012|Afternoon|Dan Black,Paul Green")
    _GUIListViewEx_Insert("3|January 31, 2013|All Day|Mary Pigment,Dan Black,Sheila Blue,Paul Green")
    _GUIListViewEx_Insert("5|February 18, 2013|11:00-18:00|Sheila Blue,Dan Black,Paul Green")
    _GUIListViewEx_Insert("7|February 14, 2013|Evening|Mary Pigment,Dan Black,Paul Green")
EndFunc   ;==>EventFullList

Func VolunteerFullList()
;~     GUICtrlCreateListViewItem("Dan Black|Parent|(514)345-6789|(514)345-9876|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator", $ListViewVolunteers)
;~     GUICtrlCreateListViewItem("Mary Pigment|Staff|(519)242-2020|(519)356-0176|(519)675-1201|21st Avenue|London|ON|J7S5M9|Principal", $ListViewVolunteers)
;~     GUICtrlCreateListViewItem("Paul Green|Friend/Family|(514)349-6699|(514)349-5555|(514)698-9857|423 Happle / Apt 12|Montreal|QC|H2N5L1|", $ListViewVolunteers)
;~     GUICtrlCreateListViewItem("Sheila Blue|Other|(514)345-7733|(514)655-4562|(608)345-1234|239 Temple Drive|Montreal|QC|H2N3M4|Coordinator", $ListViewVolunteers)

    _GUIListViewEx_Insert("1|Dan Black|Parent|(514)345-6789|(514)345-9876|(608)345-1234|253 Temple Drive|Montreal|QC|H2N3M4|Coordinator")
    _GUIListViewEx_Insert("2|Mary Pigment|Staff|(519)242-2020|(519)356-0176|(519)675-1201|21st Avenue|London|ON|J7S5M9|Principal")
    _GUIListViewEx_Insert("4|Paul Green|Friend/Family|(514)349-6699|(514)349-5555|(514)698-9857|423 Happle / Apt 12|Montreal|QC|H2N5L1|")
    _GUIListViewEx_Insert("5|Sheila Blue|Other|(514)345-7733|(514)655-4562|(608)345-1234|123 Templeton|Montreal|QC|H2N3M4|Old Coordinator")
EndFunc   ;==>VolunteerFullList

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

    $hWndListView1 = GUICtrlGetHandle($ListViewEvents)
    $hWndListView2 = GUICtrlGetHandle($ListViewVolunteers)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView1
            Switch $iCode
;               Case $LVN_COLUMNCLICK ; A column was clicked
;                   $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
;                   ; Kick off the sort callback
;                   _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
;               Case $LVN_ITEMCHANGING ; An item is changing
;                   $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
;                   Return True ; prevent the change
                    ;Return False ; allow the change
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You clicked on: " & $text)
;                    _GUICtrlListView_SetItemSelected($ListViewEvents, DllStructGetData($tInfo, "Index"))
Return $GUI_RUNDEFMSG
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
Return $GUI_RUNDEFMSG
; DO EDIT HERE
                    ; No return value
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    $text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You hit ENTER on: " & $text)
            EndSwitch

        Case $hWndListView2
            Switch $iCode
;               Case $LVN_COLUMNCLICK ; A column was clicked
;                   $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
                    ; Kick off the sort callback
;                   _GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, "SubItem"))
                    ; No return value
;               Case $LVN_ITEMCHANGING ; An item is changing
;                   $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
;                   Return True ; prevent the change
                    ;Return False ; allow the change
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You clicked on: " & $text)
;                    _GUICtrlListView_SetItemSelected($ListViewVolunteers, DllStructGetData($tInfo, "Index"))

;Return $GUI_RUNDEFMSG
                    ; No return value
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
;Return $GUI_RUNDEFMSG
                    ; No return value
; DO EDIT HERE
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    $text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You hit ENTER on: " & $text)
                    ; No return value
; DO EDIT HERE
            EndSwitch
    EndSwitch

    ; And here we call the UDF WM_NOTIFY handler
    _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $iwParam, $ilParam)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

Nothing to do with me - that is because you added the $LVS_SORTDECENDING style to the ListView. :P

So it sorts as you are adding the data and therefore get very confused. Remove that style and you get the full list again. ;)

If you really want to, you can sort the data very easily once it is inserted by calling the _GUICtrlListView_SimpleSort function. Registering the WM_NOTIFY message via the UDF as I explained a few posts above will then let the UDF look after the sorting for you. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

_GUICtrlListView_SimpleSort() requires 2nd arg to be an array, which I suppose after I populate the listview, I could use

_GUIListViewEx_Return_Array() but even the Help example is only performed when the user clicks the column -- I already have that.

So do I call it like this after populating the list?

_GUICtrlListView_SimpleSort($ListViewEvents, _GUIListViewEx_Return_Array($iLV_Events, 0), 2)

If you look at the Help example, it's confusing because the array $B_DESCENDING appears to be an empty array

But I should be able to simply call

_GUICtrlListView_SimpleSort($ListViewEvents, True, 2) ; column 2 because 1 is the hidden key

Does that sound right?

BTW, any idea why the Case $NM_RETURN doesn't work when Click and Double-Click work?

Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

You have misunderstood how _GUICtrlListView_SimpleSort works - and you ar enot alone in this. The array is a variable (array for multiple columns) which holds the sort state of the ListView:

- Empty or Descending = Next sort acending

- Ascending = Next sort decending.

See this post for a commented example and posts lower down for how to sort on fill. :)

BTW, any idea why the Case $NM_RETURN doesn't work when Click and Double-Click work?

Looking at the code now. I was eating dinner earlier. ;)

M23

Edit: And then doing my Mod thing - looking now. :)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

My best guess - ListViews created with the native function do not react to that message. I cannot get $LVN_KEYDOWN to register either. :(

I will look again tomorrow, but please do not hold your breath. I will also look to see how we might detect Enter being pressed in other ways. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Garp99HasSpoken,

That was an interesting experiment. :)

It seems neither native nor UDF created ListViews respond to the NM_RETURN message - and LVS_KEYDOWN fires on every key other then ENTER. :wacko:

I am afraid it will need someone with a lot more knowledge that I have about the inner workings of Windows messages to explain why - all I can do is suggest that you use an Accelerator key to detect ENTER being pressed when your ListView has focus: ;)

#include 
#include 
#include 
#include 

Global $cListView

Example()

Func Example()

    GUICreate("Test", 500, 500)

    $cListView = GUICtrlCreateListView("Col 1  |Col 2  |Col 3  ", 10, 10, 200, 150)

    $cItem1 = GUICtrlCreateListViewItem("item 01|Sub 12|Sub 13", $cListView)
    $cItem2 = GUICtrlCreateListViewItem("item 02|Sub 22|Sub 23", $cListView)
    $cItem3 = GUICtrlCreateListViewItem("item 03|Sub 32|Sub 33", $cListView)

    $cButton = GUICtrlCreateButton("Test", 10, 400, 80, 30)

    $cDummy_Enter = GUICtrlCreateDummy()

    GUISetState()

    GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

    ; Set GUIAccelerators for ENTER
    Local $aAccelKeys[1][2] = [["{ENTER}", $cDummy_Enter]]
    GUISetAccelerators($aAccelKeys)


    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $cDummy_Enter
                If _WinAPI_GetFocus() = GUICtrlGetHandle($cListView) Then
                    MsgBox(0, "Hi", "Enter pressed with ListView focused")
                EndIf
        EndSwitch
    WEnd

EndFunc   ;==>Example

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $iIDFrom
        Case $cListView
            Switch $iCode
                Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
                    ConsoleWrite("Enter" & @CRLF)
                Case $LVN_KEYDOWN ; A key has been pressed
                    ConsoleWrite("Key Down" & @CRLF)
                Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
                    ConsoleWrite("L Click" & @CRLF)
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    ConsoleWrite("L Double" & @CRLF)
                Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
                    ConsoleWrite("R Click" & @CRLF)
                Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
                    ConsoleWrite("R Double" & @CRLF)

           EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Try focusing the button and then pressing ENTER to confirm it needs ListView focus. Please ask if you have any questions about Accelerator keys - think HotKey but only active when your GUI is active. :)

As to the date question - why not convert to a suitable format (Julian or YYYY/MM/DD) and add another hidden column which you can then sort easily? However, you will probably need to play around in the sort routines to get clicks on the visible colum to sort on the hidden one - but that I leave to you. Or just convert all the dates into a suitable format using the UDF I showed you in another of your many threads and sort them directly. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

The NU_RETURN issue has been discussed quite a bit in regards to Listviews.

This might be of interest.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • Moderators

BrewManNH,

I had forgotten that thread - at least I am consistent in my proposed solutions! :D

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Melba, at least you're learning new things because of my project. o:)

I'll look into the date stuff more, or I may just simplify my life and use yyyy/mm/dd and only change it if the wife asks for a change.

I was able to get my example working with two ListViews and only 1 dummy enter button with accel key.

Here's the latest test code I now have working with ENTER and Double-Click on a ListView item will now call the Edit function.

;Autoit Options
; #NoTrayIcon ;No Tray Icon
Opt("GUIOnEventMode", 1)
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 3) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("GUICloseOnESC", 0) ;1=ESC  closes, 0=ESC won't close
Opt("GUIResizeMode", 802)
; Opt("GUIResizeMode", 1)


#Include <String.au3>
#include <Date.au3>
#Include <WinAPI.au3>
#include <File.au3>
#include <GuiTab.au3>
;#include <GDIPlus.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GuiScrollBars.au3>
#include <GuiStatusBar.au3>
#include <GuiToolbar.au3>

; Constants includes
#include <ListViewConstants.au3>
#include <TabConstants.au3>
#include <ToolbarConstants.au3>
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <DateTimeConstants.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

; Tab groups
Global Const $L_VOLUNTEERS =    "  Volunteers  "
Global Const $L_VOLUNTEER =    "Volunteer"
Global Const $L_EVENTS =        "  Events  "
Global Const $L_EVENT =        "Event"

; Tab items
Global Const $T_Event =        0
Global Const $T_Volunteer =    1

; Menus
Global Const $M_EVENT =        "Even&t"
Global Const $M_VOLUNTEER =    "&Volunteer"
Global Const $M_OPTIONS =        "&Go To..."
Global Const $M_ADD =            "Add "
Global Const $M_EDIT =        "Edit "
Global Const $M_DELETE =        "Delete "

; Prompts
Global Const $L_AREYOUSURE =    "Are You Sure?"
Global Const $L_CANCELEXIT =    "Cancel all changes and exit?"

;Versions Info
Global $ProgName = "Volunteer Coordinator"
Global $VersionBuild = "20130213"     ;YEAR|MON|DAY
Global $ProgVersion = "0.1"
GLOBAL $AboutVersion = "2013.02.13 (" & $ProgVersion & ")"

Global $ProgWidth =1024, $ProgHeight = 720

Local $sWidth = 400, $sHeight = 350
Local $hToolbar = 40, $hStatus = 40, $hTabs = $hToolbar+30, $hLists = ($ProgHeight - $hTabs - $hStatus - $hToolbar)

#Region ### START Koda GUI section ### Form=R:\AutoIt Examples\koda_2008-09-03\Forms\VolunteerCoordinator.kxf
Global $MainForm = GUICreate($ProgName, $ProgWidth, $ProgHeight, (@DesktopWidth - $ProgWidth) / 2, (@DesktopHeight - $ProgHeight) / 2, $WS_SIZEBOX + $WS_SYSMENU )
GUISetState(@SW_HIDE)
GUISetBkColor(0xA6CAF0)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESTORE, "")
Global $TabVol = GUICtrlCreateTab(1, $hTabs-$hToolbar, $ProgWidth-2, $hToolbar, $TCS_TABS)
GUICtrlSetOnEvent($TabVol, "TabVolClick")                ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Tried adding this
GUICtrlSetFont(-1, 12, 400, 0, "Arial")
GUICtrlSetResizing(-1, $GUI_DOCKAUTO)

Global $TabSheetEvents = GUICtrlCreateTabItem($L_EVENTS)
Global $ListViewEvents = GUICtrlCreateListView( _
        "|Date                         |Type           |Volunteers                                                                                                   ", _
        2, $hTabs, $ProgWidth-4, $hLists, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL))
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
$iLV_Events = _GUIListViewEx_Init($ListViewEvents, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Events)
EventFullList()
_GUICtrlListView_SetColumnWidth($ListViewEvents, 0, 0)    ; hidden
For $i=1 To 3
    _GUICtrlListView_SetColumnWidth($ListViewEvents, $i, $LVSCW_AUTOSIZE_USEHEADER)
Next
GUICtrlSetOnEvent($ListViewEvents, "ListViewEventsClick")

Global $TabSheetVolunteers = GUICtrlCreateTabItem($L_VOLUNTEERS)
GUICtrlSetOnEvent($TabSheetVolunteers, "ListViewVolunteersClick")    ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Tried adding this
Global $ListViewVolunteers = GUICtrlCreateListView( _
        "|Name              |Type        |Home      |Work       |Cell       |Address                 |City      |Prov|Postal|Notes                             ", _
        2, $hTabs, $ProgWidth-4, $hLists, BitOr($LVS_SHOWSELALWAYS, $LVS_SINGLESEL))
GUICtrlSetFont($ListViewVolunteers, 10, 400, 0, "MS Sans Serif")

; Initiate LVEx - no count parameter - default insert mark colour (black)
$iLV_Volunteers = _GUIListViewEx_Init($ListViewVolunteers, "", 0, 0, True, True)
_GUIListViewEx_SetActive($iLV_Volunteers)
VolunteerFullList()
_GUICtrlListView_SetColumnWidth($ListViewVolunteers, 0, 0)    ; hidden
For $i=1 To 10
    _GUICtrlListView_SetColumnWidth($ListViewVolunteers, $i, $LVSCW_AUTOSIZE_USEHEADER)
Next
Local $fSort = False        ; passed ByRef
_GUICtrlListView_SimpleSort($ListViewVolunteers, $fSort, 1)
GUICtrlSetOnEvent($ListViewVolunteers, "ListViewVolunteersClick")

GUICtrlCreateTabItem("")    ;end of tabs

Global $DummyEnter = GUICtrlCreateDummy()
GUICtrlSetOnEvent($DummyEnter, "ListViewEnterClick")

;==> EVENT menu
Local $MenuEvent = GUICtrlCreateMenu($M_EVENT)
Local $MenuEventAdd = GUICtrlCreateMenuItem($M_ADD & $L_EVENT & @tab & "F9", $MenuEvent)
GUICtrlSetOnEvent(-1, "MenuEventAddClick")
Local $MenuEventEdit = GUICtrlCreateMenuItem($M_EDIT & $L_EVENT & @tab & "F10", $MenuEvent)
GUICtrlSetOnEvent(-1, "MenuEventEditClick")
Local $MenuEventDelete = GUICtrlCreateMenuItem($M_DELETE & $L_EVENT & @tab & "", $MenuEvent)
GUICtrlSetOnEvent(-1, "MenuEventDeleteClick")

;==> VOLUNTEER menu
Local $MenuVolunteer = GUICtrlCreateMenu($M_VOLUNTEER)
Local $MenuVolunteerAdd = GUICtrlCreateMenuItem($M_ADD & $L_VOLUNTEER & @tab & "F11", $MenuVolunteer)
GUICtrlSetOnEvent(-1, "MenuVolunteerAddClick")
Local $MenuVolunteerEdit = GUICtrlCreateMenuItem($M_EDIT & $L_VOLUNTEER & @tab & "F12", $MenuVolunteer)
GUICtrlSetOnEvent(-1, "MenuVolunteerEditClick")
Local $MenuVolunteerDelete = GUICtrlCreateMenuItem($M_DELETE & $L_VOLUNTEER & @tab & "", $MenuVolunteer)
GUICtrlSetOnEvent(-1, "MenuVolunteerDeleteClick")

;==> OPTIONS menu
Local $MenuOptions = GUICtrlCreateMenu($M_OPTIONS)
Local $MenuEventDates = GUICtrlCreateMenuItem($L_EVENT & " Dates" & @tab & "F5", $MenuOptions)
GUICtrlSetOnEvent(-1, "ListViewEventsClick")
Local $MenuVolList = GUICtrlCreateMenuItem($L_VOLUNTEER & " List" & @tab & "F6", $MenuOptions)
GUICtrlSetOnEvent(-1, "ListViewVolunteersClick")

Local $MainForm_AccelTable[10][2] = [ _
        ["^!t", $MenuEvent],["{F9}", $MenuEventAdd],["{F10}", $MenuEventEdit], _
        ["^!v", $MenuVolunteer],["{F11}", $MenuVolunteerAdd],["{F12}", $MenuVolunteerEdit], _
        ["^!g", $MenuOptions],["{F5}", $MenuEventDates],["{F6}", $MenuVolList],["{ENTER}", $DummyEnter] _
]
GUISetAccelerators($MainForm_AccelTable, $MainForm)

Global $StatusBar = _GUICtrlStatusBar_Create($MainForm)
_GUICtrlStatusBar_SetSimple($StatusBar)
_GUICtrlStatusBar_SetText($StatusBar, "Simple status bar window text goes here.")
_GUICtrlStatusBar_SetMinHeight($StatusBar, $hStatus)

GUISetFont(10, 400, 0, "MS Sans Serif", $MainForm)
GUISetOnEvent($GUI_EVENT_CLOSE, "MainFormClose")
GUISetOnEvent($GUI_EVENT_RESTORE, "")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "")
GUISetOnEvent($GUI_EVENT_RESIZED, "")

_GUIListViewEx_DragRegister(True, False, False)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

#EndRegion ### END Koda GUI section ###

GUISwitch($MainForm)
GUISetState(@SW_SHOW)

; Set the Events ListView as active
;_GUIListViewEx_SetActive($iLV_Events)
ListViewEventsClick()        ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< should set Volunteer menu options to DISABLED

While 1
    sleep(100)
WEnd

GUISetState(@SW_HIDE)
GUIDelete()
_GUIListViewEx_Close($iLV_Events)
_GUIListViewEx_Close($iLV_Volunteers)
GUIRegisterMsg($WM_NOTIFY, "")
Exit

Func MainFormClose()
  Exit
EndFunc   ;==>MainFormClose

Func EventFullList()
    _GUIListViewEx_Insert("1|September 23, 2012|AM|Sheila Blue,Dan Black")
    _GUIListViewEx_Insert("2|December  3, 2012|Afternoon|Dan Black,Paul Green")
    _GUIListViewEx_Insert("3|February 18, 2013|11:00-18:00|Sheila Blue,Dan Black,Paul Green")
    _GUIListViewEx_Insert("6|February 14, 2013|Evening|Mary Pigment,Dan Black,Paul Green")
    _GUIListViewEx_Insert("7|January 31, 2013|All Day|Mary Pigment,Dan Black,Sheila Blue,Paul Green")
EndFunc   ;==>EventFullList

Func VolunteerFullList()
    _GUIListViewEx_Insert("1|Dan Black|Parent|(514)345-6789|(514)345-9876|(608)345-1234|253 Temple Drive|Montreal|QC|H2N3M4|Coordinator")
    _GUIListViewEx_Insert("2|Sheila Blue|Other|(514)345-7733|(514)655-4562|(608)345-1234|123 Templeton|Montreal|QC|H2N4Q3|Old Coordinator")
    _GUIListViewEx_Insert("6|Mary Pigment|Staff|(519)242-2020|(519)356-0176|(519)675-1201|21st Avenue|London|ON|J7S5M9|Principal")
    _GUIListViewEx_Insert("7|Paul Green|Friend / Family|(514)349-6699|(514)349-5555|(514)698-9857|423 Happle / Apt 12|Toronto|ON|L4P9J8|")
EndFunc   ;==>VolunteerFullList

Func ListViewEventsClick()
    _GUICtrlTab_SetCurFocus($TabVol, $T_Event)
    _GUIListViewEx_SetActive($iLV_Events)
    GUICtrlSetState($MenuEventEdit, $GUI_ENABLE)
    GUICtrlSetState($MenuEventDelete, $GUI_ENABLE)
    GUICtrlSetState($MenuVolunteerEdit, $GUI_DISABLE)
    GUICtrlSetState($MenuVolunteerDelete, $GUI_DISABLE)
EndFunc   ;==>ListViewEventsClick

Func ListViewVolunteersClick()
    _GUICtrlTab_SetCurFocus($TabVol, $T_Volunteer)
    _GUIListViewEx_SetActive($iLV_Volunteers)
    GUICtrlSetState($MenuEventEdit, $GUI_DISABLE)
    GUICtrlSetState($MenuEventDelete, $GUI_DISABLE)
    GUICtrlSetState($MenuVolunteerEdit, $GUI_ENABLE)
    GUICtrlSetState($MenuVolunteerDelete, $GUI_ENABLE)
EndFunc   ;==>ListViewVolunteersClick

Func TabVolClick()
    Switch GUICtrlRead($TabVol)
        Case $T_Event
;           MsgBox(0, "Hi", "Event Tab selected")
            ListViewEventsClick()
        Case $T_Volunteer
;           MsgBox(0, "Hi", "Volunteer Tab selected")
            ListViewVolunteersClick()
    EndSwitch
EndFunc   ;==>TabVolClick

Func ListViewEnterClick()
    Switch GUICtrlRead($TabVol)
        Case $T_Event
            If _WinAPI_GetFocus() = GUICtrlGetHandle($ListViewEvents) Then
                MsgBox(0, "Hi", "Enter pressed with Event ListView focused")
                MenuEventEditClick()
            EndIf
        Case $T_Volunteer
            If _WinAPI_GetFocus() = GUICtrlGetHandle($ListViewVolunteers) Then
                MsgBox(0, "Hi", "Enter pressed with Volunteer ListView focused")
                MenuVolunteerEditClick()
            EndIf
    EndSwitch
EndFunc   ;==>ListViewEnterClick

Func MenuEventAddClick()
    ListViewEventsClick()
;    CreateEvent(False, $MainForm)
    MsgBox(0, "Add", "Add new Event", 5)
    GUISetState(@SW_SHOW)
EndFunc   ;==>MenuEventAddClick

Func MenuEventEditClick()
    ListViewEventsClick()
    $id = GUICtrlRead($ListViewEvents)
    If ($id = 0) Then
        MsgBox(36, "Error", "Nothing selected in the list for Editing", 5)
    Else
;        InitEvent(GUICtrlRead($id))
;        CreateEvent(True, $MainForm)
        MsgBox(0, "Edit", "ID (" & $id & ")", 5)
    EndIf
    GUISetState(@SW_SHOW)
EndFunc   ;==>MenuEventEditClick

Func MenuEventDeleteClick()
    ListViewEventsClick()
    $id = GUICtrlRead($ListViewEvents)
    If ($id = 0) Then
        MsgBox(36, "Error", "Nothing selected in the list for deletion.", 5)
    Else
        $str = StringSplit(GUICtrlRead($id), "|", 1)
        if (MsgBox(36, $L_AREYOUSURE, $M_DELETE & $L_EVENT & "'" & $str[2] & ", " & $str[3] & "'?") = 6) Then
;            EventDeleteKey($str[1])
            _GUIListViewEx_Delete()
            MsgBox(0, "DELETE'd", "Key (" & $str[1] & ")", 5)
        EndIf
    EndIf
EndFunc   ;==>MenuEventDeleteClick

Func MenuVolunteerAddClick()
    ListViewVolunteersClick()
;    CreateVolunteer(False, $MainForm)
    MsgBox(0, "Add", "Add new Volunteer", 5)
    GUISetState(@SW_SHOW)
EndFunc   ;==>MenuVolunteerAddClick

Func MenuVolunteerEditClick()
    ListViewVolunteersClick()
    $id = GUICtrlRead($ListViewVolunteers)
    If ($id = 0) Then
        MsgBox(36, "Error", "Nothing selected in the list for Editing", 5)
    Else
;        InitVolunteer(GUICtrlRead($id))
;        CreateVolunteer(True, $MainForm)
        MsgBox(0, "Edit", "ID (" & $id & ")", 5)
    EndIf
    GUISetState(@SW_SHOW)
EndFunc   ;==>MenuVolunteerEditClick

Func MenuVolunteerDeleteClick()
    ListViewVolunteersClick()
    $id = GUICtrlRead($ListViewVolunteers)
    If ($id = 0) Then
        MsgBox(36, "Error", "Nothing selected in the list for deletion.", 5)
    Else
        $str = StringSplit(GUICtrlRead($id), "|", 1)
        if (MsgBox(36, $L_AREYOUSURE, $M_DELETE & $L_VOLUNTEER & "'" & $str[2] & "'?") = 6) Then
;            VolunteerDeleteKey($str[1])
            _GUIListViewEx_Delete()
            MsgBox(0, "DELETE'd", "Key (" & $str[1] & ")", 5)
        EndIf
    EndIf
EndFunc   ;==>MenuVolunteerDeleteClick

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo

    $hWndListView1 = GUICtrlGetHandle($ListViewEvents)
    $hWndListView2 = GUICtrlGetHandle($ListViewVolunteers)

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom
        Case $hWndListView1
            Switch $iCode
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewEvents, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
                    MenuEventEditClick()
                    ; No return value
            EndSwitch

        Case $hWndListView2
            Switch $iCode
                Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
                    $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $text = _GUICtrlListView_GetItemText($ListViewVolunteers, DllStructGetData($tInfo, "Index"))
                    _GUICtrlStatusBar_SetText($StatusBar, "You double-clicked on: " & $text)
                    MenuVolunteerEditClick()
                    ; No return value
            EndSwitch
    EndSwitch

    ; And here we call the UDF WM_NOTIFY handler
    _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $iwParam, $ilParam)

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
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...