gcue Posted July 20, 2016 Posted July 20, 2016 hello =) i am trying to allow single clicking the item to checkbox the item and double clicking the item to open it. with this Case $NM_CLICK $selected_index = _GUICtrlListView_GetSelectionMark($scan_listview) If $selected_index <> -1 Then $checked = _GUICtrlListView_GetItemChecked($scan_listview, $selected_index) If $checked = False Then _GUICtrlListView_SetItemChecked($scan_listview, $selected_index, True) Else _GUICtrlListView_SetItemChecked($scan_listview, $selected_index, False) EndIf _GUICtrlListView_SetSelectionMark($scan_listview, -1) EndIf problem is if i dont disable the selection mark after a single click, the selections go out of whack if an item is left highlited (not checked) but of course disabling the selection mark prevents me from double clicking a bit hard to explain - here is a working example to demonstrate expandcollapse popup#include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiImageList.au3> #include <GDIPlus.au3> #include <File.au3> Opt("GUIOnEventMode", 1) $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) $iExListViewStyle = BitOR($LVS_REPORT, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_CHECKBOXES) $GUI = GUICreate("test", 800, 700) $scan_listview = GUICtrlCreateListView("Thumbnail|File Name", 30, 40, 740, 600, -1, $iExWindowStyle) _GUICtrlListView_SetColumnWidth($scan_listview, 0, 100) _GUICtrlListView_SetColumnWidth($scan_listview, 1, 610) _GUICtrlListView_SetExtendedListViewStyle($scan_listview, $iExListViewStyle) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetState() Populate() While 1 Sleep(10) WEnd Func Populate() Local $GDIpBmpLarge, $GDIpBmpResized, $GDIbmp, $hImage $file_types = "*.jpg" $source_parent_dir = FileSelectFolder("Please select folder.", "", 2) If @error Then Return EndIf $hImage = _GUIImageList_Create(64, 64, 5, 3) _GUICtrlListView_SetImageList($scan_listview, $hImage) _GDIPlus_Startup() $file_paths_array = _FileListToArrayRec($source_parent_dir, $file_types, $FLTAR_FILES, 1, $FLTAR_SORT, $FLTAR_FULLPATH) Global $master_sorted_array[UBound($file_paths_array)][8] $current_row = 0 _GUICtrlListView_BeginUpdate($scan_listview) For $x = 1 To UBound($file_paths_array) - 1 $full_file_path = $file_paths_array[$x] $file_name_extension = _GetFileNameExtension($file_paths_array[$x]) $master_sorted_array[$x - 1][0] = $full_file_path $master_sorted_array[$x - 1][1] = $file_name_extension $image_path = $full_file_path $GDIpBmpLarge = _GDIPlus_ImageLoadFromFile($image_path) $GDIpBmpResized = _GDIPlus_ImageResize($GDIpBmpLarge, 64, 64) $GDIbmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($GDIpBmpResized) $img = _GUIImageList_Add($hImage, $GDIbmp) _GUICtrlListView_SetImageList($scan_listview, $hImage, 1) _GUICtrlListView_AddItem($scan_listview, StringRegExp($image_path, ".*\\(.+)$", 1), $img) ;image _GDIPlus_BitmapDispose($GDIpBmpLarge) _GDIPlus_BitmapDispose($GDIpBmpResized) _GUICtrlListView_AddSubItem($scan_listview, $current_row, $file_name_extension, 1) $current_row += 1 Next _GUICtrlListView_EndUpdate($scan_listview) _GDIPlus_Shutdown() EndFunc Func _GetFileNameExtension($sFile) Return StringRegExpReplace($sFile, "^.*\\", "") EndFunc ;==>_GetFileNameExtension Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListview $hWndListview = $scan_listview If Not IsHWnd($scan_listview) Then $hWndListview = GUICtrlGetHandle($scan_listview) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListview Switch $iCode Case $NM_CLICK $selected_index = _GUICtrlListView_GetSelectionMark($scan_listview) If $selected_index <> -1 Then $checked = _GUICtrlListView_GetItemChecked($scan_listview, $selected_index) If $checked = False Then _GUICtrlListView_SetItemChecked($scan_listview, $selected_index, True) Else _GUICtrlListView_SetItemChecked($scan_listview, $selected_index, False) EndIf _GUICtrlListView_SetSelectionMark($scan_listview, -1) EndIf ;~ _GUICtrlListView_SetItemSelected($scan_listview, -1, False) Case $NM_DBLCLK $selected_index = _GUICtrlListView_GetSelectionMark($scan_listview) If $selected_index <> -1 Then $file_full_path = $master_sorted_array[$selected_index][0] ShellExecute($file_full_path) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _Exit() Exit EndFunc ;==>_Exit thanks in advance!
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