Jump to content

Recommended Posts

Posted
6 hours ago, Melba23 said:

If you want to change the content, you must use a UDF function - _GUIListViewEx_ChangeItem (Programatic change of specified ListView item) seems a likely candidate.

Thanks for the warning.  I hope I would have noticed that anyway, but I will now.

Thanks again.

BTW, this is probably a function of my not being as familiar with the forum as I might be, but -- I searched around some, and I couldn't find the dedicated GUIListViewEx UDF thread ...

Posted

Hi again Melba23 (or anyone else, but I imagine it's going to be M23 who will chime in.  I hope ...)

  1. Thank you for your help so far.
  2. Apologies for not posting to the dedicated GUIListViewEx UDF thread.  I still haven't convinced myself that I know for sure where it is.  (I see there is a lengthy thread in Home > AutoIt v3 > AutoIt Example Scripts, currently titled "GUIListViewEx - BugFix Version 18 Apr 20".  Is that it?  Just post a follow-up to the end of the thread?)

3.

I'm slowly figuring this out.  My current hangup is defining custom behavior for double-click and right-click, but retaining internal drag and drop.

By default (with no custom WM_NOTIFY handler), drag-and-drop works.  (I have $iAdded specified to be 192 to disable external drag/drop).

But if I define a WM_NOTIFY handler, drag/drop stops working.  I instruct _GUIListViewEx_MsgRegister() not to re-register the handler, as directed.  And within the handler, I call _GUIListViewEx_WM_NOTIFY_Handler(), and return what it returns.

Now my handler is called for double-click and right-click, but drag/drop now doesn't work.  I'd thought (hoped?) that calling the UDF handler at the end of my custom handler would cause drag/drop to be retained.

Sample code follows.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <SendMessage.au3>
#include "GuiListViewEx.au3"

    global $g_GUI = GUICreate("Test", 520, 360, 300, 50)
    $lv = CreateListView()

    $a = _GUIListViewEx_ReadToArray($lv, 1)
    $lvx = _GUIListViewEx_Init($lv, $a, 1, 0, True, 192)
    _GUIListViewEx_MsgRegister _
    ( _
        False, _    ; NOTIFY
        True, _     ; MOUSEMOVE
        True, _     ; LBUTTONUP
        True _      ; SYSCOMMAND
    )

    $b_new = GUICtrlCreateButton("New",     10, 320, 50, 30)
    $b_mod = GUICtrlCreateButton("Modify",  80, 320, 50, 30)
    $b_del = GUICtrlCreateButton("Delete", 150, 320, 50, 30)

    GUISetState(@sw_show)
    GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY)

    while True
        $msg = GUIGetMsg()

        $index = _GUICtrlListView_GetSelectedIndices($lv)
        $id = ($index <> "") ? _GUICtrlListView_GetItem($lv, $index)[3] : ""
        select
            case $msg = $b_new:
                if ($index <> "") then debug(StringFormat("   New [%s]", $id))
            case $msg = $b_mod:
                if ($index <> "") then debug(StringFormat("Modify [%s]", $id))
            case $msg = $b_del:
                if ($index <> "") then debug(StringFormat("Delete [%s]", $id))

            case $msg = $GUI_EVENT_CLOSE
                Exit
        endselect

        $vRet = _GUIListViewEx_EventMonitor()
        If @error Then
            debug(StringFormat("Event error: %d", @error))
        EndIf
        Switch @extended
            Case 0
                ; No event detected
            Case 4
                debug(StringFormat("Dragged - From:To [%s]", $vRet))
        EndSwitch
    wend


    ; --------------------------
    func CreateListView()

        $style = BitOR($LVS_DEFAULT, $WS_BORDER)
        $lv = _GUICtrlListView_Create($g_GUI, "", 10, 10, 500, 300, $style)
        $ex_style = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_BORDERSELECT)
        _GUICtrlListView_SetExtendedListViewStyle($lv, $ex_style)

        _GUICtrlListView_InsertColumn($lv, 0, "A", 60)
        _GUICtrlListView_InsertColumn($lv, 1, "B", 60)
        _GUICtrlListView_InsertColumn($lv, 2, "C", 100)
        _GUICtrlListView_InsertColumn($lv, 3, "D", 274)
        _GUICtrlListView_SetTextBkColor($lv, 0xebefe4)

        local $a = ["Foo", "Bar", "Baz"]
        for $i = 0 to ubound($a) - 1
            _GUICtrlListView_AddItem($lv, $a[$i], $i)
            for $j = 1 to 3
                _GUICtrlListView_AddSubItem($lv, $i, "---", $j)
            next
        next

        return $lv

    endfunc


    ; --------------------------
    func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

        local $hdr   = DllStructCreate($tagNMHDR, $lParam)
        local $from  = HWnd(DllStructGetData($hdr, "hWndFrom"))
        local $ctrl  = DllStructGetData($hdr, "IDFrom")
        local $event = DllStructGetData($hdr, "Code")

        switch $event
            case $NM_DBLCLK
                debug('Double click')
            case $NM_RCLICK
                debug('Right click')
        endswitch

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

    endfunc


    ; --------------------------
    func debug($s)
        ConsoleWrite($s & @CRLF)
    endfunc

I trust I misunderstand in some (hopefully not too awful) way?

Thanks again.

/John

  • Moderators
Posted (edited)

DrJohn,

You rang?

That thread is indeed the one I meant - I will probably move your 2 threads there IDC.

As to your problem, it seems that it is caused by the UDF WM_NOTIFY handler not returning $GUI_RUNDEFMSG as a default. In the Guide I suggest returning the UDF return value as this is absolutely necessary when using colours or single item selection, but in this case it seems NOT returning  $GUI_RUNDEFMSG for other messages prevents the UDF from playing nicely when placed inside another handler. This is not something that has arisen before - I can only assume that it occurs because you are actioning the same messages as the UDF (double and right clicks).

Anyway, I have modified the UDF to return $GUI_RUNDEFMSG as a default when not dealing with colours and that appears to have solved the problem and returning the UDF handler return from within your own handler now leaves the drag'ndrop functionality working. So thank you very much for having found this bug .

Here is a Beta version of the UDF so you can check if it works for you - if it does than I will release a new version in the near future: 

M23

Edited by Melba23
Beta code removed

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

 

Posted
4 hours ago, Melba23 said:

That thread is indeed the one I meant - I will probably move your 2 threads there IDC.

Will use that thread in the future.

 

4 hours ago, Melba23 said:

This is not something that has arisen before - I can only assume that it occurs because you are actioning the same messages as the UDF (double and right clicks).

Fascinating.  Didn't mean to be a renegade ...

 

4 hours ago, Melba23 said:

Anyway, I have modified the UDF to return $GUI_RUNDEFMSG as a default when not dealing with colours and that appears to have solved the problem and returning the UDF handler return from within your own handler now leaves the drag'ndrop functionality working. So thank you very much for having found this bug .

As my Dad used to day, even a blind pig finds an acorn once in awhile.

 

4 hours ago, Melba23 said:

Here is a Beta version of the UDF so you can check if it works for you - if it does than I will release a new version in the near future: 

Yes, that does seem to fix it.  Thanks!

/John

Posted

Hi again Melba.  Hope I found the right place.  😁

Thanks again for the quick drag-drop/WM_NOTIFY fix.  No problems with that so far.

So what I'm basically doing is this:  I had an existing pretty well filled-out script that used ListView's, and decided I wanted to switch over to ListViewEx.  In light of the warning about 'script-breaking changes', rather than start to overhaul my existing script, I created a small test script (which you have seen) which mimics the behavior of the larger script.  I'm going through and identifying all the ListView functions I'm using, and making sure they still seem to work with ListViewEx (in a smaller, more manageable and isolated environment).

All seems to be well.  Basically, everything I had been doing I seem to also be able to do with ListViewEx.  There are a couple things, though -- they seem to work properly, but I'm wondering if they aren't questionable behavior:

  1. Any reason I can't add and delete items using the standard functions [_GUICtrlListView_AddItem(), _GUICtrlListView_DeleteItem()] after I create the ListView with _GUICtrlListView_Create(), as long as I do it before I call _GUIListViewEx_ReadToArray() and _GUIListViewEx_Init()?
  2. I have $LVS_EX_FULLROWSELECT set in my ListView, and I'm not doing any individual cell selection or editing.  Will _GUICtrlListView_GetSelectedIndices() still work to determine the index of the currently selected row?
  3. I also in some instances want to programmatically set which row is selected, so I use _GUICtrlListView_SetItemSelected().  Is that risky?

As I say, these things do seem to work.  But I'd be concerned if you thought they shouldn't ...

Thanks again!  (And BTW, lest I forget to ever say so -- this UDF is pretty amazing.)

/John

  • Moderators
Posted

DrJohn,

1. No reason at all. It is only once the ListView has been initialized that you MUST use the UDF functions to modify it - that is because the UDF maintains an internal array of what the ListView contains and gets very confused if there is any difference between that internal representation and the real thing!

2. I believe so - give it a try and see.

3. If you are not getting involved in colour, etc, I see no reason why not.

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

 

Posted (edited)

Hi, i dont seem to find any function to change fonts.

Any way to change the font? color, size, font itself?

PS: when adding the flag 32 to _GUIListViewEx_Init to allow for colouring of items, the listview becomes unresponsive, and everytime i click an item, it becomes selected as if i was pressing control+rmb in windows explorer, with this flag, i can basically select multiple items and the listview becomes unusable.

any way around this?

Thanks in advance

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

  • Moderators
Posted

careca,

You can change the font size and family for the entire ListView by using GUICtrlSetFont - you cannot change the font size and family for individual items.

Changing the colour of items is one of the functionalities of the UDF - as shown in Example 6 of the download. If you post the code which is causing you problems I will take a look and see if I can see why.

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

 

Posted
25 minutes ago, Melba23 said:

You can change the font size and family for the entire ListView by using GUICtrlSetFont - you cannot change the font size and family for individual items.

FWIW, I haven't been able to get GUICtrlSetFont() to work when the ListView is created with _GUICtrlListView_Create().  It only seems to work when the ListView is created with GUICtrlCreateListView().

I tried passing the return value from _GUICtrlListView_Create() directly to GUICtrlSetFont(), and that didn't work.  I think _GUICtrlListView_Create() returns a handle, not a control ID.  So I tried getting the control ID from the handle with _WinAPI_GetDlgCtrlID() and passing that to GUICtrlSetFont().  That didn't seem to work either.

I ended up using WinAPI_SetFont() to set the font for the ListView I created with _GUICtrlListView_Create().

/John

  • Moderators
Posted

DrJohn,

If you create controls with the native AutoIt fucntions (GUICtrlCreate*) then the return is a ControlID - an index to an internal AutoIt array which tracks all controls created in this way. You can then use this ControlID in all the other native AutoIt functions (e.g. GUICtrlSetFont). This is analogous to the index returned when you initialise a ListView with my UDF - you use that index when using most other UDF functions.

If you create controls using the UDF functions (_GUICtrl*_Create) then you get a Windows handle returned - which you cannot use in the native GUI modifying functions. So you need to use other UDF functions to do so - as you discovered.

All clear now?

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

 

Posted (edited)

I see why a windows handle wouldn't work with native gui functions.

I have to look at this, maybe change the create function to the native one.

I only realy used this one because it is present in your example, so i assumed it wouldn't work otherwise.

Thanks for the clarification.

PS: Managed to change the font, once i changed the listview create, to the native one.

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted
7 hours ago, Melba23 said:

If you create controls with the native AutoIt fucntions (GUICtrlCreate*) then the return is a ControlID - an index to an internal AutoIt array which tracks all controls created in this way. You can then use this ControlID in all the other native AutoIt functions (e.g. GUICtrlSetFont). This is analogous to the index returned when you initialise a ListView with my UDF - you use that index when using most other UDF functions.

If you create controls using the UDF functions (_GUICtrl*_Create) then you get a Windows handle returned - which you cannot use in the native GUI modifying functions. So you need to use other UDF functions to do so - as you discovered.

Yes, that makes sense.

Even though I knew GUICtrlCreateListView() returns a Control ID and the UDF function returns a window handle, I would have sworn there were instances where I ran GUICtrl* functions on the return from the UDF function and it worked anyway.  At some point, even though I didn't understand it, I formed the impression that the functions in question just took care of it for you.

But I can't find any such instances in my code now.  So either I replaced them, or I dreamed it.

In any event, there doesn't seem to be any UDF function to change the font of a UDF-created ListView.  So I guess using _WinAPI_SetFont() is my only option.  It seems to work, so I'm not knocking it.

/John

  • Moderators
Posted

DrJohn,

It is quite common to use ControlIds as parameters in the UDF functions - the UDF should take care of that internally using GUICtrlGetHandle if required - but you have never been able to use handles as parameters in the native GUICtrl* functions as they are not set up that way.

Anyway, further discussion in another thread please as we have moved a long way from my 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

 

  • Moderators
Posted

[BUGFIX VERSION] - 4 Jun 20

Fixed:  A couple of small edge case bugs  - thanks to those who reported them.

New zip containing new UDF and several example scripts in 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

 

  • Moderators
Posted

[BUGFIX VERSION] - 14 Jun 20

Fixed:  A bug in the Load function and one I introduced in the fix for an earlier bug (mea culpa!).

New zip containing new UDF and several example scripts in 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

 

Posted (edited)

Hi again Melba.

I think I may have found a bug.  Although I wouldn't bet the farm (even if I had one) that it's not something I'm doing wrong.

_GUIListViewEx_InsertSpec() doesn't seem to handle the case where GUIDataSeparatorChar is set to something other than the default "|".  This only happens when the original ListView is created with GUICtrlCreateListView(), not if it is created with _GUICtrlListView_Create().

Attached is a script that demonstrates.  Steps to reproduce:

  1. Ensure that the Opt("GUIDataSeparatorChar", Chr(31)) statement on line #7 is not commented out
  2. Ensure that line #99 is commented out, and line #100 is not, so that the ListView is created with GUICtrlCreateListView()
  3. Run script
  4. Click on the New button

(Similar problem occurs if you drag and drop -- I presume because that uses _GUIListViewEx_InsertSpec() also?)

Switch out line #99 for line #100, and it works as expected.

/John

 

Addendum:  Seems to be happier if I replace "|" on line #5225 of GUIListViewEx.au3 with Opt("GUIDataSeparatorChar").  Wouldn't presume I could safely change the file myself, though, other than for testing purposes.

test.au3

Edited by DrJohn
  • Moderators
Posted (edited)

DrJohn,

I think you have indeed found a bug - congratulations!

The UDF actually looks for a change in delimiter as it intialises a ListView and <should> use any new user-set delimiter when writing content in native-created ListViews. I have found a couple of other places in the UDF where there might be problems as well as the one you mentioned and I am looking into the matter now. Stay tuned.

M23

Edit: This seems to work correctly for me - can you please confirm: GUIListViewEx_Mod.au3

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

 

Posted

Is the order in which the register is called, important?

I can make this work if i move the creation of the items to before the init function.

But as it is i get an error, trying to understand what is the process to call each line.

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>
;Opt("GUIResizeMode", 1) ;0=no resizing, <1024 special resizing ;No effect
Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0
$hGUI = GUICreate("LVEx Example 1", 500, 430)
$hListView_Right = _GUICtrlListView_Create($hGUI, "", 10, 20, 480, 400, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)
GUICtrlSetResizing ( $hListView_Right, 1)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
;=============================================================================
; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - move edit by click + headers editable
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 32)
; All columns editable - simple text selected on open
_GUIListViewEx_SetEditStatus($iLV_Right_Index, 0)
; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()
;=============================================================================
$vRet = _GUIListViewEx_EventMonitor($iEditMode)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
    EndIf
GUISetState()
;=============================================================================
For $i = 1 To $iCount_Right
    _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1)
    If Mod($i, 4) Then
        _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1)
    EndIf
    _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2)
Next
;=============================================================================
$Count = _GUICtrlListView_GetItemCount($hListView_Right)
ConsoleWrite($Count &@CRLF)
    For $c = 0 To $Count
        If $c < 5 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 2)
        ElseIf $c > 10 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 2)
        EndIf
Next
;=============================================================================
Local $WinCoords = WinGetPos($hGUI)
WinMove($hGUI, '', $WinCoords[0], $WinCoords[1], 900, $WinCoords[3]) ;Enlarge GUI in width
GUICtrlSetPos($hListView_Right, 10, 20, 570, 400)
;=============================================================================
While 1
    $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Then Exit
    $vRet = _GUIListViewEx_EventMonitor($iEditMode)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
    EndIf
    Sleep(100)
    $GetItemTxt = _GUIListViewEx_GetLastSelItem($iLV_Right_Index)
    ConsoleWrite('$GetItemTxt:' & $GetItemTxt & @CRLF)
WEnd
;=============================================================================
Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    Local $iWidth = BitAND($lParam, 0xFFFF)
    Local $iHeight = BitShift($lParam, 16)
    _WinAPI_MoveWindow($hListView_Right, 10, 10, $iWidth - 40, $iHeight - 40, True)
    ;_GUICtrlListView_SetColumn($hListView_Right, 2, "Item", $iWidth - 260)
    Return $GUI_RUNDEFMSG
EndFunc

Struggling trying to convert my player's listview into this udf, mostly for the background color in rows, and failing miserably, then in a separate example, it kinda works, so there must be something interfering with the udf.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)

Melba is obviously going to be a much better authority on this (as well as most anything else) than me.  But I think (as it was explained to me) once having put your ListView under control of GUIListViewEx, anything you do that changes its contents must use a GUIListViewEx function.  So populating the ListView with _GUICtrlListView_AddItem() won't work.

You can add to the end of a GUIListViewEx-controlled ListView with _GUIListViewEx_InsertSpec($iLV, -1, ...).

This works for me:

#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include "GUIListViewEx.au3"
#include <Array.au3>
;Opt("GUIResizeMode", 1) ;0=no resizing, <1024 special resizing ;No effect
Global $iCount_Left = 20, $iCount_Right = 20, $vData, $sMsg, $aLV_List_Left, $aLV_List_Right, $aRet, $iEditMode = 0
$hGUI = GUICreate("LVEx Example 1", 500, 430)
$hListView_Right = _GUICtrlListView_Create($hGUI, "", 10, 20, 480, 400, BitOR($LVS_DEFAULT, $WS_BORDER))
_GUICtrlListView_SetExtendedListViewStyle($hListView_Right, $LVS_EX_FULLROWSELECT)
_GUICtrlListView_AddColumn($hListView_Right, "Peter", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Paul", 83)
_GUICtrlListView_AddColumn($hListView_Right, "Mary", 83)
GUICtrlSetResizing ( $hListView_Right, 1)
GUIRegisterMsg($WM_SIZE, "WM_SIZE")
;=============================================================================
; Initiate LVEx - use read content as array - count parameter set - red insert mark - drag image - move edit by click + headers editable
$iLV_Right_Index = _GUIListViewEx_Init($hListView_Right, $aLV_List_Right, 1, 0xFF0000, True, 32)
; All columns editable - simple text selected on open
_GUIListViewEx_SetEditStatus($iLV_Right_Index, 0)
; Register for sorting, dragging and editing
_GUIListViewEx_MsgRegister()
;=============================================================================
$vRet = _GUIListViewEx_EventMonitor($iEditMode)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
    EndIf
GUISetState()
;=============================================================================
For $i = 1 To $iCount_Right
;   _GUICtrlListView_AddItem($hListView_Right, "Peter " & $i - 1)
;   If Mod($i, 4) Then
;       _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Paul " & $i - 1, 1)
;   EndIf
;   _GUICtrlListView_AddSubItem($hListView_Right, $i - 1, "Mary " & $i - 1, 2)
    local $a = _
    [ _
        "Peter " & $i - 1, _
        Mod($i, 4) ? "Paul " & $i - 1 : "", _
        "Mary " & $i - 1 _
    ]
    _GUIListViewEx_InsertSpec($iLV_Right_Index, -1, $a, False, True)
Next
;=============================================================================
$Count = _GUICtrlListView_GetItemCount($hListView_Right)
ConsoleWrite($Count &@CRLF)
    For $c = 0 To $Count
        If $c < 5 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xFFF2B3", $c, 2)
        ElseIf $c > 10 Then
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 0)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 1)
            _GUIListViewEx_SetColour($iLV_Right_Index, "0x000000;0xB3E5FF", $c, 2)
        EndIf
Next
;=============================================================================
Local $WinCoords = WinGetPos($hGUI)
WinMove($hGUI, '', $WinCoords[0], $WinCoords[1], 900, $WinCoords[3]) ;Enlarge GUI in width
GUICtrlSetPos($hListView_Right, 10, 20, 570, 400)
;=============================================================================
While 1
    $Msg = GUIGetMsg()
        If $Msg = $GUI_EVENT_CLOSE Then Exit
    $vRet = _GUIListViewEx_EventMonitor($iEditMode)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Error", "Event error: " & @error)
    EndIf
    Sleep(100)
    $GetItemTxt = _GUIListViewEx_GetLastSelItem($iLV_Right_Index)
    ConsoleWrite('$GetItemTxt:' & $GetItemTxt & @CRLF)
WEnd
;=============================================================================
Func WM_SIZE($hWnd, $Msg, $wParam, $lParam)
    Local $iWidth = BitAND($lParam, 0xFFFF)
    Local $iHeight = BitShift($lParam, 16)
    _WinAPI_MoveWindow($hListView_Right, 10, 10, $iWidth - 40, $iHeight - 40, True)
    ;_GUICtrlListView_SetColumn($hListView_Right, 2, "Item", $iWidth - 260)
    Return $GUI_RUNDEFMSG
EndFunc

Move the GUISetState() call after the ListView is populated, and it isn't so flicker-y.  In fact, move it to just before the message loop, and it isn't flicker-y at all.

/John

Edited by DrJohn
Posted

That makes sense, i was looking at this for too long, needed to sleep. Thanks.

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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...