Jump to content
Melba23

GUIListViewEx - BugFix Version 15 Sep 20

Recommended Posts

NassauSky,

If you want to run your own functions for doubleclicks on specific columns you can do so by setting the $iMode parameter in the _GUIListViewEx_SetEditStatus function to 9 as explained in the header for that function within the UDF. Here is a short example to show it working:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

; Create GUI
$hGUI = GUICreate("LVEx Example", 320, 320)

$cListView = GUICtrlCreateListView("Tom|Dick|Harry", 10, 10, 300, 300, $LVS_SHOWSELALWAYS)
_GUICtrlListView_SetExtendedListViewStyle($cListView, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES))
_GUICtrlListView_SetColumnWidth($cListView, 0, 93)
_GUICtrlListView_SetColumnWidth($cListView, 1, 93)
_GUICtrlListView_SetColumnWidth($cListView, 2, 93)

; Create array and fill listview
Global $aLV_List[10]
For $i = 0 To UBound($aLV_List) - 1
    If Mod($i, 5) Then
        $aLV_List[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i
    Else
        $aLV_List[$i] = "Tom " & $i & "||Harry " & $i
    EndIf
    GUICtrlCreateListViewItem($aLV_List[$i], $cListView)
Next

; Initiate LVEx
$iLV_Index = _GUIListViewEx_Init($cListView, $aLV_List)

; Column 2 - editable as normal
_GUIListViewEx_SetEditStatus($iLV_Index, "2")
; Column 1 - run function MsgBox_1
_GUIListViewEx_SetEditStatus($iLV_Index, "1", 9, _MsgBox_1)
; Column 0 - run function MsgBox_0
_GUIListViewEx_SetEditStatus($iLV_Index, "0", 9, _MsgBox_0)

; Register messages
_GUIListViewEx_MsgRegister()

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    _GUIListViewEx_EventMonitor()

WEnd

Func _MsgBox_1($hLV, $iIndexLV, $iRow, $iCol)

    MsgBox($MB_SYSTEMMODAL, "Column 1 clicked", "Row = " & $iRow)

EndFunc

Func _MsgBox_0($hLV, $iIndexLV, $iRow, $iCol)

    MsgBox($MB_SYSTEMMODAL, "Column 0 clicked", "Row = " & $iRow)

EndFunc

Lines #29-34 do the magic! Please ask if you have any further questions.

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

 

Share this post


Link to post
Share on other sites

@Melba23 Nice. Each reference in the the teasers in GUIListViewEx.au3 about the function _GUIListViewEx_SetEditStatus mentioned edit so I wasn't thinking it had the custom click event monitoring 🙂

Though I did easily add the code to my existing project. It is giving an error just for when I click on a cell in column 2 which I enabled edit.  The error below displays after I press enter.

GUIListViewEx.au3" (4910) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$aGLVEx_SrcArray[$aLocation[0] + 1][$aLocation[1]] = $sItemNewText
^ ERROR

What do you think?

Share this post


Link to post
Share on other sites

NassauSky,

Quote

What do you think?

I think if you posted some code which showed the problem I might be able to look into it! Otherwise I have no idea at all what might be going on.

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

 

Share this post


Link to post
Share on other sites

I was digging and digging and was stripping my program down to post code and I found the problem and maybe could use your advice again.

When I prepopulate the listview knowing how many elements I need in the listview before time then it works fine:

; Create array and fill listview
Global $aLV_List[10]
For $i = 0 To UBound($aLV_List) - 1
   $aLV_List[$i] = $i & "|Desc " & $i & "||Cmd " & $i & "|https://www.mysite.com"
   GUICtrlCreateListViewItem($aLV_List[$i], $idListview)
Next

but if my array is dynamic then it crashes.

I tried to prepopulate the listview with the above code then run

$hListview=GUICtrlGetHandle($idListView)
   _GUICtrlListView_DeleteAllItems($hListview)

to quickly clear the values since I read somewhere that it's faster than using _GUICtrlListView_DeleteAllItems().

Each time I call my function I want it to clear the listview and repopulate it dynamically

Func myFunc()
   _WD_Navigate($sSession, $sURL)
   $pageSource = _WD_GetSource($sSession) ; Gets source code on page
   Local $aMatches = StringRegExp($pageSource, "<food>(.*?)XX(.*?)</food>", $STR_REGEXPARRAYGLOBALFULLMATCH) ; Returns full array of matches
   Global $aLV_List[UBound($aMatches)]
   For $i = 0 To UBound($aMatches) - 1
      $fieldID=$aMatches[$i]
      If StringLen($fieldID[2]) > 5 Then 
         $sElement = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, "//div[contains(@mydata,""" & $fieldID[2] & """)]") 
         $sValue1 = _WD_ElementAction($sSession, $sElement, "property", "outerHTML")
         _WD_HighlightElement($sSession, $sElement, 3)  ;3=style -> Highlight yellow rounded box + border  dotted red
         $col0= $fieldID[2]                           ; Add ID Column
         $col1= $fieldID[1]                           ; Add Description Column
         $col2= ""                                    ; Add Value Column
         $col3= ""&entry." & $fieldID[2] & "=""       ; Add CmdLine Column
         $col4= $sUrl & "&entry." & $fieldID[2] & "=" ; Add FullUrl Column
         ;GUICtrlCreateListViewItem($col0&"|"&$col1&"|"&$col2&"|"&$col3&"|"&$col4, $idListView)
         $aLV_List[$i] = $col0&"|"&$col1&"|"&$col2&"|"&$col3&"|"&$col4
         GUICtrlCreateListViewItem($aLV_List[$i], $idListview)
      EndIf
   Next
EndFunc

Make sense?

Share this post


Link to post
Share on other sites

NassauSky,

No, but I can guess why you are having the problem. Once you are working with the GUIListViewEx UDF everything you do to the ListView must be done using the UDF functions - if you are deleting and recreating elements of the ListView using standard functions then the UDF does not "know" what is in the ListView and you will very likely get an error similar to the one you saw.

As explained in the guide that i wrote and which is part of the download, if you want to clear and reload the ListView you need to do as follows:

Quote

Closure and Reloading:

 [...]

If you wish to reload the ListView with new data, you will need to clear the current content using _GUICtrlListView_DeleteAllItems, close it within the UDF using _GUIListViewEx_Close, reload the ListView with the new data and then reinitialise it using _GUIListViewEx_Init. Otherwise the UDF will become confused about the current content and errors will certainly occur.

Then the UDF knows what is currently in the ListView and will not get confused and show an error when it is asked to edit a cell that it does not think exists.

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

 

Share this post


Link to post
Share on other sites

NassauSky,

Delighted you got it working.

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

 

Share this post


Link to post
Share on other sites

I have a question, how can I add a local image (JPG) to a specific row number in a column using this UDF ?

Or is there anyway to use GDI+ and add an image like the one attached ?

 

 

Spoiler

Tick_Mark_Dark-512.png

 

Edited by Siwa
Request for GDI+

Share this post


Link to post
Share on other sites
9 hours ago, Siwa said:

how can I add a local image (JPG) to a specific row number

#include <GUIConstantsEx.au3>
#include <GuiImageList.au3>
#include <GuiListView.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
  GUICreate("ListView Get/Set Item StateImage (v" & @AutoItVersion & ")", 400, 300)
  Local $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
  _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
  GUISetState(@SW_SHOW)

  Local $hImage = _GUIImageList_Create(13, 13)
  Local $hBitMap = _WinAPI_LoadImage(0, "Check.bmp", $IMAGE_BITMAP, 0, 0, $LR_LOADFROMFILE)
  _GUIImageList_Add($hImage, $hBitMap)
  _WinAPI_DeleteObject($hBitMap)

  _GUICtrlListView_SetImageList($idListview, $hImage, 2)

  _GUICtrlListView_AddColumn($idListview, "Column 1", 120)
  _GUICtrlListView_AddColumn($idListview, "Column 2", 100)
  _GUICtrlListView_AddColumn($idListview, "Column 3", 100)

  _GUICtrlListView_AddItem($idListview, "Row 1: Col 1", 0)
  _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 2", 1)
  _GUICtrlListView_AddSubItem($idListview, 0, "Row 1: Col 3", 2)
  _GUICtrlListView_AddItem($idListview, "Row 2: Col 1", 1)
  _GUICtrlListView_AddSubItem($idListview, 1, "Row 2: Col 2", 1)
  _GUICtrlListView_AddItem($idListview, "Row 3: Col 1", 2)

  _GUICtrlListView_SetItemStateImage($idListview, 1, 1)

  Do
  Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>Example

To run this script convert your jpg into bmp

Edited by Nine
Remove useless loop

Share this post


Link to post
Share on other sites

So many thanks for your help @Nine, as this was what I was looking for, but unfortunately it is not helping me, because the image is not inserted into @Melba23's listview GUI and is placed outside of the columns. 

I guess I have to seek for a GDI+ replacement for my problem.

Share this post


Link to post
Share on other sites

Siwa,

The UDF does not handle images in the ListView - sorry about that.

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

 

Share this post


Link to post
Share on other sites

Siwa,

The UDF creates a "shadow array" to store the content of the ListView which is used to manipulate the content when the ListView content is altered and is then used to redraw the new ListView. This array is limited to text only, so no form of image is possible if you intend to do anything fancy with the content.

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

 

Share this post


Link to post
Share on other sites

I have another question, if a cell has some data in it, how can I delete the data only on a single cell ? I tried 

_GUIListViewEx_ChangeItem($iLV_Index, $i, 5, "")

with no luck.  ( Those cells update during the code )

Btw, Can I later change the background color for a previously colored cell ? Because this did not work neither.

PS : I'm using   _GUIListViewEx_BlockReDraw , But even after usnig  __GUIListViewEx_RedrawWindow($iLV_Index) nothing was changed

Edited by Siwa

Share this post


Link to post
Share on other sites

Siwa,

Both of those functions should work - although it is certain that _BlockReDraw could interfere with showing the results. You do turn redrawing back on again later?

But as always I need a short reproducer script so that I can debug - without that there is not a lot I can do.

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

 

Share this post


Link to post
Share on other sites

It was an error from my coding 🙂, it actually was working.

There is another problem I wan to fix, is there anyway to have a hidden column, and set the tooltip to show it ?

And is it possible to only show the tooltip when the mouse is only on a single cell instead of the entire row ? 

Share this post


Link to post
Share on other sites

Siwa,

Glad you got your code working.

I do not understand the "tooltip" questions. If a column is hidden, how do you expect to show a UDF-generated tooltip which requires you to click on an item to display? And UDF-generated tooltips are set for a column, not a row, Can you clarify the question please.

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

 

Share this post


Link to post
Share on other sites

Dear Melba23, 

lets say I have 5 columns visible, then I want some extra information to be displayed when the mouse is on column 4, this information is related to this row and contains more details about column 4 of this row, but I don't want it to be seen unless the mouse is only at column 4. 

And I don't want to add a visible column to my GUI, instead I want to save the details in a separate column to be invisible to the user, but only show the contet as an tooltip when mouse is on cloumn4.

And I have another question too, how can I define click event on your listview ?

For example when I click on any row, lets say, a message pops up.

 

Edited by Siwa

Share this post


Link to post
Share on other sites

Siwa,

The best I can come up with is showing a tooltip showing the hidden data when an item is double-clicked - as shown in this example script. Double-click a "Tom" and the corresponding "Dora" is displayed:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>

#include "GUIListViewEx.au3"

#include <Array.au3> ; Just for display in example

Global $iCount_Left = 20, $iCount_Right = 20, $vData, $aRet, $iEditMode = 0

; Create GUI
$hGUI = GUICreate("LVEx Example 2", 640, 430)

; Create Left ListView
GUICtrlCreateLabel("Native ListView", 10, 5, 300, 35)
$cListView_Left = GUICtrlCreateListView("Tom|Dora", 10, 40, 250, 300, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
_GUICtrlListView_SetExtendedListViewStyle($cListView_Left, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($cListView_Left, 0, 229)
_GUICtrlListView_SetColumnWidth($cListView_Left, 1, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Create array and fill Left listview
Global $aLV_List_Left[$iCount_Left + 1] = [$iCount_Left]
For $i = 1 To UBound($aLV_List_Left) - 1
    $aLV_List_Left[$i] = "Tom " & $i - 1 & "|Dora " & $i - 1
    GUICtrlCreateListViewItem($aLV_List_Left[$i], $cListView_Left)
Next

; Initiate LVEx - count parameter set - blue insert mark- no drag image
$iLV_Left_Index = _GUIListViewEx_Init($cListView_Left, $aLV_List_Left, 1, 0x0000FF, False, 512)

; DoubleClick on col 0 runs function to show tooltip
_GUIListViewEx_SetEditStatus($iLV_Left_Index, 0, 9, _HiddenColShow) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Create Right ListView
GUICtrlCreateLabel("UDF ListView", 380, 5, 300, 35)
$hListView_Right = _GUICtrlListView_Create($hGUI, "Peter", 380, 40, 250, 300, BitOR($LVS_SHOWSELALWAYS, $LVS_REPORT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_SetColumnWidth($hListView_Right, 0, 229)
_GUICtrlListView_SetInsertMarkColor($hListView_Right, 0)

; Create array and fill listview
Global $aLV_List_Right[$iCount_Right]
For $i = 0 To UBound($aLV_List_Right) - 1
    $aLV_List_Right[$i] = "Peter " & $i
    _GUICtrlListView_AddItem($hListView_Right, $aLV_List_Right[$i])
Next

; Initiate LVEx - no count - green insert parameter - no drag image
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 0, 0x00FF00)

; Create Edit Mode Combos
GUICtrlCreateLabel("Edit Modes", 280, 50, 60, 20)
GUICtrlCreateLabel("0" & @CRLF & "1" & @CRLF & "2" & @CRLF & "3", 280, 70, 10, 80)
GUICtrlCreateLabel(":  Single Edit" & @CRLF & ":  Exit Edge" & @CRLF & ":  Stay Edge" & @CRLF & ":  Loop Edge", 290, 70, 65, 80)
GUICtrlCreateLabel("Row Mode", 280, 140, 60, 20)
$cCombo_Row = GUICtrlCreateCombo("", 280, 160, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Row, "0|1|2|3", 0)
GUICtrlCreateLabel("Col Mode", 280, 200, 60, 20)
$cCombo_Col = GUICtrlCreateCombo("", 280, 220, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Col, "0|1|2|3", 0)
GUICtrlCreateLabel("ESC Mode", 280, 260, 75, 20)
$cCombo_Reset = GUICtrlCreateCombo("", 280, 280, 75, 20, 0x3) ; $CBS_DROPDOWNLIST
GUICtrlSetData($cCombo_Reset, "Exit Edit|Reset All", "Exit Edit")

; Create buttons
$cInsert_Button = GUICtrlCreateButton("Insert", 10, 350, 200, 30)
$cDelete_Button = GUICtrlCreateButton("Delete", 10, 390, 200, 30)
$cUp_Button = GUICtrlCreateButton("Move Up", 220, 350, 200, 30)
$cDown_Button = GUICtrlCreateButton("Move Down", 220, 390, 200, 30)
$cDisplay_Left_Button = GUICtrlCreateButton("Show Left", 430, 350, 100, 30)
$cDisplay_Right_Button = GUICtrlCreateButton("Show Right", 530, 350, 100, 30)
$cExit_Button = GUICtrlCreateButton("Exit", 430, 390, 200, 30)

GUISetState()

; Register for dragging and editing
_GUIListViewEx_MsgRegister()

; Set the right ListView as active
_GUIListViewEx_SetActive(2)

Switch _GUIListViewEx_GetActive()
    Case 0
        $sMsg = "No ListView is active"
    Case 1
        $sMsg = "The LEFT ListView is active" & @CRLF & "<--------------------------"
    Case 2
        $sMsg = "The RIGHT ListView is active" & @CRLF & "---------------------------->"
EndSwitch

;MsgBox(0, "Active ListView", $sMsg)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $cExit_Button
            Exit
        Case $cInsert_Button
            ; Prepare data  for insertion
            Switch $aGLVEx_Data[0][1]
                Case 1
                    ; Array format with single column native ListView
                    Global $vData[1] = ["Tom " & $iCount_Left]
                    $iCount_Left += 1
                    _GUIListViewEx_Insert($vData)
                Case 2
                    ; String format with single column UDF ListView
                    $vData = "Peter " & $iCount_Right
                    $iCount_Right += 1
                    _GUIListViewEx_Insert($vData)
            EndSwitch

        Case $cDelete_Button
            _GUIListViewEx_Delete()

        Case $cUp_Button
            _GUIListViewEx_Up()

        Case $cDown_Button
            _GUIListViewEx_Down()

        Case $cDisplay_Left_Button
            $aLV_List_Left = _GUIListViewEx_ReturnArray($iLV_Left_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Left, "Returned Left")
            Else
                MsgBox(0, "Left", "Empty Array")
            EndIf

        Case $cDisplay_Right_Button
            $aLV_List_Right = _GUIListViewEx_ReturnArray($iLV_Right_Index)
            If Not @error Then
                _ArrayDisplay($aLV_List_Right, "Returned Right")
            Else
                MsgBox(0, "Right", "Empty Array")
            EndIf

        Case $cCombo_Row
            Switch GUICtrlRead($cCombo_Row)
                Case 0
                    GUICtrlSetData($cCombo_Col, 0)
                Case Else
                    If GUICtrlRead($cCombo_Col) = 0 Then
                        GUICtrlSetData($cCombo_Col, GUICtrlRead($cCombo_Row))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Col
            Switch GUICtrlRead($cCombo_Col)
                Case 0
                    GUICtrlSetData($cCombo_Row, 0)
                Case Else
                    If GUICtrlRead($cCombo_Row) = 0 Then
                        GUICtrlSetData($cCombo_Row, GUICtrlRead($cCombo_Col))
                    EndIf
            EndSwitch
            $iEditMode = Number(GUICtrlRead($cCombo_Row) & GUICtrlRead($cCombo_Col))

        Case $cCombo_Reset
            ; Toggle edit mode value to switch ESC modes
            $iEditMode *= -1

    EndSwitch

    $vRet = _GUIListViewEx_EventMonitor($iEditMode) ; Use combos to change EditMode
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
    EndIf
    Switch @extended
        Case 0
            ; No event detected
        Case 1
            If $vRet = "" Then
                MsgBox($MB_SYSTEMMODAL, "Edit", "Edit aborted" & @CRLF)
            Else
                _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " content edited", Default, 8)
            EndIf
        Case 2
            If $vRet = "" Then
                MsgBox($MB_SYSTEMMODAL, "Header edit", "Header edit aborted" & @CRLF)
            Else
                _ArrayDisplay($vRet, "ListView " & _GUIListViewEx_GetActive() & " header edited", Default, 8)
            EndIf
        Case 3
            MsgBox($MB_SYSTEMMODAL, "Sorted", "ListView: " & $vRet & @CRLF)
        Case 4
            MsgBox($MB_SYSTEMMODAL, "Dragged", "From : To" & @CRLF & $vRet & @CRLF)
    EndSwitch

WEnd

Func _HiddenColShow($hListViewHandle, $iListViewIndex, $iRow, $iCol) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    ; Get ListView content
    Local $aContent = _GUIListViewEx_ReturnArray($iListViewIndex, 3)
    ; Get mouse pos
    $aMPos = MouseGetPos()
    ; Show tooltip with hidden data
    ToolTip($aContent[$iRow + 1][1], $aMPos[0], $aMpos[1])
    Sleep(2000)
    ToolTip("")

EndFunc

Look for the <<<<<<<<<<<<<<< lines to see how I did it.

Any use?

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

 

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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...