ActualAkshay Posted May 4, 2012 Share Posted May 4, 2012 (edited) Hi everyone, I have attached a file below, in the GUI there is a List View that displays a list of items, and theres an input box, i want it in such way that when you select an item from list, its automatically shown in the input box. I tried to make it work for hours, but couldnt make it work, would really appreciate it if someone helps me out thank you GUI.au3 EDIT: PS here is other other GUI with which im having problem, you have to drag and drop files on combo to make file list Good Luck with it GUI 2.au3 GUIListViewEx.au3 Edited May 4, 2012 by ActualAkshay Link to comment Share on other sites More sharing options...
ahmet Posted May 4, 2012 Share Posted May 4, 2012 You do it just like line Case $GUI_EVENT_CLOSE. You'll only put variables of your ListViewItems. Also look in AutoIt's help file for GUICtrlRead() and GUICtrlSetData(). Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 4, 2012 Author Share Posted May 4, 2012 You do it just like line Case $GUI_EVENT_CLOSE. You'll only put variables of your ListViewItems. Also look in AutoIt's help file for GUICtrlRead() and GUICtrlSetData(). i tried everything, but i couldnt make it work at all, I even tried using _GUIListViewEx_WM_LBUTTONUP_Handler from _GUIListViewEx UDF, _GUICtrlListView_GetItemText() but nothing worked, GUICtrlRead() return strange numbers like 120, 121, 124 Link to comment Share on other sites More sharing options...
ahmet Posted May 4, 2012 Share Posted May 4, 2012 If you use GUICtrlRead on $ListView1_2 it returns 4324|. You may also look at StringTrimRight(). Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 4, 2012 Author Share Posted May 4, 2012 (edited) yes right, if i trim the item number from StringTrimRight, _GUICtrlListView_GetItemText can be used to display the item, but whats the reason behind list view returning numbers? and cant items be directly returned by any other way that could make the program simple? Edited May 4, 2012 by ActualAkshay Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 4, 2012 Author Share Posted May 4, 2012 OOPS, sorry, its working with this gui, let me upload another GUI, where it dont work Link to comment Share on other sites More sharing options...
ahmet Posted May 4, 2012 Share Posted May 4, 2012 Try thisCase $ListView1_2 GUICtrlSetData($Input1,StringTrimRight(GUICtrlRead($ListView1_2),1)) Case $ListView1_3 GUICtrlSetData($Input1,StringTrimRight(GUICtrlRead($ListView1_3),1)) $ListView1_3 and $ListView1_2 can be repleaced with $nMsg Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 4, 2012 Author Share Posted May 4, 2012 Try thisCase $ListView1_2 GUICtrlSetData($Input1,StringTrimRight(GUICtrlRead($ListView1_2),1)) Case $ListView1_3 GUICtrlSetData($Input1,StringTrimRight(GUICtrlRead($ListView1_3),1)) $ListView1_3 and $ListView1_2 can be repleaced with $nMsg so here is other other GUI with which im having problem, you have to drag and drop files on combo to make file list Good Luck with it GUI 2.au3 GUIListViewEx.au3 Link to comment Share on other sites More sharing options...
ahmet Posted May 4, 2012 Share Posted May 4, 2012 I think I don't understand your problem well. Do you want to populate listview with files you drag or combobox, because the cod does once and you wrote other? Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 5, 2012 Author Share Posted May 5, 2012 I want it in such way, that when u drag and drop files on the list view, its filled with file path, and when u select a file from list, its displayed on the input on the left side of the gui Link to comment Share on other sites More sharing options...
ahmet Posted May 5, 2012 Share Posted May 5, 2012 (edited) Set this function Func Set() GUICtrlSetData($TitleC,GUICtrlRead(@GUI_CtrlId)) EndFunc to be called when you click ListViewItem. Try with GUICtrlSetOnEvent(-1,"Set") Edited May 5, 2012 by ahmet Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 5, 2012 Author Share Posted May 5, 2012 Set this function Func Set() GUICtrlSetData($TitleC,GUICtrlRead(@GUI_CtrlId)) EndFunc to be called when you click ListViewItem. Try with GUICtrlSetOnEvent(-1,"Set") no it isnt working, i have already tried this, and i again tried it to make usre if you are right, come on, can you please try it yourself before suggesting something Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 5, 2012 Author Share Posted May 5, 2012 sure* Link to comment Share on other sites More sharing options...
ahmet Posted May 5, 2012 Share Posted May 5, 2012 Of course I have tried it and it worked. expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GUIListViewEx.au3> #include <array.au3> Opt("GUIOnEventMode", 1) Opt("GUIResizeMode", 1) ;~ Global $WM_DROPFILES = 0x233 Global $DropFilesArr[1], $IDs[10], $counter=0 Local $FileList, $CancelB, $TitleC _GUICreate() _SetOnEvents() $sel_file_index = 0 While 1 Sleep(10) WEnd Func _GUICreate() #Region ### START Koda GUI section ### Form=Form2 (2).kxf $GUI = GUICreate("Akshay", 608, 376, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, "")) $TitleC = GUICtrlCreateInput("", 74, 59, 256, 25) ;, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_GROUP)) $FileList = GUICtrlCreateListView("Name", 376, 8, 224, 360, BitOR($LVS_SHOWSELALWAYS, $WS_HSCROLL)) GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC") #EndRegion ### END Koda GUI section ### EndFunc ;==>_GUICreate Func _GUIDelete() GUIDelete() EndFunc ;==>_GUIDelete Func _Exit() Exit EndFunc ;==>_Exit Func _SetOnEvents() GUISetOnEvent($GUI_EVENT_DROPPED, "_DragFileFill") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") EndFunc ;==>_SetOnEvents Func _DragFileFill() $NotValidExtPath = "" $ValidExtCount = 0 For $i = 1 To UBound($DropFilesArr) - 1 ;~ If (UBound($IDs))>$counter Then ReDim $IDs[2*UBound($IDs)] ;~ ConsoleWrite("$counter=" & $counter) $ValidExtCount += 1 ;~ $counter=$counter+1 GUICtrlCreateListViewItem($DropFilesArr[$i], $FileList) GUICtrlSetOnEvent(-1,"Set") Next If $ValidExtCount > 0 Then GUICtrlSendMsg($FileList, $LVM_SETCOLUMNWIDTH, 0, -1) _GUICtrlListView_SetItemSelected($FileList, 0) EndFunc ;==>_DragFileFill Func _File_Selected() $sel_file_text = _GUICtrlListView_GetItemText($FileList, GUICtrlRead($FileList)) GUICtrlSetData($TitleC, $sel_file_text) EndFunc ;==>_File_Selected Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("char[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", _ DllStructGetPtr($pFileName), "int", $nSize) ReDim $DropFilesArr[$i + 2] $DropFilesArr[$i + 1] = DllStructGetData($pFileName, 1) $pFileName = 0 Next $DropFilesArr[0] = UBound($DropFilesArr) - 1 EndFunc ;==>WM_DROPFILES_FUNC Func Set() GUICtrlSetData($TitleC,GUICtrlRead(@GUI_CtrlId)) EndFunc I think that the function in you while loop you had, the one in the same line with If... , was for GUIRegister Message() ActualAkshay 1 Link to comment Share on other sites More sharing options...
ActualAkshay Posted May 6, 2012 Author Share Posted May 6, 2012 Of course I have tried it and it worked. expandcollapse popup#include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GUIListViewEx.au3> #include <array.au3> Opt("GUIOnEventMode", 1) Opt("GUIResizeMode", 1) ;~ Global $WM_DROPFILES = 0x233 Global $DropFilesArr[1], $IDs[10], $counter=0 Local $FileList, $CancelB, $TitleC _GUICreate() _SetOnEvents() $sel_file_index = 0 While 1 Sleep(10) WEnd Func _GUICreate() #Region ### START Koda GUI section ### Form=Form2 (2).kxf $GUI = GUICreate("Akshay", 608, 376, -1, -1, -1, BitOR($WS_EX_ACCEPTFILES, "")) $TitleC = GUICtrlCreateInput("", 74, 59, 256, 25) ;, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_GROUP)) $FileList = GUICtrlCreateListView("Name", 376, 8, 224, 360, BitOR($LVS_SHOWSELALWAYS, $WS_HSCROLL)) GUICtrlSendMsg(-1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_HEADERDRAGDROP, $LVS_EX_HEADERDRAGDROP) GUICtrlSetState(-1, $GUI_DROPACCEPTED) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES_FUNC") #EndRegion ### END Koda GUI section ### EndFunc ;==>_GUICreate Func _GUIDelete() GUIDelete() EndFunc ;==>_GUIDelete Func _Exit() Exit EndFunc ;==>_Exit Func _SetOnEvents() GUISetOnEvent($GUI_EVENT_DROPPED, "_DragFileFill") GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") EndFunc ;==>_SetOnEvents Func _DragFileFill() $NotValidExtPath = "" $ValidExtCount = 0 For $i = 1 To UBound($DropFilesArr) - 1 ;~ If (UBound($IDs))>$counter Then ReDim $IDs[2*UBound($IDs)] ;~ ConsoleWrite("$counter=" & $counter) $ValidExtCount += 1 ;~ $counter=$counter+1 GUICtrlCreateListViewItem($DropFilesArr[$i], $FileList) GUICtrlSetOnEvent(-1,"Set") Next If $ValidExtCount > 0 Then GUICtrlSendMsg($FileList, $LVM_SETCOLUMNWIDTH, 0, -1) _GUICtrlListView_SetItemSelected($FileList, 0) EndFunc ;==>_DragFileFill Func _File_Selected() $sel_file_text = _GUICtrlListView_GetItemText($FileList, GUICtrlRead($FileList)) GUICtrlSetData($TitleC, $sel_file_text) EndFunc ;==>_File_Selected Func WM_DROPFILES_FUNC($hWnd, $msgID, $wParam, $lParam) Local $nSize, $pFileName Local $nAmt = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", 0xFFFFFFFF, "ptr", 0, "int", 255) For $i = 0 To $nAmt[0] - 1 $nSize = DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", 0, "int", 0) $nSize = $nSize[0] + 1 $pFileName = DllStructCreate("char[" & $nSize & "]") DllCall("shell32.dll", "int", "DragQueryFile", "hwnd", $wParam, "int", $i, "ptr", _ DllStructGetPtr($pFileName), "int", $nSize) ReDim $DropFilesArr[$i + 2] $DropFilesArr[$i + 1] = DllStructGetData($pFileName, 1) $pFileName = 0 Next $DropFilesArr[0] = UBound($DropFilesArr) - 1 EndFunc ;==>WM_DROPFILES_FUNC Func Set() GUICtrlSetData($TitleC,GUICtrlRead(@GUI_CtrlId)) EndFunc I think that the function in you while loop you had, the one in the same line with If... , was for GUIRegister Message() Oh thanks a lot bro it worked, you rock!! thank you soooooo much 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