Jump to content

GUIListViewEx - Deprecated Version


Melba23
 Share

Recommended Posts

That makes sense, I know it's difficult or impossible to debug somebody else's incomplete code... I was just hoping that maybe the scenario might be something you've seen.  I'm not going to look at it further until Monday; I deliberately left it all in the office so I can't worry about it over the weekend, I have more interesting things to do. :)

Perhaps you could explain, though what the x and y parameters (I don't even have a copy of your udf here at the moment so I don't recall what exactly they're called) do... the documentation there is vague, it says something about "tweaking" the x and y positions, is that to adjust the edit field position, that might fix the first problem?

Have you seen problems when a second listview is created after _GUIListViewEx_Init has been executed on the first listview?  Once that second window (and listview) has been created, used, and deleted, even the original use of edititem that works fine before I use the new subroutine, no longer works after the subroutine is invoked (in the old version of your UDF).  Of course, I use a lot of _ArrayDisplay for debugging, which also creates temporary listviews, and that doesn't seem to hurt anything, hmmm, that might be a clue for me.

Also it's been a year since I last worked on this, and as you know it takes awhile to get your head back inside a program.

Link to comment
Share on other sites

  • Moderators

Dana,

Perhaps you could explain, though what the x and y parameters [...] do...

They allow single pixel adjustments to the location of the edit control in case there were problems with getting them exactly aligned. However it seems that this was not needed. :)

Other than the bugs reported in this thread I have not seen any problems with the UDF - although of course I have not explored every possible 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

 

Link to comment
Share on other sites

  • 2 weeks later...

HI Melba23

Quite an impressive UDF

I'm in the process of modifying it to suit my needs and i noticed you are using _GUICtrlListView_EndUpdate in _GUIListViewEx_ReWriteLV, but _GUICtrlListView_BeginUpdate is absent

I noticed the flicker is reduced/eliminated with that added

also, little typo -- find: WM_LBUTTONUPhandlers

replace: WM_LBUTTONUP handlers

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

Link to comment
Share on other sites

  • Moderators

iCode

Thanks for that - the _BeginUpdate line must have been overwritten at some point because it certainly used to be there! :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

EDIT: cancel this request, at least for now :)

There is allot more to be done than what i posted below

@Melba - small feature request to set the bkcolor of LV items since it's not so easy to figure out how to do it after they are created (can be done with _GUICtrlListView_GetItemParam() if anyone is interested)...

Func _GUIListViewEx_Insert($vData, $iBkColor = 0xFFFFFF)
...
    ; Rewrite ListView
    _GUIListViewEx_ReWriteLV($hGLVEx_SrcHandle, $cGLVEx_SrcID, $aGLVEx_SrcArray, $iArray_Index, $iBkColor = 0xFFFFFF)


Func _GUIListViewEx_ReWriteLV($hLVHandle, $cLV_CID, ByRef $aLV_Array, $iLV_Index, $iBkColor = 0xFFFFFF)
...
        ; Create item
        GUICtrlCreateListViewItem(StringTrimRight($sLine, 1), $cLV_CID)
        GUICtrlSetBkColor(-1, $iBkColor)
Edited by iCode

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

Link to comment
Share on other sites

  • Moderators

iahngy,

You do not need a UDF to do that: ;)

#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <GUIComboBox.au3>

$hGUI = GUICreate("Test", 500, 500)

$cListView = GUICtrlCreateListView("This is the ListView header", 10, 10, 200, 200)
$hCombo = _GUICtrlComboBox_Create(_GUICtrlListView_GetHeader($cListView), "", 0, 0, 100, 20)
For $i = 0 To 9
    _GUICtrlComboBox_AddString($hCombo, "Item " & $i)
Next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Good enough? :)

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,

How can I use the combox for any colum of header ? instead of just the 1st colum ? :)

without your GUIListViewEx.au3, can I still edit any colum at any row using the regular listview udf ? ( I remembered I couldn't :) )

Link to comment
Share on other sites

  • Moderators

iahngy,

 

How can I use the combox for any colum of header ? instead of just the 1st colum

Change the coordinates for the combo to match the header position. And before you ask, _GUICtrlListView_GetColumnWidth will help you work out where to put it. ;)

 

without your GUIListViewEx.au3, can I still edit any colum at any row using the regular listview udf

I think not - which is why I wrote the UDF. :)

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

Hi Melba,

I hve trouble with make list view editable.

I created the gui first with an empty list view and some buttons...the listview is only generated after it have an array2d returned from a sql querry. I saw from your example1, you filled the listview , init, _GUIListViewEx_MsgRegister(), then display gui.

How can I make it editable after gui already displayed and listview generated after gui.

Link to comment
Share on other sites

  • Moderators

iahngy,

Does this explain clearly enough how to do it? :)

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

#include "GUIListViewEx.au3"

$hGUI = GUICreate("Test", 500, 500)

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

; Create buttons
$cAdd = GUICtrlCreateButton("Add Data", 10, 350, 80, 30)
$cRead = GUICtrlCreateButton("Read Current", 150, 350, 80, 30)

GUISetState()

; Register messages
_GUIListViewEx_MsgRegister()

; Initiate ListView - no array - no count parameter - default insert mark colour (black) - no drag image - editable - default all cols editable
$iLV_Index = _GUIListViewEx_Init($cListView, "", 0, 0, True, 2 + 4)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cAdd
            _GUIListViewEx_SetActive($iLV_Index)

            ; Generate 2D array simulating SQL query
            Global $aData[3][3] = [["Tom 1", "Dick 1", "Harry 1"], _
                                    ["Tom 2", "Dick 2", "Harry 2"], _
                                    ["Tom 3", "Dick 3", "Harry 3"]]

            ; Split into separate rows for insertion
            Local $iCols = UBound($aData, $UBOUND_COLUMNS)
            Local $aLine[$iCols]
            For $i = 0 To UBound($aData) - 1
                For $j = 0 To $iCols - 1
                    $aLine[$j] = $aData[$i][$j]
                Next
                ; Insert each row
                _GUIListViewEx_Insert($aLine)
            Next

        Case $cRead
            ; Get array from ListView
            $aCurrent = _GUIListViewEx_ReturnArray($iLV_Index)
            If IsArray($aCurrent) Then
                _ArrayDisplay($aCurrent, "Current", Default, 8)
            Else
                MsgBox(0, "Empty", "No content")
            EndIf

    EndSwitch

    ; Do we need to edit?
    _GUIListViewEx_EditOnClick()

WEnd
Please ask if you still have 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

 

Link to comment
Share on other sites

  • Moderators

iahngy ,

 

can the list view be initted w/o header

Certainly - just use BitOr($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER) as a style. :)

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

iahngy,

Already explained in this thread. :)

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

  • 1 month later...
  • Moderators

[NEW VERSION] - 20 May 14

Added:

- 1. Native-created ListViews will expand their columns to fit the inserted text - see example scripts >here. There is now an additional parameter to the _GUIListViewEx_Insert function which can be set to restore the original width if required.

- 2. There is a new flag for the $iAdded parameter in _GUIListViewEx_Init to prevent external drag/drop to/from other initialised ListViews. The default is for all initialised ListViews to be able to drag/drop with all others - setting this flag makes it impossible to change the content of a ListView via drag/drop, although internal dragging is still possible.

New UDF in the first post. :)

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

  • 4 weeks later...

Hello Melba23,
Thank you for creating and sharing such a great UDF. The examples are especially useful in seeing how everything works.
 
However, due to my lack of understanding, I am unable to add a "WM_NOTIFY" function to my script.

I realize there is probably something very simple I am just not seeing in your following comments from GUIListViewEx.au3:

; Name...........: _GUIListViewEx_WM_NOTIFY_Handler
; Description ...: Windows message handler for WM_NOTIFY
; Remarks .......: If a WM_NOTIFY handler already registered, then call this function from within that handler

As another example, where would you add the following lines to your GLVEx_Example_1.au3 script?

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $iCode
        Case -189
            MsgBox(0, "ListView Checkbox", "Checked or Unchecked", 1)
    EndSwitch
EndFunc

Thank you for your help.
taurus905

Edited by taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

  • Moderators

taurus905,

All you need to do is amend the code in 2 places:

- 1. Do not use _GUIListViewEx_MsgRegister to trap the WM_NOTIFY messages, just register your own handler:

; Register only MOUSEMOVE and LBUTTONUP
_GUIListViewEx_MsgRegister(False, True, True) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Register your own NOTIFY handler
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Then add the UDF WM_NOTIFY handler function inside your own handler:

Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam
    Local $iCode, $tNMHDR
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $iCode
        Case -189
            ConsoleWrite("ListView Checkbox Checked or Unchecked" & @CRLF)
            ;MsgBox(0, "ListView Checkbox", "Checked or Unchecked", 1)
    EndSwitch

    ; Call the UDF NOTIFY handler from within your own <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $wParam, $lParam)

EndFunc
Now the UDF gets the WM_NOTIFY messages just after your own handler. I took the liberty of removing the MsgBox from the handler code - I realise that you have a 1 sec timeout, but when the Help file says:

 

the return to the system should be as fast as possible !!!

it means it. I regard anything over 250 ms as too long. You can get round this by using a flag which you set inside the handler and then check in your idle loop - that way you exit the handler as quickly as possible. ;)

Please ask if anything is still unclear. :)

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

Melba23,

That's perfect!

I knew it was something simple I was overlooking.

The part I was missing was disabling your "Register WM_NOTIFY message" using:

_GUIListViewEx_MsgRegister(False, True, True)

or just:

_GUIListViewEx_MsgRegister(False)

I had already completed your other suggestions, including the flag.

I have two more goals to accomplish for my gui.

Maybe you can guide me in the most elegant way to use your UDF.

First, change the background to black and font to white for checked items.

(I edited your UDF for my purposes, but I don't like doing it this way.)

I'd rather use your UDF as you created it and be able to edit my script.

An option to input a given color would be nice.

GUICtrlCreateListViewItem(StringTrimRight($sLine, 1), $cLV_CID)
            ; Reset checkbox if they exist
            If $fCheckBox And $aCheck_Array[$i] Then
                _GUICtrlListView_SetItemChecked($hLVHandle, $i - 1)
                GUICtrlSetBkColor(-1, 0x000000) ; line added by taurus905
                GUICtrlSetColor(-1, 0xffffff) ; line added by taurus905
            EndIf

I also would like to create a _GUIListViewEx_Update() function to update the color when a checkbox is checked or unchecked.

Second, create an editbox to just display the contents of a row as they are selected with the mouse or arrow keys.

I also need to increase the size of the arrays to allow for much longer strings; maybe up to 128 characters.

Any tips on the best ways to achieve these goals are greatly appreciated.

Sorry if this is asking too much.

taurus905

"Never mistake kindness for weakness."-- Author Unknown --"The highest point to which a weak but experienced mind can rise is detecting the weakness of better men."-- Georg Lichtenberg --Simple Obfuscator (Beta not needed.), Random names for Vars and Funcs

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...