Sign in to follow this  
Followers 0
Bumek662

GuiCtrlCreateList - Help

7 posts in this topic

#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?

Share this post


Link to post
Share on other sites



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

2 people like this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  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
1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#4 ·  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

Share this post


Link to post
Share on other sites

Bumek662,

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

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

@Melba23

It crashes with the stable version 3.3.8.1 but not with the beta one.

He is using your code.

Edited by FireFox
1 person likes this

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Yeah, FireFox code all work, thanks.

Share this post


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
Sign in to follow this  
Followers 0