Jump to content

Recommended Posts

Posted

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>

Global $GUI = GUICreate("Kulinarne przepisy", 293, 294, 302, 218)
Global $Przepisy = GUICtrlCreateList("xd", 0, 0, 153, 292)
GUICtrlSetData($Przepisy, "Skasuj Mnie|")
$Skasuj = GUICtrlCreateButton("Skasuj", 160, 146, 129, 49)
$Dodaj = GUICtrlCreateButton("Dodaj", 160, 90, 129, 49)
GUISetState(@SW_SHOW)

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

        Case $Dodaj
            Dodaj()

        Case $Skasuj
        If Not GUICtrlRead($Przepisy) = "" Then

            $DoSkasownia = _GUICtrlListBox_FindInText($Przepisy, GUICtrlRead($Przepisy))
            _GUICtrlListBox_DeleteString($Przepisy, $DoSkasownia)
        EndIf

    EndSwitch
WEnd







































Func Dodaj()
Local $GuiDodaj = GUICreate("Dodawanie przepisu", 267, 357, 192, 124)
GUICtrlCreateLabel("Podaj nazwę przepisu:", 64, 8, 139, 22)
GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")

$Nazwa = GUICtrlCreateInput("", 0, 32, 265, 21)
GUICtrlCreateLabel("Tutaj daj przepis:", 72, 64, 113, 22)
GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")
$Przepis = GUICtrlCreateEdit("", 0, 88, 265, 225)
GUICtrlSetData(-1, "Przepis")
$Koniec = GUICtrlCreateButton("Dodaj!", 49, 320, 169, 33)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete($GuiDodaj)
            Return

        Case $Koniec
            GUICtrlSetData($Przepisy, GUICtrlRead($Nazwa) & "|")
            GUIDelete($GuiDodaj)
            Return

    EndSwitch
WEnd

EndFunc

How to do that when I click two times for a given position in the list, it will start the feature?

  • Moderators
Posted

Burnek662,

You can detect a doubleclick on a list item like this: ;)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>

#include <Constants.au3>

Global $GUI = GUICreate("Kulinarne przepisy", 293, 294, 302, 218)
Global $Przepisy = GUICtrlCreateList("xd", 0, 0, 153, 292)
GUICtrlSetData($Przepisy, "Skasuj Mnie|")
$Skasuj = GUICtrlCreateButton("Skasuj", 160, 146, 129, 49)
$Dodaj = GUICtrlCreateButton("Dodaj", 160, 90, 129, 49)

$cDblClk = GUICtrlCreateDummy() ; Create dummy control <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") ; Register handler to detect double click <<<<<<<<<<<<<<<<<

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

        Case $Dodaj
            Dodaj()

        Case $Skasuj
            If Not GUICtrlRead($Przepisy) = "" Then

                $DoSkasownia = _GUICtrlListBox_FindInText($Przepisy, GUICtrlRead($Przepisy))
                _GUICtrlListBox_DeleteString($Przepisy, $DoSkasownia)
            EndIf

        Case $cDblClk                               ; Dummy control fired <<<<<<<<<<<<<<<<<<<<<<
            $sText = GUICtrlRead($cDblClk)          ; Get text <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            MsgBox($MB_OK, "DoubleClicked", $sText) ; Display it <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    EndSwitch
WEnd

Func Dodaj()
    Local $GuiDodaj = GUICreate("Dodawanie przepisu", 267, 357, 192, 124)
    GUICtrlCreateLabel("Podaj nazwe przepisu:", 64, 8, 139, 22)
    GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")

    $Nazwa = GUICtrlCreateInput("", 0, 32, 265, 21)
    GUICtrlCreateLabel("Tutaj daj przepis:", 72, 64, 113, 22)
    GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")
    $Przepis = GUICtrlCreateEdit("", 0, 88, 265, 225)
    GUICtrlSetData(-1, "Przepis")
    $Koniec = GUICtrlCreateButton("Dodaj!", 49, 320, 169, 33)
    GUISetState(@SW_SHOW)

    While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                GUIDelete($GuiDodaj)
                Return

            Case $Koniec
                GUICtrlSetData($Przepisy, GUICtrlRead($Nazwa) & "|")
                GUIDelete($GuiDodaj)
                Return

        EndSwitch
    WEnd

EndFunc   ;==>Dodaj

Func _WM_COMMAND($hWnd, $msg, $wParam, $lParam)

    Local $nCode = BitShift($wParam, 16)        ; HiWord
    Local $nIDFrom = BitAND($wParam, 0xFFFF)    ; LoWord

    Switch $nIDFrom
        Case $Przepisy
            Switch $nCode
                Case $LBN_DBLCLK
                    $sListItem = GUICtrlRead($Przepisy) ; Read selected item <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    GUICtrlSendToDummy($cDblClk, $sListItem) ; Send the text to the dummy control and fire it <<<<<<<<<<<<<<<<<<<
            EndSwitch
    EndSwitch

    Return $GUI_RUNDEFMSG

EndFunc   ;==>_WM_COMMAND

All clear? :)

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

 

Posted (edited)

If you had searched in the forum with the keywords "list double click" you would have found a few topics with the solution as Melba23's just gave you.

 

Here is your cleaned code :

#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
 
#region GUI
Local $hGUI = GUICreate("Kulinarne przepisy", 293, 294, 302, 218)
 
Global $iListPrzepisy = GUICtrlCreateList("xd", 0, 0, 153, 292)
GUICtrlSetData($iListPrzepisy, "Skasuj Mnie|")
 
Local $iBtnSkasuj = GUICtrlCreateButton("Skasuj", 160, 146, 129, 49)
Local $iBtnDodaj = GUICtrlCreateButton("Dodaj", 160, 90, 129, 49)
 
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUISetState(@SW_SHOW, $hGUI)
#endregion
 
Local $iDoSkasownia = 0
 
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
        Case $iBtnDodaj
            Dodaj()
        Case $iBtnSkasuj
            If GUICtrlRead($iListPrzepisy) <> "" Then
                $iDoSkasownia = _GUICtrlListBox_FindInText($iListPrzepisy, GUICtrlRead($iListPrzepisy))
                _GUICtrlListBox_DeleteString($iListPrzepisy, $iDoSkasownia)
            EndIf
    EndSwitch
WEnd
 
GUIDelete($hGUI)
 
Func Dodaj()
    Local $iInputNazwa = 0, $iEditPrzepis = 0, $iBtnDodaj2 = 0
 
    Local $hGUIDodaj = GUICreate("Dodawanie przepisu", 267, 357, 192, 124)
    GUICtrlCreateLabel("Podaj nazwe przepisu:", 64, 8, 139, 22)
    GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")
 
    $iInputNazwa = GUICtrlCreateInput("", 0, 32, 265, 21)
 
    GUICtrlCreateLabel("Tutaj daj przepis:", 72, 64, 113, 22)
    GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")
 
    $iEditPrzepis = GUICtrlCreateEdit("", 0, 88, 265, 225)
    GUICtrlSetData($iEditPrzepis, "Przepis")
 
    $iBtnDodaj2 = GUICtrlCreateButton("Dodaj!", 49, 320, 169, 33)
 
    GUISetState(@SW_SHOW, $hGUIDodaj)
 
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                GUIDelete($hGUIDodaj)
                Return
            Case $iBtnDodaj2
                GUICtrlSetData($iListPrzepisy, GUICtrlRead($iInputNazwa) & "|")
                GUIDelete($hGUIDodaj)
                Return
        EndSwitch
    WEnd
EndFunc   ;==>Dodaj
 
Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
    Local $iIDFrom = 0, $iCode = 0
 
    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
 
    Switch $iIDFrom
        Case $iListPrzepisy
            Switch $iCode
                Case $LBN_DBLCLK
                    ConsoleWrite("Item double clicked: " & GUICtrlRead($iListPrzepisy) & @CrLf)
            EndSwitch
    EndSwitch
 
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Br, FireFox. Edited by FireFox
Posted (edited)

I have problem, first double click - working

If i double click secound time - program crash.

http://scr.hu/12lk/e9ofb
Edited by Bumek662
  • Moderators
Posted

Bumek662,

The code I posted does not crash after multiple doubleclicks. What code are you using? :huh:

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

 

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...