Spenhouet Posted June 4, 2012 Posted June 4, 2012 Hi Forum Here is my code: expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> #Include <GuiListView.au3> #include <ListViewConstants.au3> #EndRegion ### include #Region ### START GUI section ### #Region ### Form $Form1 = GUICreate("Tests", 426, 220, 352, 147) #EndRegion ### Form #Region ### Testlist $testlist = GUICtrlCreateListView("", 56, 15, 353, 70, BitOR($WS_HSCROLL,$WS_VSCROLL,$WS_BORDER,$LVS_NOCOLUMNHEADER), 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") _GUICtrlListView_AddColumn($testlist, "",335) #Region ### -> Enter here the existing tests <- $tl_na = _GUICtrlListView_AddItem($testlist, "Set up profile (no-account)",0) $tl_oI = _GUICtrlListView_AddItem($testlist, "Set up profile (only I)",0) $tl_aS = _GUICtrlListView_AddItem($testlist, "Adjust profile (add S)",0) $tl_IS = _GUICtrlListView_AddItem($testlist, "Set up profile (IS)",0) ;~ $tl_Map = _GUICtrlListView_AddItem($testlist, "Set up 1:1 Mapping",0) ;~ $tl_mail = _GUICtrlListView_AddItem($testlist, "Send an e-mail",0) #EndRegion ### exsisttest #EndRegion ### Testlist #Region ### Test selection $testselection = GUICtrlCreateListView("", 56, 125, 353, 50, BitOR($WS_HSCROLL,$WS_VSCROLL,$WS_BORDER,$LVS_NOCOLUMNHEADER), 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") _GUICtrlListView_AddColumn($testselection, "", 335) #EndRegion ### Test selection #Region ### Buttons $test = GUICtrlCreateButton("Test", 320, 175, 90, 30, 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") $manual = GUICtrlCreateButton("Manual", 216, 175, 90, 30, 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") #EndRegion ### Buttons GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) #EndRegion ### END GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView1 = GUICtrlGetHandle($testlist) $hWndListView2 = GUICtrlGetHandle($testselection) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView1 Switch $iCode Case $NM_dblclk $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($testlist, DllStructGetData($tInfo, "Index")) $inde = DllStructGetData($tInfo, "Index") _GUICtrlListView_DeleteItem($testlist, $inde) ;~ _GUICtrlListView_DeleteItemsSelected($testlist) _GUICtrlListView_AddItem($testselection, $text,0) EndSwitch Case $hWndListView2 Switch $iCode Case $NM_dblclk $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $text = _GUICtrlListView_GetItemText ($testselection, DllStructGetData($tInfo, "Index")) $inde = DllStructGetData($tInfo, "Index") _GUICtrlListView_DeleteItem($testselection, $inde) ;~ _GUICtrlListView_DeleteItemsSelected($testlist) _GUICtrlListView_AddItem($testlist, $text,0) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I wan't to move one Item of the List into the other List (remove in first, add in second). But DeleteItem won't work anyway.... -.- whats wrong? pls help me Spenhouet
ReFran Posted June 4, 2012 Posted June 4, 2012 At lest for DeleteItem you have to use the handle (not the control ID).$hWndListView2 = GUICtrlGetHandle($testselection)_GUICtrlListView_DeleteItem($hWndListView2 , $inde)HTH, Reinhard Spenhouet 1
Moderators Melba23 Posted June 4, 2012 Moderators Posted June 4, 2012 Spenhouet, You were mixing UDF and native commands when creatign the listviews and their items - always a recipe for tears. Take a look at this - I have also cleaned up the handler a little: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #endregion #region ### START GUI section ### #region ### Form $Form1 = GUICreate("Tests", 426, 220, 352, 147) #endregion ### Form #region ### Testlist $testlist = _GUICtrlListView_Create($Form1, "", 56, 15, 353, 70, BitOR($WS_HSCROLL, $WS_VSCROLL, $WS_BORDER, $LVS_REPORT, $LVS_NOCOLUMNHEADER), 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") _GUICtrlListView_AddColumn($testlist, "", 335) #region ### -> Enter here the existing tests <- $tl_na = _GUICtrlListView_AddItem($testlist, "Set up profile (no-account)", 0) $tl_oI = _GUICtrlListView_AddItem($testlist, "Set up profile (only I)", 0) $tl_aS = _GUICtrlListView_AddItem($testlist, "Adjust profile (add S)", 0) $tl_IS = _GUICtrlListView_AddItem($testlist, "Set up profile (IS)", 0) ;~ $tl_Map = _GUICtrlListView_AddItem($testlist, "Set up 1:1 Mapping",0) ;~ $tl_mail = _GUICtrlListView_AddItem($testlist, "Send an e-mail",0) #endregion ### -> Enter here the existing tests <- #endregion ### Testlist #region ### Test selection $testselection = _GUICtrlListView_Create($Form1, "", 56, 125, 353, 50, BitOR($WS_HSCROLL, $WS_VSCROLL, $WS_BORDER, $LVS_REPORT, $LVS_NOCOLUMNHEADER), 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") _GUICtrlListView_AddColumn($testselection, "", 335) #endregion ### Test selection #region ### Buttons $test = GUICtrlCreateButton("Test", 320, 175, 90, 30, 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") $manual = GUICtrlCreateButton("Manual", 216, 175, 90, 30, 0) GUICtrlSetFont(-1, 12, 400, 0, "Arial Narrow") #endregion ### Buttons GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) #endregion ### START GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Struct = $tagNMHDR and "int Item" Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int", $lParam) Local $hWndFrom, $iCode, $iIndex, $sText $iCode = DllStructGetData($tStruct, 3) Switch $iCode Case $NM_DBLCLK $hWndFrom = HWnd(DllStructGetData($tStruct, 1)) $iIndex = DllStructGetData($tStruct, 4) Switch $hWndFrom Case $testlist $sText = _GUICtrlListView_GetItemText($testlist, $iIndex) _GUICtrlListView_AddItem($testselection, $sText, 0) _GUICtrlListView_DeleteItem($testlist, $iIndex) Case $testselection $sText = _GUICtrlListView_GetItemText($testselection, $iIndex) _GUICtrlListView_AddItem($testlist, $sText, 0) _GUICtrlListView_DeleteItem($testselection, $iIndex) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY All clear? Please ask if not. M23 Spenhouet 1 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
AdmiralAlkex Posted June 4, 2012 Posted June 4, 2012 At lest for DeleteItem you have to use the handle (not the control ID).$hWndListView2 = GUICtrlGetHandle($testselection)_GUICtrlListView_DeleteItem($hWndListView2 , $inde)HTH, ReinhardWhy? Proove it.And dont' say it's because of the example, the documentation clearly state that control ids work and the function has code to handle them so it clearly can't be trusted. .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface
BrewManNH Posted June 4, 2012 Posted June 4, 2012 (edited) With the delete LV item function, if the LV items are created using the UDF functions (_GUICtrlListView_AddItem) you have to delete them using the handle of the LV, if you create them with the native AutoIt function, you can use the control ID. Mixing them won't work, it's a known issue with listviews. Edited June 4, 2012 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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