johnmcloud Posted December 15, 2012 Share Posted December 15, 2012 Hi guys, this is the script: expandcollapse popup#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 Link to comment Share on other sites More sharing options...
KaFu Posted December 15, 2012 Share Posted December 15, 2012 (edited) Some stuff for you to tinker on ... the Edit rect seems out of line to me (Win7), but was to lazy to dive into that ... expandcollapse popup#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) $hGUI = GUICreate("_GUICtrlListView_Example", 262, 351, -1, -1) $cListview = GUICtrlCreateListView("N°|Name|Subject", 5, 5, 250, 272) $hListview = GUICtrlGetHandle($cListview) _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) $c_Button_Add = GUICtrlCreateButton("Add", 90, 315, 80, 25) $Info = GUICtrlCreateInput("Subject", 88, 286, 83, 21) $c_Button_Save = GUICtrlCreateButton("Save", 174, 284, 80, 25) $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) $c_Dummy_Down = GUICtrlCreateDummy() $c_Dummy_Up = GUICtrlCreateDummy() $c_Dummy_Delete = GUICtrlCreateDummy() $c_Dummy_Enter = GUICtrlCreateDummy() Local $AccelKeys[4][2] = [["{DELETE}", $c_Dummy_Delete],["{UP}", $c_Dummy_Up],["{DOWN}", $c_Dummy_Down],["{ENTER}", $c_Dummy_Enter]] GUISetAccelerators($AccelKeys, $hGUI) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($hListview)] GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $c_Button_Add Add_Item() Case $c_Button_Save Save_List() Case $c_Dummy_Delete Delete_Item() Case $c_Dummy_Down Move_Down() Case $c_Dummy_Up Move_Up() Case $c_Dummy_Enter If _WinAPI_GetFocus() = $hEdit Then _WinAPI_SetFocus($hListview) ; fires $EN_KILLFOCUS in WM_COMMAND Case $cListview _GUICtrlListView_SimpleSort($hListview, $B_DESCENDING, GUICtrlGetState($cListview)) EndSwitch WEnd Func Add_Item() $Number += 1 _GUICtrlListView_AddItem($hListview, $Number, -1, 9999 + $Number) ; add lparam value, is used for sorting as far as I remember _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 ;==>_Arrange_Numbers 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($hGUI, $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, $hGUI) 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 Edited December 15, 2012 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
johnmcloud Posted December 15, 2012 Author Share Posted December 15, 2012 (edited) Hi KaFu, Very Nice, thanks Sorry for this late answer, my fault. Only a little problem, if i use: $cListview = GUICtrlCreateListView("N°|Name|Subject", 5, 5, 250, 272, $LVS_REPORT) The Move_Up and Move_Down function not work. Do you know why and if can be resolved? Thanks again EDIT: Oh, for center the Edit rect in the same position of the item, just change this line: $hEdit = _GUICtrlEdit_Create($hGUI, $iItemText, $aRect[0] + 8, $aRect[1] + 7, $iLen + 10, 17, $Style) Edited December 15, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
KaFu Posted December 15, 2012 Share Posted December 15, 2012 This works for me. $cListview = GUICtrlCreateListView("N°|Name|Subject", 5, 5, 250, 272, BitOR($LVS_SINGLESEL, $LVS_REPORT)) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
johnmcloud Posted December 15, 2012 Author Share Posted December 15, 2012 But if i use $LVS_SINGLESEL i can't select multiple items with CTRL or SHIFT, right? I'd like to make multiple selection Link to comment Share on other sites More sharing options...
KaFu Posted December 15, 2012 Share Posted December 15, 2012 Yeah, that's right. I think the problem is not the LV style, but within the functions Move_Up and Move_Down. You only select new ones, but you don't deselect the old ones, see this line. _GUICtrlListView_SetItemSelected($hListview, $Sel, 0) I guess you need to think of a way on how to handle the move operation when more than one item is selected, this scenario is currently not reflected in the functions. expandcollapse popup#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) $hGUI = GUICreate("_GUICtrlListView_Example", 262, 351, -1, -1) ;$cListview = GUICtrlCreateListView("N°|Name|Subject", 5, 5, 250, 272) $cListview = GUICtrlCreateListView("N°|Name|Subject", 5, 5, 250, 272, $LVS_REPORT) $hListview = GUICtrlGetHandle($cListview) _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) $c_Button_Add = GUICtrlCreateButton("Add", 90, 315, 80, 25) $Info = GUICtrlCreateInput("Subject", 88, 286, 83, 21) $c_Button_Save = GUICtrlCreateButton("Save", 174, 284, 80, 25) $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) $c_Dummy_Down = GUICtrlCreateDummy() $c_Dummy_Up = GUICtrlCreateDummy() $c_Dummy_Delete = GUICtrlCreateDummy() $c_Dummy_Enter = GUICtrlCreateDummy() Local $AccelKeys[4][2] = [["{DELETE}", $c_Dummy_Delete],["{UP}", $c_Dummy_Up],["{DOWN}", $c_Dummy_Down],["{ENTER}", $c_Dummy_Enter]] GUISetAccelerators($AccelKeys, $hGUI) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($hListview)] GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $c_Button_Add Add_Item() Case $c_Button_Save Save_List() Case $c_Dummy_Delete Delete_Item() Case $c_Dummy_Down Move_Down() Case $c_Dummy_Up Move_Up() Case $c_Dummy_Enter If _WinAPI_GetFocus() = $hEdit Then _WinAPI_SetFocus($hListview) ; fires $EN_KILLFOCUS in WM_COMMAND Case $cListview _GUICtrlListView_SimpleSort($hListview, $B_DESCENDING, GUICtrlGetState($cListview)) EndSwitch WEnd Func Add_Item() $Number += 1 _GUICtrlListView_AddItem($hListview, $Number, -1, 9999 + $Number) ; add lparam value, is used for sorting as far as I remember _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 ;==>_Arrange_Numbers 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, 0) _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, 0) _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($hGUI, $iItemText, $aRect[0] + 3, $aRect[1], $iLen + 10, 17, $Style) $hEdit = _GUICtrlEdit_Create($hGUI, $iItemText, $aRect[0] + 8, $aRect[1] + 7, $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, $hGUI) 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 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 16, 2012 Moderators Share Posted December 16, 2012 johnmcloud,Take a look at my GUIListViewEx UDF. I faced the same problem (how to handle the move operation when more than one item is selected) and decided that I would only accept a consecutive block. There is some code in there (look at lines 829-860) which might help you do the same thing in your script. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
KaFu Posted December 16, 2012 Share Posted December 16, 2012 Nice spot and cross-reference Mr. Hawkeye ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
johnmcloud Posted December 16, 2012 Author Share Posted December 16, 2012 (edited) I have added the Melba's code part about the moving part: expandcollapse popup#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) $hGUI = GUICreate("_GUICtrlListView_Example", 262, 351, -1, -1) $cListview = GUICtrlCreateListView("N°|Name|Subject", 5, 5, 250, 272, $LVS_REPORT) $hListview = GUICtrlGetHandle($cListview) _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) $c_Button_Add = GUICtrlCreateButton("Add", 90, 315, 80, 25) $Info = GUICtrlCreateInput("Subject", 88, 286, 83, 21) $c_Button_Save = GUICtrlCreateButton("Save", 174, 284, 80, 25) $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) $c_Dummy_Down = GUICtrlCreateDummy() $c_Dummy_Up = GUICtrlCreateDummy() $c_Dummy_Delete = GUICtrlCreateDummy() $c_Dummy_Enter = GUICtrlCreateDummy() Local $AccelKeys[4][2] = [["{DELETE}", $c_Dummy_Delete],["{UP}", $c_Dummy_Up],["{DOWN}", $c_Dummy_Down],["{ENTER}", $c_Dummy_Enter]] GUISetAccelerators($AccelKeys, $hGUI) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($hListview)] GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $c_Button_Add Add_Item() Case $c_Button_Save Save_List() Case $c_Dummy_Delete Delete_Item() Case $c_Dummy_Down Move_Down() Case $c_Dummy_Up Move_Up() Case $c_Dummy_Enter If _WinAPI_GetFocus() = $hEdit Then _WinAPI_SetFocus($hListview) ; fires $EN_KILLFOCUS in WM_COMMAND Case $cListview _GUICtrlListView_SimpleSort($hListview, $B_DESCENDING, GUICtrlGetState($cListview)) EndSwitch WEnd Func Add_Item() $Number += 1 _GUICtrlListView_AddItem($hListview, $Number, -1, 9999 + $Number) ; add lparam value, is used for sorting as far as I remember _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 ;==>_Arrange_Numbers 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() ; Get dragged item index $iGLVExDragged_Index = DllStructGetData($tStruct, 4) ; Item ; Set dragged item count $iGLVEx_Dragging = 1 ; Check for selected items Local $iIndex = _GUICtrlListView_GetSelectedIndices($hListview) ; Check if item is part of a multiple selection If StringInStr($iIndex, $iGLVExDragged_Index) And StringInStr($iIndex, "|") Then ; Extract all selected items Local $aIndex = StringSplit($iIndex, "|") For $i = 1 To $aIndex[0] If $aIndex[$i] = $iGLVExDragged_Index Then ExitLoop Next ; Now check for consecutive items If $i <> 1 Then ; Up For $j = $i - 1 To 1 Step -1 ; Consecutive? If $aIndex[$j] <> $aIndex[$j + 1] - 1 Then ExitLoop ; Adjust dragged index to this item $iGLVExDragged_Index -= 1 ; Increase number to drag $iGLVEx_Dragging += 1 Next EndIf If $i <> $aIndex[0] Then ; Down For $j = $i + 1 To $aIndex[0] ; Consecutive If $aIndex[$j] <> $aIndex[$j - 1] + 1 Then ExitLoop ; Increase number to drag $iGLVEx_Dragging += 1 Next EndIf Else ; Either no selection or only a single ; Set flag $iGLVEx_Dragging = 1 EndIf _Arrange_Numbers() EndFunc ;==>Move_Up Func Move_Down() ;~ Test 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 Global $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $ilParam) $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($hGUI, $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, $hGUI) 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 Seemes do nothing and i don't have any error. I'm sure is my mistake, or i don't have understand what i need to do with the flag Edited December 16, 2012 by johnmcloud Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now