Jump to content
PINTO1927

_GUICtrlListView_GetItemTextString Single Cell

Recommended Posts

Hi guys,

through _GUICtrlListView GetItemText String formula you can only get the contents of a cell?
example:

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

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Text String", 400, 300)

    $idListview = GUICtrlCreateListView("col1|col2|col3", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUICtrlCreateListViewItem("line4|data4|more4", $idListview)
    GUICtrlCreateListViewItem("line5|data5|more5", $idListview)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", "Item 2 Text: " & @CRLF & @CRLF & _GUICtrlListView_GetItemTextString($idListview, 1))

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example

In the MsgBox I would like to show only, for example, "data3", and not all the content of the line3.

Share this post


Link to post
Share on other sites

I tried to use it but it does not show what I was looking

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

Example()

Func Example()
    Local $idListview
    GUICreate("ListView Get Item Text", 400, 300)
    $idListview = GUICtrlCreateListView("test|test|test", 2, 2, 394, 268)
    GUICtrlCreateListViewItem("line1|data1|more1", $idListview)
    GUICtrlCreateListViewItem("line2|data2|more2", $idListview)
    GUICtrlCreateListViewItem("line3|data3|more3", $idListview)
    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", _GUICtrlListView_GetItemText($idListview, 1))

    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc

 

Share this post


Link to post
Share on other sites

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

Example()

Func Example()
    Local $idListview

    GUICreate("ListView Get Item Text String", 400, 300)

    $idListview = GUICtrlCreateListView("", 2, 2, 394, 268)

    _GUICtrlListView_AddColumn(GUICtrlGetHandle($idListview), "ESTADO", 100)
    _GUICtrlListView_AddColumn(GUICtrlGetHandle($idListview), "PRUEBA", 100)

    For $s = 0 to 5
        _GUICtrlListView_AddItem(GUICtrlGetHandle($idListview), "ESTADO" & $s)
        _GUICtrlListView_AddSubItem(GUICtrlGetHandle($idListview), $s, "PRUEBA" & $s, 1)
    Next


    GUISetState(@SW_SHOW)

    MsgBox($MB_SYSTEMMODAL, "Information", _GUICtrlListView_GetItemTextString(GUICtrlGetHandle($idListview)))
    Exit

    ; Loop until the user exits.
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>Example
 

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

  • Similar Content

    • By jantograaf
      Hi all,
      I've been search all around this forum for a solution, but so far haven't been able to find one. So I thought I'd explain it as good as possible and ask here for your views on the issue.
      Situation:
      I'm trying to automatically (on first run of a newly installed PC for our customers) open the adapter properties of a specific network adapter and then disable all protocols except TCP/IP V4. This is needed for specific functionality with hardware connected to this adapter. I am aware of most of the existing tools (wmic/netsh/devcon/...) to interfere with network adapters, but apart from a WHOLE lot of work in the registry, automating the checkmarks in the properties window should be the fastest solution.
      System is Windows 10 64-Bit and I've compiled the application as a x64-executable (since I know from the past that the choice between 32- and 64-bit can have consequences for interaction with SysListViews).
      Let's suppose the adapter is called "ADAPTERXX" (I am aware that my screenshot shows FUJIFILM, but that's from my own PC)
      Problem:
      I am perfectly able to automatically open the properties window of the correct adapter using the following code (I know the sending of the keystrokes can be programmed in a little loop, no worries, I'll get to this a little later, this is just a quick draft)...
      ShellExecute("control.exe","ncpa.cpl",@WindowsDir,"",@SW_SHOW) WinWait("Network Connections","") WinActivate("Network Connections","") WinWaitActive("Network Connections","") Send("{F5}") Sleep(250) BlockInput(1) Send("{A}") Send("{D}") Send("{A}") Send("{P}") Send("{T}") Send("{E}") Send("{R}") Send("{X}") Sleep(500) Send("{APPSKEY}") Sleep(100) Send("{R}") Local $ListWindow = WinWaitActive("ADAPTERXX Properties","") When I arrive in this window, I can detect which specific options has which specific ID in the SysListView32-instance by using:
      ControlListView("ADAPTERXX Properties","","[CLASSNN:SysListView321]","FindItem","Client for Microsoft Networks") But then, I can't control the checkmark in front of the text and the icon... I've tried lots of solutions.
      I've tried checking the state, but this next command always returns 'True'
      Local $GHandle = ControlGetHandle("ADAPTERXX Properties","","[CLASSNN:SysListView321]") MsgBox(0,"Is Item3 checked?",_GUICtrlListView_GetItemChecked($GHandle,3)) I've tried selecting or deselecting, but no result...
      ControlListView("FUJIFILM Properties","","[CLASSNN:SysListView321]","Deselect",$List_CMN) Creating an array of the window returns an empty array
      Local $ListArray = _GUICtrlListView_CreateArray($GHandle,Default)  
      If anyone has any ideas, please shoot. It's also something that anyone can try at home with their own 'network properties', just change the ADAPTERXX to another name and the code to select the right adapter in the network connections window (all the little keystrokes). I'm open to any and all suggestions, I'm just at the end of my wits here...
      Thanks in advance!
      Jan

    • By johnmcloud
      Hi guys, this is the script:


      #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <GuiEdit.au3> #include <GuiMenu.au3> #include <WinAPI.au3> Global $hEdit, $hDC, $hBrush, $Item = -1, $SubItem = 0, $Number = 0, $hMenu Global Enum $idMoveUp = 1000, $idMoveDown, $idDelete Global $Style = BitOR($WS_CHILD, $WS_VISIBLE, $ES_AUTOHSCROLL, $ES_LEFT) HotKeySet("{DELETE}", "Delete_Item") HotKeySet("{UP}", "Move_Up") HotKeySet("{DOWN}", "Move_Down") $GUI = GUICreate("_GUICtrlListView_Example", 262, 351, -1, -1) $hListView = _GUICtrlListView_Create($GUI, "N°|Name|Subject", 5, 5, 250, 272) _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_BORDERSELECT)) _GUICtrlListView_SetColumnWidth($hListView, 0, 35) _GUICtrlListView_SetColumnWidth($hListView, 1, 107) _GUICtrlListView_SetColumnWidth($hListView, 2, 108) $Label = GUICtrlCreateLabel("Name", 13, 290, 67, 17) $Add = GUICtrlCreateButton("Add", 90, 315, 80, 25) $Info = GUICtrlCreateInput("Subject", 88, 286, 83, 21) $Save = GUICtrlCreateButton("Save", 174, 284, 80, 25) GUISetState(@SW_SHOW) $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Move Up", $idMoveUp) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Move Down", $idMoveDown) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Delete", $idDelete) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Add Add_Item() Case $Save Save_List() EndSwitch WEnd Func Add_Item() $Number += 1 _GUICtrlListView_AddItem($hListView, $Number) _GUICtrlListView_AddSubItem($hListView, $Number - 1, GUICtrlRead($Label), 1) _GUICtrlListView_AddSubItem($hListView, $Number - 1, GUICtrlRead($Info), 2) EndFunc ;==>Add_Item Func Delete_Item() _GUICtrlListView_DeleteItemsSelected($hListView) _Arrange_Numbers() EndFunc ;==>Delete_Item Func _Arrange_Numbers() Dim $iCount = 0 $Total_Number = _GUICtrlListView_GetItemCount($hListView) - 1 For $i = 0 To $Total_Number $iCount += 1 _GUICtrlListView_SetItemText($hListView, $i, $iCount) Next EndFunc Func Save_List() Local $Save = FileSaveDialog("Save", @WorkingDir, "Txt Files (*.txt)", 2, "Test_File_" & @MDAY & "-" & @MON & "-" & @YEAR & "_" & @HOUR & "-" & @MIN) If @error Then ConsoleWrite("Abort") Else $List = FileOpen($Save & ".txt", 2) $Number_items = _GUICtrlListView_GetItemCount($hListView) For $i = 0 To $Number_items - 1 Step +1 $output = StringReplace(_GUICtrlListView_GetItemTextString($hListView, $i), "|", " - ") FileWriteLine($List, $output) Next FileClose($List) EndIf EndFunc ;==>Save_List Func Move_Up() Local $Sel, $aArrayListView $aArrayListView = _GUICtrlListView_CreateArray($hListView) $Sel = _GUICtrlListView_GetNextItem($hListView) If $Sel > 0 Then Local $SelItem, $NxtItem $SelItem = _GUICtrlListView_GetItemTextArray($hListView, $Sel) $PrvItem = _GUICtrlListView_GetItemTextArray($hListView, $Sel - 1) For $i = 1 To $SelItem[0] $aArrayListView[$Sel][$i - 1] = $PrvItem[$i] $aArrayListView[$Sel - 1][$i - 1] = $SelItem[$i] _GUICtrlListView_SetItemText($hListView, $Sel, $PrvItem[$i], $i - 1) _GUICtrlListView_SetItemText($hListView, $Sel - 1, $SelItem[$i], $i - 1) _GUICtrlListView_SetItemSelected($hListView, $Sel - 1) Next EndIf _Arrange_Numbers() EndFunc ;==>Move_Up Func Move_Down() Local $Sel, $Lst, $aArrayListView $aArrayListView = _GUICtrlListView_CreateArray($hListView) $Sel = _GUICtrlListView_GetNextItem($hListView) $Lst = _GUICtrlListView_GetItemCount($hListView) - 1 If $Sel < $Lst And $Sel <> -1 Then Local $SelItem, $NxtItem $SelItem = _GUICtrlListView_GetItemTextArray($hListView, $Sel) $NxtItem = _GUICtrlListView_GetItemTextArray($hListView, $Sel + 1) For $i = 1 To $SelItem[0] $aArrayListView[$Sel][$i - 1] = $NxtItem[$i] $aArrayListView[$Sel + 1][$i - 1] = $SelItem[$i] _GUICtrlListView_SetItemText($hListView, $Sel, $NxtItem[$i], $i - 1) _GUICtrlListView_SetItemText($hListView, $Sel + 1, $SelItem[$i], $i - 1) _GUICtrlListView_SetItemSelected($hListView, $Sel + 1) Next EndIf _Arrange_Numbers() EndFunc ;==>Move_Down Func _GUICtrlListView_CreateArray($hListView, $sDelimeter = '|') Local $iColumnCount = _GUICtrlListView_GetColumnCount($hListView), $iDim = 0, $iItemCount = _GUICtrlListView_GetItemCount($hListView) If $iColumnCount < 3 Then $iDim = 3 - $iColumnCount EndIf If $sDelimeter = Default Then $sDelimeter = '|' EndIf Local $aColumns = 0, $aReturn[$iItemCount + 1][$iColumnCount + $iDim] = [[$iItemCount, $iColumnCount, '']] For $i = 0 To $iColumnCount - 1 $aColumns = _GUICtrlListView_GetColumn($hListView, $i) $aReturn[0][2] &= $aColumns[5] & $sDelimeter Next $aReturn[0][2] = StringTrimRight($aReturn[0][2], StringLen($sDelimeter)) For $i = 0 To $iItemCount - 1 For $j = 0 To $iColumnCount - 1 $aReturn[$i + 1][$j] = _GUICtrlListView_GetItemText($hListView, $i, $j) Next Next Return SetError(Number($aReturn[0][0] = 0), 0, $aReturn) EndFunc ;==>_GUICtrlListView_CreateArray Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_DBLCLK Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) If ($aHit[0] <> -1) And ($aHit[1] = 0) Then $Item = $aHit[0] $SubItem = 0 Local $aRect = _GUICtrlListView_GetItemRect($hListView, $Item) ElseIf ($aHit[0] <> -1) And ($aHit[1] > 0) Then $Item = $aHit[0] $SubItem = $aHit[1] Local $aRect = _GUICtrlListView_GetSubItemRect($hListView, $Item, $SubItem) Else Return $GUI_RUNDEFMSG EndIf Local $iItemText = _GUICtrlListView_GetItemText($hListView, $Item, $SubItem) Local $iLen = _GUICtrlListView_GetStringWidth($hListView, $iItemText) $hEdit = _GUICtrlEdit_Create($GUI, $iItemText, $aRect[0] + 3, $aRect[1], $iLen + 10, 17, $Style) _GUICtrlEdit_SetSel($hEdit, 0, -1) _WinAPI_SetFocus($hEdit) $hDC = _WinAPI_GetWindowDC($hEdit) $hBrush = _WinAPI_CreateSolidBrush(0x0000FF) FrameRect($hDC, 0, 0, $iLen + 10, 17, $hBrush) Case $NM_RCLICK $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) If DllStructGetData($tInfo, "Item") > -1 Then _GUICtrlMenu_TrackPopupMenu($hMenu, $GUI) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func FrameRect($hDC, $nLeft, $nTop, $nRight, $nBottom, $hBrush) Local $stRect = DllStructCreate("int;int;int;int") DllStructSetData($stRect, 1, $nLeft) DllStructSetData($stRect, 2, $nTop) DllStructSetData($stRect, 3, $nRight) DllStructSetData($stRect, 4, $nBottom) DllCall("user32.dll", "int", "FrameRect", "hwnd", $hDC, "ptr", DllStructGetPtr($stRect), "hwnd", $hBrush) EndFunc ;==>FrameRect Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iCode = BitShift($wParam, 16) Switch $lParam Case $hEdit Switch $iCode Case $EN_KILLFOCUS Local $iText = _GUICtrlEdit_GetText($hEdit) _GUICtrlListView_SetItemText($hListView, $Item, $iText, $SubItem) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($hEdit, $hDC) _WinAPI_DestroyWindow($hEdit) $Item = -1 $SubItem = 0 EndSwitch EndSwitch Switch $wParam Case $idMoveUp Move_Up() Case $idMoveDown Move_Down() Case $idDelete Delete_Item() EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND
      I have some problem with it, hope someone can give me a solution:
      1) The Move_Up and Move_Down fuction, for move items, isn't compatible with $LVS_REPORT and i don't know what is the problem
      2) When i double click i can edit the item, but i want to confirm with RETURN key and not clicking outside the item, and i don't know how to do
      3) I can't sort item. If i use GUICtrlCreateListView i can sort but i can't double click with editing the item, if i use _GUICtrlListView_Create i can't sort but i can edit the items...

      I'm in a dead end
      Thanks for any help
×
×
  • Create New...