Jump to content

Create a Popup Window


Recommended Posts

Hi guys! How are you? Hope fine :D I'm looking for displaying a popup GUI when I press an item in my listview...
This is needed for capturing the click on the item:
 

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
                        CreaPopupRecord() ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Here I call the function that create the popup
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc

And the function to create the popup is:
 

#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, "edit_Descrizione")
    $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("Descrizione:", 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, "edit_Descrizione")
    $button_MostraInfo = GUICtrlCreateButton("Mostra Info", 58, 296, 121, 25)
    GUICtrlSetFont(-1, 10, 800, 0, "Arial")
    GUISetState(@SW_SHOW, $form_PopupRecord)
    #EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
EndFunc

But, how to manage the events from the two different GUIs? 
The popup is mostly "read-only", it has only one button that ( I'll implement ), that shows up a MsgBox...
How can I proceed? Thanks :D 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Moderators

FrancescoDiMuro,

Quote

How can I proceed?

Not as you are. You must NOT have any form of blocking function inside a Windows message handler - as explained clearly in the Help file for GUIRegisterMsg:

Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

You need to have a Global flag which you set inside the handler when required and then check within your idle loop. When the flag is set, you run your function outside the handler.

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

20 minutes ago, Melba23 said:

FrancescoDiMuro,

Not as you are. You must NOT have any form of blocking function inside a Windows message handler - as explained clearly in the Help file for GUIRegisterMsg:

Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

You need to have a Global flag which you set inside the handler when required and then check within your idle loop. When the flag is set, you run your function outside the handler.

M23

I do not have enough concepts to undestrand what you wrote, Melba. 
Blocking function = MsgBox, because when it appears, he needs an "Ok" or a timeout to "exit"... Is that correct?
Windows Message Handler = ?
Global flag... So, something like that ? :
 

; Main
Global $bFlag
If($bFlag = True) Then MsgBox(...)
; Func
Func myFunc()
    ; Some conditions...
    $bFlag = True
EndFunc

But, I don't understand If you answered me or not... Sorry :) 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

1 hour ago, Melba23 said:

FrancescoDiMuro,

Not as you are. You must NOT have any form of blocking function inside a Windows message handler - as explained clearly in the Help file for GUIRegisterMsg:

Warning: blocking of running user functions which executes window messages with commands such as "MsgBox()" can lead to unexpected behavior, the return to the system should be as fast as possible !!!

You need to have a Global flag which you set inside the handler when required and then check within your idle loop. When the flag is set, you run your function outside the handler.

M23

I tried something like this, but Idk if it's correct... I tested and the Popup respondsw well to commands, but, now, I'd develop func that the $button_MostraInfoCan should run... Can someone tell me something about my code, please? :) 

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
                        CreaListView()
                EndSwitch
            Case $form_PopupRecord
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($form_PopupRecord)
                    Case $button_MostraInfo
                        ;
                EndSwitch
        EndSwitch
WEnd

PS: Seems it's not working properly... Some suggestion? Thanks :) 

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Moderators

FrancescoDiMuro,

Does this make it clearer?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <StructureConstants.au3>

Global $iLVFlag = 0

$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 Then
        ; Run the associated function
        _LVClicked()
        ; Reset the flag
        $iLVFlag = 0
    EndIf

WEnd

Func _LVClicked()
    MsgBox($MB_SYSTEMMODAL, "Hi", "You clicked item " & $iLVFlag)
EndFunc

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

M23

P.S. And please stop quoting me in every post - use the "Reply to this topic" button at the top of the thread or the "Reply to this topic" editor at the bottom rather than the "Quote" button. I know what I wrote and it just pads the thread unnecessarily.

 

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

  • Moderators

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

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

2 hours ago, FrancescoDiMuro said:

I tried something like this, but Idk if it's correct... I tested and the Popup respondsw well to commands, but, now, I'd develop func that the $button_MostraInfoCan should run... Can someone tell me something about my code, please? :) 

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
                        CreaListView()
                EndSwitch
            Case $form_PopupRecord
                Switch $aMsg[0]
                    Case $GUI_EVENT_CLOSE
                        GUIDelete($form_PopupRecord)
                    Case $button_MostraInfo
                        ;
                EndSwitch
        EndSwitch
WEnd

 

Thanks Melba :) Now, I'm looking for an "exclusive string search", something like "Search ABCD in ABCDED, and find only the string that contains "ABCD", not "ABCDED"... I tried with StringInStr, but I didn't managed to do what I want... Any suggestion? Thanks <3

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Moderators

FrancescoDiMuro,

That sounds like you need a RegEx:

#include <MsgBoxConstants.au3>

Global $aList[] = ["ABCD", "ABCDED", "ABABCD", "ABABCDED"]

$sSearch = "ABCD"

For $i = 0 To UBound($aList) - 1

    If StringRegExp($aList[$i], "^" & $sSearch & "$") Then
        MsgBox($MB_SYSTEMMODAL, "Match", $aList[$i] & " matches " & $sSearch)
    Else
        MsgBox($MB_SYSTEMMODAL, "No match", $aList[$i] & " does not match " & $sSearch)
    EndIf
Next

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

Good morning Melba! :) Thanks for the reply :)
I tried your code, but it's not working for me... Maybe I explained bad my expected result, I'll try to explain it again :)
I have an Excel database with 2 sheets. In the first column ( A ), I have all the codes which identify the product... In example:
A           B                C       D
1500     Product1    € 12  This product is...
1512     Product2    € 10  This product is(2)...
1615     Product3    € 19  This product is(3)...

Always for example, but for the script I'm doing either, I'd like to search ONLY product(s) that/which have content column A that starts from "15", so, it finds only first two rows, because they contain 15 from the start of their texts... 
So, now I've explained my expected result... Here is my code... Tell me where ( if I am ), wrong, please :) Thanks Melba! 

 

Func RicercaProdotto() 
    Local $sChiaveDiRicerca = InputBox("Ricerca Prodotto", "Inserisci il codice" & @CRLF & "del prodotto che vuoi cercare:")
        If(@error) Then
            Switch(@error)
                Case 1
                    MsgBox($MB_ICONINFORMATION, "Operazione annullata", "Operazione annullata dall'utente.")
                Case 2
                    MsgBox($MB_ICONINFORMATION, "Attenzione!", "Tempo di timeout raggiunto!")
                Case 3
                    MsgBox($MB_ICONERROR, "Errore!", "Errore durante l'apertura della InputBox.")
                Case 4
                    MsgBox($MB_ICONERROR, "Errore!", "La InputBox non può essere mostrata su nessun monitor.")
                Case 5
                    MsgBox($MB_ICONERROR, "Errore!", "Parametro 'Larghezza' senza parametro 'Altezza'/" & @CRLF & "Parametro 'Sinistra' senza parametro 'Superiore'")
            EndSwitch
        Else
            GUICtrlSetData($input_ChiaveDiRicerca, $sChiaveDiRicerca)
            Local $i
            Local $sRigaListView
            Local $sItemListView
            Local $aRisultatoRicerca = LeggiTutteLeGiacenze()
            For $i = 0 To UBound($aRisultatoRicerca) - 1
                $iInStringa = StringRegExp($aRisultatoRicerca[$i][0],"^" & $sChiaveDiRicerca & "$") ;StringInStr($aRisultatoRicerca[$i][0], $sChiaveDiRicerca, 2)
                If($iInStringa And Not @error) Then
                    $sRigaListView = $aRisultatoRicerca[$i][0] & "|" & $aRisultatoRicerca[$i][1] & "|" & $aRisultatoRicerca[$i][2] & "|" & $aRisultatoRicerca[$i][3] & "|" & _
                    $aRisultatoRicerca[$i][4] & "|" & $aRisultatoRicerca[$i][5] & "|" & $aRisultatoRicerca[$i][6] & "|" & $aRisultatoRicerca[$i][7]
                    $sItemListView = GUICtrlCreateListViewItem($sRigaListView, $listview_ListaRicerca)
                    ;MsgBox($MB_ICONINFORMATION, "Found...", "Found something!")
                EndIf
            Next
            _GUICtrlTab_ActivateTab($tab_Fogli, 1) ; Attiva la seconda Tab ( RicercaProdotto )
        EndIf
EndFunc ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> RicercaProdotto()

Func LeggiTutteLeGiacenze()
    Local $oExcel = _Excel_Open(False)
    If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante la creazione dell'oggetto Excel." & @CRLF & "Errore: " & @error & ", Informazioni: " & @extended)
    Local $oWorkbook = _Excel_BookOpen($oExcel, $sFileDatabaseMagazzino, False)
    If @error Then
        MsgBox($MB_SYSTEMMODAL, "Errore!", "Errore durante l'apertura della Cartella di Lavoro '" & @ScriptDir & $sFileDatabaseMagazzino & "'." & @CRLF & "Errore: " & @error & ", Informazioni: " & @extended)
        _Excel_Close($oExcel)
        Exit
    EndIf
    $oWorkbook.Sheets("Magazzino Rockwell").Activate
    Local $aRisultatoRockwell = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:H"), 1)
    For $i = UBound($aRisultatoRockwell) - 1 To 4 Step -1
        If($aRisultatoRockwell[$i][4] = "") Then _ArrayDelete($aRisultatoRockwell, $i)
    Next
    $oWorkbook.Sheets("Magazzino Siemens").Activate
    Local $aRisultatoSiemens = _Excel_RangeRead($oWorkbook, Default, $oWorkbook.ActiveSheet.Usedrange.Columns("A:H"), 1)
    For $i = UBound($aRisultatoSiemens) - 1 To 4 Step -1
        If($aRisultatoSiemens[$i][4] = "") Then _ArrayDelete($aRisultatoSiemens, $i)
    Next
    _Excel_Close($oExcel)
    _ArrayConcatenate($aRisultatoSiemens, $aRisultatoRockwell, 4)
    Local $aRisultato = $aRisultatoSiemens
    Return $aRisultato
EndFunc ; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> LeggiTutteLeGiacenze()
        ; This function retrieves all the data from Excel sheets ( only 2 ), and removes all blank rows... The result is returned by the func :)

 

Edited by FrancescoDiMuro
Forget to post the code ^^

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Moderators

FrancescoDiMuro,

I would read the data into an array and then run through the first column using something like:

If StringLeft($aArray[$i][0], 2) = "15" Then

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

I'm having some issues on this Research function... 
If I would like to do a research like this? :
* is intended as sometext...
*ABCD, find all strings which have * before the ABCD, AND THEN ABCD at the end of the string;
[ Maybe I can do it with StringRight? ]
ABCD*, find all strings which have * after the ABCD, AND THEN sometext;
[ Maybe I can do it with StringLeft? ]
ABCD, find all string which have ABCD, as it's described, in themselves;
[ Maybe I can do it with StringInStr? ]

I did something like this, but I don't know if it's gonna work in each case I've described above...
 

Switch($sChiaveDiRicerca)
                Case StringLeft($sChiaveDiRicerca, 1) = "*"
                    MsgBox($MB_SYSTEMMODAL, "", "Ricerca da destra")
                    $aRisultatoRicerca = LeggiTutteLeGiacenze()
                    $sChiaveDiRicerca = StringReplace($sChiaveDiRicerca, "*", "")
                    For $i = 0 To UBound($aRisultatoRicerca) - 1
                        $iInStringa = StringRight($aRisultatoRicerca[$i][0], StringLen($sChiaveDiRicerca))
                        If($iInStringa = $sChiaveDiRicerca) Then
                            $sRigaListView = $aRisultatoRicerca[$i][0] & "|" & $aRisultatoRicerca[$i][1] & "|" & $aRisultatoRicerca[$i][2] & "|" & $aRisultatoRicerca[$i][3] & "|" & _
                            $aRisultatoRicerca[$i][4] & "|" & $aRisultatoRicerca[$i][5] & "|" & $aRisultatoRicerca[$i][6] & "|" & $aRisultatoRicerca[$i][7]
                            $sItemListView = GUICtrlCreateListViewItem($sRigaListView, $listview_ListaRicerca)
                        EndIf
                    Next
                Case StringRight($sChiaveDiRicerca, 1) = "*"
                    MsgBox($MB_SYSTEMMODAL, "", "Ricerca da sinistra")
                    $aRisultatoRicerca = LeggiTutteLeGiacenze()
                    $sChiaveDiRicerca = StringReplace($sChiaveDiRicerca, "*", "")
                    For $i = 0 To UBound($aRisultatoRicerca) - 1
                        $iInStringa = StringLeft($aRisultatoRicerca[$i][0], StringLen($sChiaveDiRicerca));StringInStr($aRisultatoRicerca[$i][0], $sChiaveDiRicerca, 2)
                        If($iInStringa = $sChiaveDiRicerca) Then
                            $sRigaListView = $aRisultatoRicerca[$i][0] & "|" & $aRisultatoRicerca[$i][1] & "|" & $aRisultatoRicerca[$i][2] & "|" & $aRisultatoRicerca[$i][3] & "|" & _
                            $aRisultatoRicerca[$i][4] & "|" & $aRisultatoRicerca[$i][5] & "|" & $aRisultatoRicerca[$i][6] & "|" & $aRisultatoRicerca[$i][7]
                            $sItemListView = GUICtrlCreateListViewItem($sRigaListView, $listview_ListaRicerca)
                        EndIf
                    Next
                Case Else
                    MsgBox($MB_SYSTEMMODAL, "", "Ricerca StringInStr")
                    $aRisultatoRicerca = LeggiTutteLeGiacenze()
                    $sChiaveDiRicerca = StringReplace($sChiaveDiRicerca, "*", "")
                    For $i = 0 To UBound($aRisultatoRicerca) - 1
                        $iInStringa = StringInStr($aRisultatoRicerca[$i][0], $sChiaveDiRicerca);StringInStr($aRisultatoRicerca[$i][0], $sChiaveDiRicerca, 2)
                        If($iInStringa) Then
                            $sRigaListView = $aRisultatoRicerca[$i][0] & "|" & $aRisultatoRicerca[$i][1] & "|" & $aRisultatoRicerca[$i][2] & "|" & $aRisultatoRicerca[$i][3] & "|" & _
                            $aRisultatoRicerca[$i][4] & "|" & $aRisultatoRicerca[$i][5] & "|" & $aRisultatoRicerca[$i][6] & "|" & $aRisultatoRicerca[$i][7]
                            $sItemListView = GUICtrlCreateListViewItem($sRigaListView, $listview_ListaRicerca)
                        EndIf
                    Next
            EndSwitch



Thanks for your help Melba :)

EDIT: I'm managing with StringRegExp() function, setting the parameter "$" to search from the end of the string, "^" to search from the beginning of the string, and now I'm developing the last case I've described to you before :) If you wanna reply, by the way, it would be appreciated. Maybe, your answer can be useful to another user :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

  • Moderators

FrancescoDiMuro,

StringRegExp with the ^ & $ anchors would have been my suggestion.

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

20 minutes ago, Biatu said:

If I were u, use an AdlibRegister to exec the popup func from ur WM_* callback, then adlibUnregister at the head of ur popup func

I'll try asap and I'll update you guys :) Thanks :)

Edited by FrancescoDiMuro

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

Just now, FrancescoDiMuro said:

Ehm? :huh2:

In your WM_NOTIFY function, your not supposed to use blocking functions. Your script will crash. But if you use AdlibRegisterServer to call your function, then call AdlibUnRegisterServer at the top of the called function...your blocking function still gets executed, and your script does not crash.

What is what? What is what.

Link to comment
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, I was trying your code, but there's no "multiple" GUI management... How can I manage the different GUIs? I have 2 GUIs, but, If I close the popup, I close the  main GUI too... Thanks :) 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
Share on other sites

@FrancescoDiMuro, change your GuiGetMsg() to GuiGetMsg(1), and handle messages from each window, and its corresponding controls. Like this:

$aMsg=GuiGetMsg(1)
Switch $aMsg[1]
    Case $hGUI_1
        Switch $aMsg[0]
            Case $idControlsXYZ
        EndSwitch
    Case $hGUI_2
        Switch $aMsg[0]
            Case $idControlsXYZ
        EndSwitch
EndSwitch

 

What is what? What is what.

Link to comment
Share on other sites

5 minutes ago, Biatu said:

@FrancescoDiMuro, change your GuiGetMsg() to GuiGetMsg(1), and handle messages from each window, and its corresponding controls. Like this:

$aMsg=GuiGetMsg(1)
Switch $aMsg[1]
    Case $hGUI_1
        Switch $aMsg[0]
            Case $idControlsXYZ
        EndSwitch
    Case $hGUI_2
        Switch $aMsg[0]
            Case $idControlsXYZ
        EndSwitch
EndSwitch

 

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()
        ; Reset the flag
        $iLVFlag = -1
    EndIf
WEnd

@Biatu
Main form is $form_GestioneMagazzino;
The popup is form_PopupRecord;
Now, I can manage the two different GUIs, BUT, how can I manage the Infinite Print of the MsgBox under $button_MostraInfo in the popup? 
I have this popup with a button, that shows up some information... How can I manage that thing in the popup OR in a function called somewhere? Thanks :) 
 

Click here to see my signature:

Spoiler

ALWAYS GOOD TO READ:

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...