Jump to content

problem with listbox, double click, then set text in edit box


retaly
 Share

Recommended Posts

Hy dear autoit users,

i've got one small problem what i cant fixing.

i've made one gui, with one edit, and one list box,

how does it work?

-when i click 1x to one text in listbox, its appear in edit, but if i click to one more text in list, its remove the first text in edit.

and i'd like to do the next:

-its appear in edit when i click 2x, and dont rewrite each other,i want under each other.

sorry for my bad english, i guess some1 can help me.

regards.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <file.au3>
#include <GuiEdit.au3>
#include <Constants.au3>
#include <GUIListBox.au3>
;local $msg
Local $msg, $mylist, $Edit1


#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
;GUISetState(@SW_SHOW)
$Edit1 = GUICtrlCreateEdit("", 30, 72, 445, 265)
GUISetState()
GUICtrlSetColor(-1, 0x00C2FF)
;GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetData(-1, "")
GUICtrlSetState(-1, $GUI_DISABLE)
$mylist = GUICtrlCreateList("", 480, 72, 121, 265)
GUICtrlSetLimit(-1, 200)
GUICtrlSetData(-1, "Test1|Test2|Test3")
$button = GUICtrlCreateButton("Exit", 280, 368, 75, 25)
GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###



While 1
$msg = GUIGetMsg()



If $msg = $mylist Then
GUICtrlSetData($Edit1, GUICtrlRead($mylist))
EndIf

If $msg = $GUI_EVENT_CLOSE Then
ExitLoop
Endif


If $msg = $button Then ; If button is pushed, exit without saving to text file
ExitLoop
EndIf




WEnd

GUIDelete()
Link to comment
Share on other sites

  • Moderators

retaly,

Does this do what you want: :huh:

#include <GUIConstantsEx.au3>

$sData = ""

$Form1 = GUICreate("Form1", 615, 438, 192, 124)

$Edit1 = GUICtrlCreateEdit("", 30, 72, 445, 265, $ES_READONLY)

$mylist = GUICtrlCreateList("", 480, 72, 121, 265)
GUICtrlSetData(-1, "Test1|Test2|Test3")

$button = GUICtrlCreateButton("Exit", 280, 368, 75, 25)

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $mylist
            $sData &= GUICtrlRead($mylist) & @CRLF
            GUICtrlSetData($Edit1, $sData)
        Case $GUI_EVENT_CLOSE, $button
            Exit
    EndSwitch
WEnd

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

 

Link to comment
Share on other sites

  • Moderators

retaly,

paste texts in edit when i clicked double to text, and do nothing for one click

Some people are really picky! :D

This should do it: ;)

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

Global $sData = ""

$Form1 = GUICreate("Form1", 615, 438, 192, 124)

$Edit1 = GUICtrlCreateEdit("", 30, 72, 445, 265, $ES_READONLY)

$mylist = GUICtrlCreateList("", 480, 72, 121, 265)
GUICtrlSetData(-1, "Test1|Test2|Test3")

$button = GUICtrlCreateButton("Exit", 280, 368, 75, 25)

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $button
            Exit
    EndSwitch

WEnd

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

    #forceref $hWnd, $iMsg, $lParam

    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word

    Switch $iCode
        Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
            Switch $iIDFrom
                Case $mylist
                    $sData &= GUICtrlRead($mylist) & @CRLF
                    GUICtrlSetData($Edit1, $sData)
            EndSwitch
    EndSwitch

EndFunc

And does it? :)

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

  • Moderators

retaly,

My apologies, I deleted too many unnecessary includes. :>

You need these ones:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ListBoxConstants.au3>

Sorry about that. :)

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

  • 3 weeks later...
  • Moderators

retaly,

I think this should solve those 2 problems - look for the <<<<<<<< lines as usual. :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <ListBoxConstants.au3>

$Form1 = GUICreate("Form1", 615, 438, 192, 124)

$Edit1 = GUICtrlCreateEdit("", 30, 72, 445, 265)

$mylist = GUICtrlCreateList("", 480, 72, 121, 265)
GUICtrlSetData(-1, 'Test1 ""|Test2|Test3') ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

$button = GUICtrlCreateButton("Exit", 280, 368, 75, 25)

GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $button
            Exit
    EndSwitch

WEnd

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

    #forceref $hWnd, $iMsg, $lParam

    $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word
    $iCode = BitShift($wParam, 16) ; Hi Word

    Switch $iCode
        Case $LBN_DBLCLK
            Switch $iIDFrom
                Case $mylist
                    ; Read current content
                    $sData = GUICtrlRead($Edit1) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
                    ; What are we adding
                    $sAdd = GUICtrlRead($mylist)
                    ; As long as we clicked on a list item
                    If $sAdd Then
                        ; Add the clicke4ed item
                        $sData &= GUICtrlRead($mylist) & @CRLF
                        ; Reset the edit content
                        GUICtrlSetData($Edit1, $sData)
                    EndIf
            EndSwitch
    EndSwitch

EndFunc

Is that how you want it? :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

 

Link to comment
Share on other sites

  • Moderators

retaly,

Glad I could help. :)

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

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