RegularGuy Posted August 6, 2011 Posted August 6, 2011 (edited) Hello, I’ve been having this problem for a few days now and after all the research I’ve done, I can’t for the life of me figure out what I need to do. I currently have a GUI that generates a List view, I would like to double click on one of the list view items and have another GUI pop up with expanded information about selection. The information is placed in Input controls that are disabled, and can be enabled by pressing a button off to the side. I wish to expand to this more. I am having issues with the double click. As it goes, when I double click a function is called but not within the original loop of the Parent Gui. I’ve only included the parts I think I’m having trouble with (the first is the Parent window, the second is the double click function, and lastly is the child window) ive read that it is possible to have two Qui windows up at the same time and the code for the double click I found here in the Forums, but I feel that I need the double click to register within the main menu loop, I just don’t know if that is correct or how I might go about this another way ( I have also studied a bit on GUIset onEvent but I don’t know if that’s what I need) Thank you in advance for your help, please let me know if you need anything more. RegularGuy expandcollapse popup;-------------------MAIN MENU Func _create_main_menu() $Gui = GUICreate("Main Menu", $guix, $guiy) $tab = GUICtrlCreateTab(-1, 0, $guix + 5, $guiy + 5) ;-------------------- Create the "Add Entry" tab $add_entry = GUICtrlCreateTabItem("Add Entry") GUICtrlCreateLabel("Date Recieved:", 20, 44) $daterec_add = Guictrlcreateinput("", 100, 40, 100) GuiCtrlCreatelabel("Date Sent:", 245, 44) $datesent_add = GUICtrlCreateInput("", 300, 40, 100) GUICtrlCreateLabel("Address 1:", 20, 69) $address1_add = GUICtrlCreateInput("1234 W. State St.,", 100, 65, 300) GUICtrlCreateLabel("Address 2:", 20, 94) $address2_add = GUICtrlCreateInput("", 100, 90, 300) GUICtrlCreateLabel("City:", 20, 119) $city_add = GUICtrlCreateInput("", 100, 115, 150) GUICtrlCreateLabel("State:", 265, 119) $state_add = GUICtrlCreateInput("IL", 300, 115, 25, -1, 0X0800) GUICtrlCreateLabel("Zip Code:", 20, 144) $zip_code_add = GUICtrlCreateInput("", 100, 140, 100) GUICtrlCreateLabel("File Number:", 20, 169) $filenumber_add = GUICtrlCreateInput("", 100, 165, 100) GUICtrlCreateLabel("Negotiator:", 245, 169) $negotiator_add = GUICtrlCreateInput("", 300, 165, 100) GuiCtrlcreatelabel("Letter Type:", 20, 194) $letter_type_add = Guictrlcreateinput("", 100, 190, 200) GUICtrlCreateLabel("Status:", 20, 219) $status_add = Guictrlcreateinput("", 100, 215, 300) $saveopen_add = GUICtrlCreateButton("Save/Open", 20, 245, 75) $save_add = GUICtrlCreateButton("Save", 115, 245, 75) $clear_add = GUICtrlCreateButton("Clear Fields", 210, 245, 75) $search_add = GUICtrlCreateButton("Search Entry", 305, 245, 75) $listview_top = 280 $listview_add_entry = GUICtrlCreateListView("Address 1|Address 2|City|State|Zip|Filenumber|Negotiator", 20, $listview_top, $guix - 40, $guiy - $listview_top - 50) _GUICtrlListView_SetColumnWidth($listview_add_entry, 0, 200);Address1 _GUICtrlListView_SetColumnWidth($listview_add_entry, 2, 100);City _GUICtrlListView_SetColumnWidth($listview_add_entry, 4, 50) ;zip ;-------------------- Create the "Work Schedule" Tab $workschedule = GUICtrlCreateTabItem("Work Schedule") GUICtrlCreateListView("Address|Filenumber|Date Rec.|Type|Negotiator|Status", 20, 40, $guix - 40, $guiy - 100) ;--------------------------------------------------; GUICtrlCreateTabItem("") $exit = GUICtrlCreateButton("Exit", 20, $guiy - 40, 75) GUISetState() $notify = GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $Gui Switch $msg[0] Case $GUI_EVENT_CLOSE Exit Case $exit Exit Case $clear_add _clear_entry_add() _clear_search_results() Case $save_add If GUICtrlRead($address1_add) == "" Then MsgBox(0, "Insuficient Information", "Please provide some information" & @CRLF & 'in "Address1:" line') Else _clear_search_results() _add_address() _update_search_fields() EndIf Case $search_add If GUICtrlRead($address1_add) == "" And GUICtrlRead($filenumber_add) == "" Then MsgBox(0, "Insuficient Information", " Please enter something into either" & @CRLF & '"Address1:" or "Filenumber:" line') Else _clear_search_results() _search_filenum_or_address() _update_search_fields() EndIf Case $saveopen_add If GUICtrlRead($address1_add) == "" Then MsgBox(0, "Insuficient Information", "Please provide some information" & @CRLF & 'in "Address1:" line') Else _clear_search_results() _add_address() _update_search_fields() EndIf Case $listview_add_entry MsgBox(0,"","You double clicked") EndSwitch Case $Gui_Address Switch $msg[0] Case $GUI_EVENT_CLOSE GUIDelete($Gui_Address) _create_main_menu() Case $edit_button _edit_mode() EndSwitch EndSwitch WEnd GUIDelete() EndFunc ;==>_create_main_menu ;-------------DOUBLE CLICK Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $listview_add_entry If Not IsHWnd($listview_add_entry) Then $hWndListView = GUICtrlGetHandle($listview_add_entry) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) Local $aInfo[5] = [$hWndFrom, $iIDFrom, $iCode, DllStructGetData($tInfo, "Index"), _ DllStructGetData($tInfo, "SubItem")] IF $tInfo <> -1 Then ToolTip("You Double Clicked on" & @CRLF & "3---Column: " & $aInfo[3] & @CRLF & "4---Row: " & $aInfo[4], 0, 0) _address_gui($aInfo[4], $new_entry_search); EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;------------------------CHILD GUI-------------- Func _address_gui($rownum, $entryarray) $Gui_Address = Guicreate($entryarray[$rownum][1]&" - "&$entryarray[$rownum][6], 700, 500,-1,-1,-1,-1,$Gui) $address1_display = GUICtrlCreateInput(" "&$entryarray[$rownum][1], 100, 20, 300,-1, 0X0800) GUICtrlCreateLabel("Address 1:", 20, 24) $address2_display = GUICtrlCreateInput(" "&$entryarray[$rownum][2], 100, 45, 300,-1, 0X0800) GUICtrlCreateLabel("Address 2:", 20, 49) $city_display = GUICtrlCreateInput(" "&$entryarray[$rownum][3], 100, 70, 150,-1, 0X0800) GUICtrlCreateLabel("City:", 20, 75) $state_display = GUICtrlCreateInput(" "&$entryarray[$rownum][4], 300, 70, 25, -1, 0X0800) GUICtrlCreateLabel("State:", 265, 75) $zip_code_display = GUICtrlCreateInput(" "&$entryarray[$rownum][5], 100, 95, 100,-1, 0X0800) GUICtrlCreateLabel("Zip Code:", 20, 99) $filenumber_display = GUICtrlCreateInput(" "&$entryarray[$rownum][6], 100, 120, 100,-1, 0X0800) GUICtrlCreateLabel("File Number:", 20, 124) $negotiator_display = GUICtrlCreateInput(" "&$entryarray[$rownum][7], 300, 120, 100,-1, 0X0800) GUICtrlCreateLabel("Negotiator:", 245, 124) $letter_type_display = Guictrlcreateinput(" "&$entryarray[$rownum][8], 100, 145, 200,-1, 0X0800) GuiCtrlcreatelabel("Letter Type:", 20, 149) $status_display = Guictrlcreateinput("", 100, 170, 300,-1, 0X0800) GUICtrlCreateLabel("Status:", 20, 174) $edit_button = GUICtrlCreateButton ("Edit Address", 500, 95) GUISetState() ;@SW_SHOW, $Gui_Address EndFunc Edited August 6, 2011 by RegularGuy
rover Posted August 6, 2011 Posted August 6, 2011 Hello, I’ve been having this problem for a few days now and after all the research I’ve done, I can’t for the life of me figure out what I need to do. I currently have a GUI that generates a List view, I would like to double click on one of the list view items and have another GUI pop up with expanded information about selection. The information is placed in Input controls that are disabled, and can be enabled by pressing a button off to the side. I wish to expand to this more. I am having issues with the double click. As it goes, when I double click a function is called but not within the original loop of the Parent Gui. I’ve only included the parts I think I’m having trouble with (the first is the Parent window, the second is the double click function, and lastly is the child window) ive read that it is possible to have two Qui windows up at the same time and the code for the double click I found here in the Forums, but I feel that I need the double click to register within the main menu loop, I just don’t know if that is correct or how I might go about this another way ( I have also studied a bit on GUIset onEvent but I don’t know if that’s what I need) Thank you in advance for your help, please let me know if you need anything more. RegularGuy A GUICtrlCreateDummy() control is perfect for this. It is generally helpful to post a functional code reproducer so those who help do not have to make the code functional in order to show working code to you the original poster and to those who may read this later. I prefer to post a working example. A block of code is worth a 1000 words expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> ;Use this Opt() line with the SciTE editor. ;It makes a good taskmaster for enforcing declaration of variables in global or local scope. ;Opt('MustDeclareVars', 1) ;Your going to need globals for the vars accessed in wm_notify, _create_main_menu and _address_gui Global $listview_add_entry, $Gui, $Gui_Address, $edit_button, $cLVItem Global $aNew_entry_search[30][9] _create_main_menu() ;-------------------MAIN MENU Func _create_main_menu() Local $guix = 600, $guiy = 600 $Gui = GUICreate("Main Menu", $guix, $guiy) $tab = GUICtrlCreateTab(-1, 0, $guix + 5, $guiy + 5) ;-------------------- Create the "Add Entry" tab $add_entry = GUICtrlCreateTabItem("Add Entry") GUICtrlCreateLabel("Date Recieved:", 20, 44) $daterec_add = Guictrlcreateinput("", 100, 40, 100) GuiCtrlCreatelabel("Date Sent:", 245, 44) $datesent_add = GUICtrlCreateInput("", 300, 40, 100) GUICtrlCreateLabel("Address 1:", 20, 69) $address1_add = GUICtrlCreateInput("1234 W. State St.,", 100, 65, 300) GUICtrlCreateLabel("Address 2:", 20, 94) $address2_add = GUICtrlCreateInput("", 100, 90, 300) GUICtrlCreateLabel("City:", 20, 119) $city_add = GUICtrlCreateInput("", 100, 115, 150) GUICtrlCreateLabel("State:", 265, 119) $state_add = GUICtrlCreateInput("IL", 300, 115, 25, -1, 0X0800) GUICtrlCreateLabel("Zip Code:", 20, 144) $zip_code_add = GUICtrlCreateInput("", 100, 140, 100) GUICtrlCreateLabel("File Number:", 20, 169) $filenumber_add = GUICtrlCreateInput("", 100, 165, 100) GUICtrlCreateLabel("Negotiator:", 245, 169) $negotiator_add = GUICtrlCreateInput("", 300, 165, 100) GuiCtrlcreatelabel("Letter Type:", 20, 194) $letter_type_add = Guictrlcreateinput("", 100, 190, 200) GUICtrlCreateLabel("Status:", 20, 219) $status_add = Guictrlcreateinput("", 100, 215, 300) $saveopen_add = GUICtrlCreateButton("Save/Open", 20, 245, 75) $save_add = GUICtrlCreateButton("Save", 115, 245, 75) $clear_add = GUICtrlCreateButton("Clear Fields", 210, 245, 75) $search_add = GUICtrlCreateButton("Search Entry", 305, 245, 75) $listview_top = 280 $listview_add_entry = GUICtrlCreateListView("Address 1|Address 2|City|State|Zip|Filenumber|Negotiator", 20, $listview_top, $guix - 40, $guiy - $listview_top - 50) _GUICtrlListView_SetColumnWidth($listview_add_entry, 0, 200);Address1 _GUICtrlListView_SetColumnWidth($listview_add_entry, 2, 100);City _GUICtrlListView_SetColumnWidth($listview_add_entry, 4, 50) ;zip For $i = 1 To 30 GUICtrlCreateListViewItem("Row" & $i & ": Col 1|Row" & $i & ": Col 2|Row" & $i & ": Col 3", $listview_add_entry) Next ;-------------------- Create the "Work Schedule" Tab $workschedule = GUICtrlCreateTabItem("Work Schedule") $t = GUICtrlCreateListView("Address|Filenumber|Date Rec.|Type|Negotiator|Status", 20, 40, $guix - 40, $guiy - 100) ;--------------------------------------------------; GUICtrlCreateTabItem("") $exit = GUICtrlCreateButton("Exit", 20, $guiy - 40, 75) $cLVItem = GUICtrlCreateDummy() ; dummy control for listview LVN_ITEMACTIVATE dblclick on item $notify = GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState() While 1 $msg = GUIGetMsg(1) Switch $msg[1] Case $Gui Switch $msg[0] Case 0 ;used for large case statements so the 0 returned by continuous polling is not tested against all statements Case $GUI_EVENT_CLOSE Exit Case $exit Exit Case $clear_add ;~ _clear_entry_add() ;~ _clear_search_results() Case $cLVItem ;listview dummy control ;retrieve selected listview index from dummy with GUICtrlRead() _address_gui(GUICtrlRead($cLVItem), $aNew_entry_search) Case $save_add If GUICtrlRead($address1_add) == "" Then MsgBox(0, "Insuficient Information", "Please provide some information" & @CRLF & 'in "Address1:" line') Else ;~ _clear_search_results() ;~ _add_address() ;~ _update_search_fields() EndIf Case $search_add If GUICtrlRead($address1_add) == "" And GUICtrlRead($filenumber_add) == "" Then MsgBox(0, "Insuficient Information", " Please enter something into either" & @CRLF & '"Address1:" or "Filenumber:" line') Else ;~ _clear_search_results() ;~ _search_filenum_or_address() ;~ _update_search_fields() EndIf Case $saveopen_add If GUICtrlRead($address1_add) == "" Then MsgBox(0, "Insuficient Information", "Please provide some information" & @CRLF & 'in "Address1:" line') Else ;~ _clear_search_results() ;~ _add_address() ;~ _update_search_fields() EndIf ;Case $listview_add_entry ;single click, and includes click on header ;MsgBox(0,"","You double clicked") EndSwitch Case $Gui_Address Switch $msg[0] Case $GUI_EVENT_CLOSE If IsHWnd($Gui_Address) Then GUIDelete($Gui_Address) Case $edit_button ;_edit_mode() EndSwitch EndSwitch WEnd GUIDelete() EndFunc ;==>_create_main_menu ;-------------DOUBLE CLICK Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $listview_add_entry If Not IsHWnd($listview_add_entry) Then $hWndListView = GUICtrlGetHandle($listview_add_entry) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_ITEMACTIVATE;dblclick on item (NM_DBLCLK includes blank space in listview) ;Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) Local $iIndex = DllStructGetData($tInfo, "Index") ;Local $aInfo[5] = [$hWndFrom, $iIDFrom, $iCode, DllStructGetData($tInfo, "Index"), _ ;DllStructGetData($tInfo, "SubItem")] IF $iIndex <> -1 Then ;check index: -1 indicates click was not on an item GUICtrlSendToDummy($cLVItem, $iIndex) ;ToolTip("You Double Clicked on" & @CRLF & "3---Column: " & $aInfo[3] & @CRLF & "4---Row: " & $aInfo[4]) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;------------------------CHILD GUI-------------- Func _address_gui($rownum, ByRef $entryarray) ;delete previous gui if another listview item dblclicked If IsHWnd($Gui_Address) Then GUIDelete($Gui_Address) $Gui_Address = Guicreate($entryarray[$rownum][1]&" - "&$entryarray[$rownum][6], 700, 500,-1,-1,-1,-1,$Gui) $address1_display = GUICtrlCreateInput(" "&$entryarray[$rownum][1], 100, 20, 300,-1, 0X0800) GUICtrlCreateLabel("Address 1:", 20, 24) $address2_display = GUICtrlCreateInput(" "&$entryarray[$rownum][2], 100, 45, 300,-1, 0X0800) GUICtrlCreateLabel("Address 2:", 20, 49) $city_display = GUICtrlCreateInput(" "&$entryarray[$rownum][3], 100, 70, 150,-1, 0X0800) GUICtrlCreateLabel("City:", 20, 75) $state_display = GUICtrlCreateInput(" "&$entryarray[$rownum][4], 300, 70, 25, -1, 0X0800) GUICtrlCreateLabel("State:", 265, 75) $zip_code_display = GUICtrlCreateInput(" "&$entryarray[$rownum][5], 100, 95, 100,-1, 0X0800) GUICtrlCreateLabel("Zip Code:", 20, 99) $filenumber_display = GUICtrlCreateInput(" "&$entryarray[$rownum][6], 100, 120, 100,-1, 0X0800) GUICtrlCreateLabel("File Number:", 20, 124) $negotiator_display = GUICtrlCreateInput(" "&$entryarray[$rownum][7], 300, 120, 100,-1, 0X0800) GUICtrlCreateLabel("Negotiator:", 245, 124) $letter_type_display = Guictrlcreateinput(" "&$entryarray[$rownum][8], 100, 145, 200,-1, 0X0800) GuiCtrlcreatelabel("Letter Type:", 20, 149) $status_display = Guictrlcreateinput("", 100, 170, 300,-1, 0X0800) GUICtrlCreateLabel("Status:", 20, 174) $edit_button = GUICtrlCreateButton ("Edit Address", 500, 95) GUISetState(@SW_SHOW, $Gui_Address) ;@SW_SHOW, $Gui_Address EndFunc I see fascists...
RegularGuy Posted August 6, 2011 Author Posted August 6, 2011 First off, thank you so much!!! Sorry about not posting a working piece, I’ve been in a bit of a rush. I’m pretty sure I understand the concept though. Create a dummy Control, return information to it when a double click has been sent so it can be read by GUIGetMsg()… then run the commands from there. That was exactly what I needed, and I partially recognized I needed something along those lines I just didn’t know how to go about it. Again sorry about not posting a fully functioning script, but I really really appreciate your help!!!
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