Biatu Posted January 9, 2017 Share Posted January 9, 2017 (edited) lol, I don't quite follow Edited January 9, 2017 by Biatu What is what? What is what. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 9, 2017 Author Share Posted January 9, 2017 2 minutes ago, Biatu said: lol, I don't quite follow Case $form_PopupRecord Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($form_PopupRecord) Case $button_MostraInfo MsgBox($MB_SYSTEMMODAL, "", "Ciao!") EndSwitch In this case, I manage the popup. If I run it, instantly, a MsgBox is printed infinitely... How can I avoid that? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Biatu Posted January 9, 2017 Share Posted January 9, 2017 that's because you have ur nesting wrong... While 1 $aMsg = GUIGetMsg(1) Switch $aMsg[1] Case $form_GestioneMagazzino Switch $aMsg[0] Case $GUI_EVENT_CLOSE Exit Case $button_ScegliDatabaseMagazzino $sFileDatabaseMagazzino = ScegliFile() GUICtrlSetData($input_DatabaseMagazzino, $sFileDatabaseMagazzino) Case $button_VisualizzaTutteLeGiacenze CreaListViewItems() Case $button_RicercaProdotto RicercaProdotto() EndSwitch Case $form_PopupRecord Switch $aMsg[0] Case $GUI_EVENT_CLOSE GUIDelete($form_PopupRecord) Case $button_MostraInfo MsgBox($MB_SYSTEMMODAL, "", "Ciao!") EndSwitch EndSwitch If $iLVFlag <> -1 Then ; Run the associated function CreaPopupRecord(); <--- is executed on every loop. ; Reset the flag $iLVFlag = -1 EndIf WEnd What is what? What is what. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 9, 2017 Author Share Posted January 9, 2017 Oh... And, how can I fix that? :/ Thanks Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Biatu Posted January 9, 2017 Share Posted January 9, 2017 post ur full script? What is what? What is what. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 9, 2017 Author Share Posted January 9, 2017 3 minutes ago, Biatu said: post ur full script? Tell me what do you need, I'll provide you of the code you need Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Biatu Posted January 9, 2017 Share Posted January 9, 2017 (edited) Everything associated with: mainly everything that sets/modifies $iVLFlag, and the CreaPopupRecord() func If $iLVFlag <> -1 Then ; Run the associated function CreaPopupRecord(); <--- is executed on every loop. ; Reset the flag $iLVFlag = -1 Edited January 9, 2017 by Biatu What is what? What is what. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 9, 2017 Author Share Posted January 9, 2017 11 minutes ago, Biatu said: Everything associated with: mainly everything that sets/modifies $iVLFlag, and the CreaPopupRecord() func If $iLVFlag <> -1 Then ; Run the associated function CreaPopupRecord(); <--- is executed on every loop. ; Reset the flag $iLVFlag = -1 The popup: expandcollapse popupFunc CreaPopupRecord() #Region ### START Koda GUI section ### Form=C:\Users\Portatile-60\Documents\Documenti Lavoro\AutoIt\Gestione Magazzino\Popup_Record_Gestione_Magazzino_SYS.kxf $form_PopupRecord = GUICreate("Indice:", 237, 330, 192, 124) $label_Codice = GUICtrlCreateLabel("Codice:", 8, 8, 52, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $input_Codice = GUICtrlCreateInput("", 72, 8, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $label_Marca = GUICtrlCreateLabel("Marca:", 8, 32, 47, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $input_Marca = GUICtrlCreateInput("", 72, 32, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $label_Quantita = GUICtrlCreateLabel("Quantità:", 8, 56, 62, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $input_Quantita = GUICtrlCreateInput("", 72, 56, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $label_Scaffale = GUICtrlCreateLabel("Scaffale:", 8, 80, 60, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $input_Scaffale = GUICtrlCreateInput("", 72, 80, 161, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $label_Descrizione = GUICtrlCreateLabel("Descrizione:", 8, 104, 82, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $edit_Descrizione = GUICtrlCreateEdit("", 8, 128, 225, 65, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetData(-1, "") $label_Costo = GUICtrlCreateLabel("Costo:", 128, 56, 43, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $input_Costo = GUICtrlCreateInput("", 176, 56, 57, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_READONLY)) $label_Note = GUICtrlCreateLabel("Note:", 8, 200, 82, 20) GUICtrlSetFont(-1, 10, 800, 0, "Arial") $edit_Note = GUICtrlCreateEdit("", 8, 224, 225, 65, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY)) GUICtrlSetData(-1, "") $button_MostraInfo = GUICtrlCreateButton("Mostra Info", 58, 296, 121, 25) GUICtrlSetFont(-1, 10, 800, 0, "Arial") Local $aItem = _GUICtrlListView_GetItemTextArray($listview_Lista, $iLVFlag) GUICtrlSetData($form_PopupRecord, $iLVFlag) GUICtrlSetData($input_Codice, $aItem[1]) ; Codice GUICtrlSetData($input_Marca, $aItem[2]) ; Marca GUICtrlSetData($input_Quantita, $aItem[3]) ; Quantità GUICtrlSetData($input_Scaffale, $aItem[4]) ; Scaffale GUICtrlSetData($edit_Descrizione, $aItem[5]) ; Descrizione GUICtrlSetData($input_Costo, "€ " & $aItem[6]) ; Costo GUICtrlSetData($edit_Note, $aItem[7]) ; Note GUISetState(@SW_SHOW, $form_PopupRecord) #EndRegion ### END Koda GUI section ### EndFunc The WM_NOTIFY func that set the $iLVFlag: Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $listview_Lista If Not IsHWnd($hWndListView) Then $hWndListView = GUICtrlGetHandle($listview_Lista) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iItem = DllStructGetData($tInfo, "Item") If $iItem <> -1 Then $iLVFlag = $iItem EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Thanks Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Biatu Posted January 9, 2017 Share Posted January 9, 2017 (edited) What exactly pops up when you run the code? a MsgBox, ur popup GUI? Edit: Another thing, are you wanting ur popup when clicking once on the listview item? or on a double click? Edited January 9, 2017 by Biatu What is what? What is what. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 9, 2017 Author Share Posted January 9, 2017 2 minutes ago, Biatu said: What exactly pops up when you run the code? a MsgBox, ur popup GUI? When I run the code, a MsgBox is printed, over and over again ( While 1 )... Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Biatu Posted January 9, 2017 Share Posted January 9, 2017 MsgBox($MB_SYSTEMMODAL, "", "Ciao!") This MsgBox? Another thing, are you wanting ur popup when clicking once on the listview item? or on a double click? What is what? What is what. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 9, 2017 Author Share Posted January 9, 2017 Yes, that MsgBox And the event is on ONE CLICK, and not DOUBLE CLICK Thanks Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Biatu Posted January 9, 2017 Share Posted January 9, 2017 Well, than the only cause is $button_MostraInfo being fired. BTW its kinda hard to debug without full script What is what? What is what. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 9, 2017 Author Share Posted January 9, 2017 2 minutes ago, Biatu said: Well, than the only cause is $button_MostraInfo being fired. BTW its kinda hard to debug without full script I manage the While 1 in a function, that creates the main GUI too... Could be that the cause of the error? Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Biatu Posted January 9, 2017 Share Posted January 9, 2017 It shouldn't What is what? What is what. Link to comment Share on other sites More sharing options...
zone97 Posted January 9, 2017 Share Posted January 9, 2017 (edited) I had the same issue.. Do this.. Global $NameOfGui1 = 9999, $NameofGui2 = 9999 ;- In your code i think it would be Global $form_GestioneMagazzino = 9999, $form_PopupRecord = 9999 See if that doesn't solve your issue. It prevents the buttons from automatically being pressed. Edited January 9, 2017 by zone97 Spoiler WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ] Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 9, 2017 Moderators Share Posted January 9, 2017 FrancescoDiMuro, Just to add a little meat to the bones of the above suggestion - which is very likely to be the correct solution. When you get a case firing continuously within a GUIGetMsg Switch structure it is usually because the associated control has not been given a place holder and left as "empty". When AutoIt checks this "empty" value it reads it as 0 - which just happens to be the default value returned by GUIGetMsg when no event occurs. So the case fires on every pass. The solution is to use a "place holder" value in the variable used to store the ControlID of controls which are only created after the GUIGetMsg loop starts - that way you will not get the Case firing unless the actual ControlID is returned. And do not forget to reset this "place holder" value if the control is then deleted or you could get problems if further controls are created and reuse the same ControlID. I hope that makes the whole thing clearer - ask if not. M23 zone97 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 Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted January 10, 2017 Author Share Posted January 10, 2017 On 5/1/2017 at 5:26 PM, Melba23 said: FrancescoDiMuro, It does now: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <StructureConstants.au3> Global $iLVFlag = -1 $hGUI = GUICreate("Test", 500, 500) $cLV = GUICtrlCreateListView("Items to click", 10, 10, 400, 300) $hLV = GUICtrlGetHandle($cLV) For $i = 0 To 9 GUICtrlCreateListViewItem("Item " & $i, $cLV) Next GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; Look for flag If $iLVFlag <> -1 Then ; Run the associated function _LVClicked() ; Reset the flag $iLVFlag = -1 EndIf WEnd Func _LVClicked() MsgBox($MB_SYSTEMMODAL, "Hi", "You clicked item " & $iLVFlag) EndFunc ;==>_LVClicked Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hLV Switch $iCode Case $NM_CLICK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iItem = DllStructGetData($tInfo, "Item") If $iItem <> -1 Then ; Set the flag $iLVFlag = $iItem EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY M23 Hey Melba! How are you? Hope everything fine If I would like to extend this to another listview in another tab, how can I do it? Thanks Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 10, 2017 Moderators Share Posted January 10, 2017 FrancescoDiMuro, What have you tried that has not worked? 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...
FrancescoDiMuro Posted January 10, 2017 Author Share Posted January 10, 2017 (edited) I've tried the code for A listview, and it works perfectly... But, what changes should I do in the code you post, without creating another function that captures the event $NM_CLICK? Better? Thanks EDIT: and I still can't manage the button inside the popup... WHY?! Edited January 10, 2017 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette 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