Jump to content

Recommended Posts

Posted

Hi guys, :lmao:

2 Question for the boss:

Is it possible to make a different context menu for each row ? Or is the solution to create it, at each right click, for each row index ?

Same question for a column configured with a combo (by _GUIListViewEx_SetEditStatus). Is there a way to do this for each row or may i intercept doublclick and modify my combo data) :blink:

thanks for the advice/method.

Nicolas.

  • Moderators
Posted

satanico64,

I have no idea about the context menus - each row of a ListView is a separate control so you should be able to do it but nothing in this UDF can help you do it.

The combo content is set for a specific column when defining the edit mode - there is no easy way I can see to allow for different contents for different rows. And given that the usual function of a ListView is to tabulate similar elements in each column I wonder why you even see the need for such a functionality?

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:

  Reveal hidden contents

 

Posted

thanks for your answer,  so i'm going to dismember again your code :) to make this.

 

my list manage materials from stock, from clients to stock and stock to clients, and materials remplacement. My combo indicate 'from client to stock' and "from stock to client" ( i'm simplifying)

It's populate from materials which is at the client site. I juste want to be impossible to select 'from stock to client' on an item which is at the client site.

something like that. :blink:

it make sense believe me :P (not sure i'm really clear)

thanks for your quick  answer.

Nicolas.

  • Moderators
Posted

satanico64,

  Quote

I juste want to be impossible to select 'from stock to client' on an item which is at the client site

Expand  

I would suggest using the array returned by the _EventMonitor function after a successful edit to check if the selection was valid for that particular row - and if not use the _GUIListViewEx_ChangeItem function to reset the original value (also found in the returned array) and pop up a MsgBox to warn the user. That is why I added the ability to check the edited values to the UDF.

Let me know if a quick example would help understand how to do it.

M23

 

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

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted

i understand what you mean.

I thought it was better to block the possibility before, than check it just after.

So it certainly will be easier in your way.

Let's ask my lazy-meter.....  ok i'll do your way... :)

 

i'll try by myself before asking your example, thanks Melba :)

More than 27k posts ? are you a bot man ?   Have you passed the turing test ? :lmao:

 

  • 1 month later...
Posted (edited)

Hello melba and guys, Someone can help me understand how to do it:

1. I want to know how to order the icon column correctly,I just ordered the columns with the text but the column with the icons do not coincide correctly.

2. How can I use this function to launch sorting when I click on the listview header

My code here, and files https://ufile.io/03x69 THX

 

#include <ButtonConstants.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <GuiListView.au3>
#include <GDIPlus.au3>
#include <Array.au3>
#include <GuiImageList.au3>
#include <StaticConstants.au3>
#include <IE.au3>
#include <Misc.au3>
#include <EditConstants.au3>
#include <ListBoxConstants.au3>
#include <GuiListBox.au3>
#include <File.au3>
#include <FileConstants.au3>
#include <WinAPI.au3>
#include <WinAPITheme.au3>
#include <Color.au3>
#include <ColorConstants.au3>
#include <WinAPIConstants.au3>
#include "GUIListViewEx.au3"

#Region ### START Koda GUI section ### Form=

Global $IEControl,$tini = @ScriptDir&"\test.ini"
Global $ListView

$Form1 = GUICreate("Form1", 800, 600, 192, 124)
$ListView = GUICtrlCreateListView("",  10, 10, 780, 580, -1, BitOR($LVS_EX_FULLROWSELECT, 0x00010000))
_GUICtrlListView_SetExtendedListViewStyle($ListView, BitOR($LVS_AUTOARRANGE, $LVS_EX_FULLROWSELECT, $LVS_EX_DOUBLEBUFFER, $LVS_EX_SUBITEMIMAGES))
GUICtrlSetFont($ListView, 8, Default, Default, "Arial")
GUICtrlSetResizing($ListView,1); 102 + 2)
_GUICtrlListView_AddColumn($ListView, "Icon", 70)
_GUICtrlListView_AddColumn($ListView, "Name", 330)
_GUICtrlListView_AddColumn($ListView, "Country", 50)
_GUICtrlListView_AddColumn($ListView, "Path", 320)

_GUIListViewEx_MsgRegister()


read()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)


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

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $ListView
    EndSwitch
WEnd

   GUIDelete()
Func read()
    Local $tot = 0
    If FileExists($tini) Then
        $hImage2 = _GUIImageList_Create(48, 48, 5, 1)
        _GDIPlus_Startup()

        $aArrays = IniReadSectionNames($tini)



        If Not @error Then
            For $i = 1 To UBound($aArrays) - 1

                $n = IniRead($tini, $aArrays[$i], "name", "")
                $z = IniRead($tini, $aArrays[$i], "ico", "")
                $r = IniRead($tini, $aArrays[$i], "region", "")
                ConsoleWrite($z&@CRLF)
                ;load icon and upscale the icon to 48x48 pixels
                $hBitmap2 = _GDIPlus_BitmapCreateFromFile($z)
                $hBitmap_scaled2 = _GDIPlus_ImageResize($hBitmap2, 48, 48)
                $hBitmap_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_scaled2)
                _GDIPlus_BitmapDispose($hBitmap_scaled2)
                $ico = _GUIImageList_Add($hImage2, $hBitmap_GDI)
                _GUICtrlListView_SetImageList($ListView, $hImage2, 1)
                _GUICtrlListView_AddItem($ListView, "", $ico)
                _GUICtrlListView_AddSubItem($ListView, $i - 1, $n, 1)
                _GUICtrlListView_AddSubItem($ListView, $i - 1, $r, 2)
                _GUICtrlListView_AddSubItem($ListView, $i - 1, $aArrays[$i], 3)
                $tot += 1
            Next

                    $aLVArray = _GUIListViewEx_ReadToArray($ListView)

                    $iLV_Index = _GUIListViewEx_Init($ListView, $aLVArray, 0, 0, True, 0)

                    $sort = _GUIListViewEx_SortCol($iLV_Index,1);<-------------------------

                    ConsoleWrite("Satus " & $sort&@CRLF);<-------------------------
            _GDIPlus_Shutdown()
        EndIf
    EndIf
EndFunc   ;==>read


; ========================================================
; This thing is responcible for click events
; ========================================================
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)

    Local $hWndFrom, $iCode, $tNMHDR, $hWndListView
    $hWndListView = $ListView
    If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")

    Switch $hWndFrom

        Case $hWndListView
            Switch $iCode

                Case $NM_CLICK
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $Index = DllStructGetData($tInfo, "Index")
                    If DllStructGetData($tInfo, "Index") = -1 Then
                        ConsoleWrite("no item" & @CRLF)
                    Else
                        Local $iItemTextCL = _GUICtrlListView_GetItemText($ListView, DllStructGetData($tInfo, "Index"), 1)
                        ConsoleWrite("Click item "&$iItemTextCL&@CRLF)
                    EndIf


                Case $LVN_KEYDOWN

                    $tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
                    $iKey = DllStructGetData($tInfo, "VKey")
                    ; Get current selection
                    $aLastSel = StringSplit(_GUIListViewEx_GetLastSelectedItem(), "|")
                    Switch $iKey
                        Case 38
                            If _GUIListViewEx_GetLastSelectedItem() <> "" Then
                                ; Move up unless at top
                                $iCurrItem = $aLastSel[2] - 1
                                If $iCurrItem < 0 Then
                                    $iCurrItem = 0
                                EndIf
                                _GUICtrlListView_ClickItem($hWndFrom, $iCurrItem, "top", False, 1, 2)
                                $target = _GUICtrlListView_GetItemText($ListView, $iCurrItem, 1)
                                ConsoleWrite("up item " & $target & @CRLF)
                            Else
                                _GUICtrlListView_ClickItem($hWndFrom, 0, "top", False, 1, 2)
                            EndIf
                        Case 40
                            If _GUIListViewEx_GetLastSelectedItem() <> "" Then
                                ; Move down unless at bottom
                                $iCurrItem = $aLastSel[2] + 1
                                If $iCurrItem >= _GUICtrlListView_GetItemCount($hWndFrom) Then
                                    $iCurrItem = _GUICtrlListView_GetItemCount($hWndFrom) - 1
                                EndIf
                                _GUICtrlListView_ClickItem($hWndFrom, $iCurrItem, "down", False, 1, 2)
                                $targetb = _GUICtrlListView_GetItemText($ListView, $iCurrItem, 1)
                                ConsoleWrite("down item " & $targetb & @CRLF)
                            Else
                                _GUICtrlListView_ClickItem($hWndFrom, 0, "down", False, 1, 2)
                            EndIf
                    EndSwitch

                Case $NM_DBLCLK
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $Index = DllStructGetData($tInfo, "Index")
                    If DllStructGetData($tInfo, "Index") = -1 Then
                        ConsoleWrite("no item" & @CRLF)
                    Else
                        Local $iItemText = _GUICtrlListView_GetItemText($ListView, DllStructGetData($tInfo, "Index"), 1)
                        ConsoleWrite("Dbclick item " & $iItemText & @CRLF)
                    EndIf

                Case $NM_RCLICK
                    Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
                    $Index = DllStructGetData($tInfo, "Index")
                    If DllStructGetData($tInfo, "Index") = -1 Then
                        ConsoleWrite("no item" & @CRLF)
                    Else
                        Local $iItemTextr = _GUICtrlListView_GetItemText($ListView, DllStructGetData($tInfo, "Index"), 1)
                        ConsoleWrite("Nmclick item " & $iItemTextr & @CRLF)
                    EndIf

            EndSwitch
    EndSwitch
$iRet = _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $iMsg, $iwParam, $ilParam)
    Return $iRet
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY


Func _GUIListViewEx_GetLastSelectedItem($iLV_Index = 0)
    ; Check valid index
    Switch $iLV_Index
        Case 1 To $aGLVEx_Data[0][0]
    EndSwitch

    ; Read last selected item
    Local $iRow = $aGLVEx_Data[$iLV_Index][20]
    Local $iCol = $aGLVEx_Data[$iLV_Index][21]
    ; Check selection has been made
    If $iRow = -1 Or $iCol = -1 Then Return SetError(2, 0, "")
    ; Return selection details
    Return $iLV_Index & "|" & $iRow & "|" & $iCol

EndFunc   ;==>_GUIListViewEx_GetLastSelectedItem

 

Edited by rootx
  • Moderators
Posted

rootx,

As I have explained many times, the UDF does not support sorting ListViews with icons as it only uses the SimpleSort function. The code is already complicated enough, so I have no intention of trying to add this functionality either - sorry.

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:

  Reveal hidden contents

 

Posted

Sorry, I did not read that topic, I would like to know if you believe I can use GUICtrlListView Register Sort CallBack ($ ListView), or this conflicts with your UDF.

THX

  • Moderators
Posted

rootx,

I have never tried, so why not do so yourself. Just make sure you do not set the UDF to sort columns as well.

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:

  Reveal hidden contents

 

  • 4 weeks later...
Posted (edited)

I think I found issue in GLVEx_Example_1.au3
Step to reproduce:

  1. Run
  2. Click and hold on "Tom 6"
  3. Drag "Tom 6" to line beetwen "Tom 0" and "Tom 1"

Symptoms: in many cases / tryies , "Tom 6" is moved beetwen  "Tom 1" and "Tom 2"

Regards,
mLipok

 

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • Moderators
Posted

mLipok,

I have just tried multiple drag/drop steps as you describe and I get the row moved to the correct location each time. Are you waiting for the delimiter bar to appear in the required place before releasing the mouse button? I wonder if you are not releasing too soon.

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:

  Reveal hidden contents

 

Posted

Is it possible to stop the default windows ding sound when dragging an item?

 

I am right in saying there is no way to stop a script from having sound? e.g. #NoSoundPlease

  • Moderators
Posted

Gambler71,

I believe that you will need to turn off the associated Windows sound effect - there is nothing that I know of which allows a script to do so independently.

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:

  Reveal hidden contents

 

Posted
  On 6/5/2017 at 6:52 AM, Melba23 said:

I have just tried multiple drag/drop steps as you describe and I get the row moved to the correct location each time. Are you waiting for the delimiter bar to appear in the required place before releasing the mouse button? I wonder if you are not releasing too soon.

Expand  

I need to look more closely at this.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 weeks later...
Posted

Melba23,

very nice UDF! :)

I get an error if "MustDeclareVars" is placed before "#include GUIListViewEx.au3":

"D:\SUPERSONIC\_\AUTOIT\Include\Melba23\GUIListViewEx\20170216\_\GUIListViewEx.au3" (3753) : ==> Variable used without being declared.:
$iCol = DllStructGetData($tNMHEADER, "Item")
^ ERROR

  • Moderators
Posted (edited)

supersonic,

I do not get that error with my master copy of the UDF - are you sure you have the latest version?

M23

Edit: Apologies, I can see where it might occur during execution but not be picked up by Au3Check - I will see how I can fix it.

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:

  Reveal hidden contents

 

  • 2 weeks later...
Posted

Hi Melba,

great work on this as always... I use old version of this UDF but I guess I will have to upgrade as I need some features from your new version.

To be more exact I need one column to have updown control.

And I struggle to figure out how to SetEditStatus so it has UpDown controls next to number and further to that how can I limit range(for example so it goes from 1 to 6).

Any help would be appreciated...

Thanks a lot

Jan

  • Moderators
Posted

JanZoudlik,

The _SetEditStatus function header explains how to get an UpDown control and how to set limits and even whether the control should wrap - but in trying to write you a short example I have just discovered that another later change to the UDF has broken that particular section! So give me a moment to work out how to fix it and I will come back.

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:

  Reveal hidden contents

 

  • Moderators
Posted

JanZoudlik,

There is no problem with the UDF - I had mis-read my own instructions on how to do it!!!!! I really do feel that this UDF is now far too complicated for its own good, but people seem to like it.....

Here is an UpDown example which works with the latest version:

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

#include "GUIListViewEx.au3"

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

$cLV = GUICtrlCreateListView("No UpDown|UpDown|Limit UpDown|Wrap UpDown", 10, 10, 420, 260, BitOR($LVS_SINGLESEL, $LVS_SHOWSELALWAYS))
_GUICtrlListView_SetExtendedListViewStyle($cLV, $LVS_EX_FULLROWSELECT)
For $i = 0 To 3
    _GUICtrlListView_SetColumnWidth($cLV, $i, 100)
Next

; Create array and fill listview
Global $aLVArray[6][4]
For $i = 0 To 5
    $sData = "Item " & $i & "-0"
    $aLVArray[$i][0] = $sData
    For $j = 1 To 3
        $sData &= "|SubItem " & $i & "-" & $j
        $aLVArray[$i][$j] = "SubItem " & $i & "-" & $j
    Next
    GUICtrlCreateListViewItem($sData, $cLV)
Next

; Initiate ListView
$iLVIndex = _GUIListViewEx_Init($cLV, $aLVArray)

; Set column edit status
_GUIListViewEx_SetEditStatus($iLVIndex, 0, 1)                   ; Default = standard text edit
_GUIListViewEx_SetEditStatus($iLVIndex, 1, 1, 1)                ; UpDown with no limit
_GUIListViewEx_SetEditStatus($iLVIndex, 2, 1, 1, "1|6|0")       ; UpDown with limit
_GUIListViewEx_SetEditStatus($iLVIndex, 3, 1, 1, "1|6|1")       ; UpDown with limit and wrap

_GUIListViewEx_MsgRegister()

GUISetState()

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

    _GUIListViewEx_EventMonitor()

WEnd

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:

  Reveal hidden contents

 

  • 2 weeks later...
Posted (edited)

Melba23,

as reported in post #175 I have found another missing variable declaration. I modified your UDF a bit and now I seems to work using "MustDeclareVars".

Please see attachment for comparison.

Comparison.jpg

Edited by supersonic

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