Jump to content

Recommended Posts

2 minutes ago, Biatu said:

lol, I don't quite follow :huh2:

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:

 

Link to post
Share on other sites

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 post
Share on other sites

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 by Biatu

What is what? What is what.

Link to post
Share on other sites
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:
 

Func 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:

 

Link to post
Share on other sites

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 by Biatu

What is what? What is what.

Link to post
Share on other sites
2 minutes ago, Biatu said:

Well, than the only cause is $button_MostraInfo being fired. BTW its kinda hard to debug without full script :P

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:

 

Link to post
Share on other sites

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 by zone97

 

Spoiler

WinSizer 2.1 (01/04/2017) - Download - [ Windows Layout Manager ]
Folder+Program (12/23/2016) - Download - [ USB Shortcut Creator ]

 

Link to post
Share on other sites
  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites
On 5/1/2017 at 5:26 PM, Melba23 said:

FrancescoDiMuro,

It does now:

#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 :D 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites
  • Moderators

FrancescoDiMuro,

What have you tried that has not worked?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to post
Share on other sites

I've tried the code for 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 :D 
EDIT: and I still can't manage the button inside the popup... WHY?! 
 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...