Jump to content
Sign in to follow this  
AndreyS

How to do word wrap in ListBox?

Recommended Posts

AndreyS
Hello everyone!
Maybe someone knows. Is it possible to make long items listboks transferred / broken into multiple lines?

Share this post


Link to post
Share on other sites
Artisan

Need a little clarification before I can help you.

Is it just an issue of display?  If so, look at GUICtrlListView - it automatically includes a horizontal scroll bar and resizable column headers.

Do you want Word Wrap applied to longer strings so that one long entry is more than one line?  I think GUICtrlListView can do that too.

Do you want to break a long string into multiple single-line entries?  That's easy to do with a few String...() functions.

Share this post


Link to post
Share on other sites
AndreyS

Thank you for having responded to that!

Will explain. I saw the need to fully long elements without using the horizontal scroll is. Items consist of a few sentences so that they fit only 3-4 lines. When you click on an item must be allocated all of the rows of the item.

Share this post


Link to post
Share on other sites
Artisan

Sounds like you want this:

Specifically, post #17.  It's an Outlook style ListView which should do the trick for you.  Very customizable!

Edited by Artisan
  • Like 1

Share this post


Link to post
Share on other sites
AndreyS
If such a ListView control of foliage in the settings that will be possible to set it up on a multi-line then that is what you need! :)
Thanks Artisan for the link! 
I will try!

Share this post


Link to post
Share on other sites
PhoenixXL
Is it possible to make long items listboks transferred / broken into multiple lines?

Then there would be two different items and selection of both the items at the same time won't be possible.

Rather when strings are long, a hover tip could be used to display( >if interested )

Best regards :)


My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
AZJIO

#include <WindowsConstants.au3>
$sText = 'This is a very long string . But that''s not the problem. The line will be divided by the length of no more than 35 characters.'
$hGui = GUICreate('My Program', 250, 260)
$iList = GUICtrlCreateList('', 10, 10, 230, 240, $WS_BORDER + $WS_VSCROLL)
GUICtrlSetData($iList, StringRegExpReplace($sText, '(.{35,}?)\h', '$1|'))
GUISetState()
Do
Until GUIGetMsg() = -3

Share this post


Link to post
Share on other sites
AndreyS
Thanks for the option Azjio!
In this embodiment, obtained as a result of three elements, it is necessary that there was one. And that when clicked immediately stood out all the lines.
 
 

post-54057-0-85711500-1378556819_thumb.j

Edited by AndreyS

Share this post


Link to post
Share on other sites
TheSaint

Word Wrap or more correctly Text Wrap (for unbroken text) will occur if you don't use any Horizontal Scroll parameters during ListBox creation. At least, that's how it works for me with AutoIt v3.3.0.0 .... not sure for current AutoIt. In that same version, you cannot set this after ListBox creation using GUICtrlSetStyle ... not without deleting and recreating the control.

This behavior can be seen in my WebPad program, currently available in the most recent listings of Examples section of forum.

Text Wrap is a menu item.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
PhoenixXL

This behavior can be seen in my WebPad program, currently available in the most recent listings of Examples section of forum.

Text Wrap is a menu item.

But it is an edit control and we are speaking about ListBox, can you provide an example for a listbox ?

  • Like 1

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
AndreyS

Yes, I would like to see your solution, TheSaint, or if you can link to.

 
By the way, dear developers, you can even without spaces between items that are visible on my preview.

Share this post


Link to post
Share on other sites
PhoenixXL

This is what I've got for the moment.

If you are interested in it tell me for any modifications.

Added a lot more of code and functions

Features

  • Add, Insert or Delete(one or all) Item
  • Call function when item is clicked
  • Support of scrolling with arrow buttons
  • VScroll Bar is now included
  • Enter is also taken as an event
  • Set your own cursor
  • Multiple EditLists could be used at a time.

 

EditList.au3

#include-once
#include <Array.au3>
#include <WinAPISys.au3>
#include <WinAPIRes.au3>
#include <APISysConstants.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

; = = = = = = .  . . . Private UDF Global Variables ===========================================================

Global $aItems[1] ;stores Item indexes
Global $sAppend ;stores Item delimited
Global $__hCur ;stores the handle to the cursor
Global $h_ControlHwnd ;stores the handle of the control.
Global $p_Original_WindowProc ;stores the original window procedure(WndProc) of the edit control.

Global $h_NewWndProc = DllCallbackRegister("_NewWnd_Proc_", "int", "hwnd;uint;wparam;lparam") ;hanlde to the new WndProc
Global $p_NewWndProc = DllCallbackGetPtr($h_NewWndProc) ;pointer to the new WndProc.

Global $s_OnEventFunc ;string storing the name of the func to call upon click.

Func _Edit_List_Create($iX, $iY, $iWidth, $iHeight, $hWin, $sAppendString = -1)

    $h_ControlHwnd = _GUICtrlRichEdit_Create($hWin, "", $iX, $iY, $iWidth, $iHeight, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_MULTILINE, $ES_NOHIDESEL))
    OnAutoItExitRegister("Destroy")

    $p_Original_WindowProc = _Subclass_($h_ControlHwnd, $p_NewWndProc)

    _GUICtrlRichEdit_SetText($h_ControlHwnd, "")

    If $sAppendString = -1 Then $sAppendString = @LF
    $sAppend = $sAppendString
    $aItems[0] = -StringLen($sAppend)

    Return $h_ControlHwnd ;

EndFunc   ;==>_Edit_List_Create

Func _Edit_List_Suspend()

    Local $aRet[6] = [$aItems, $sAppend, $__hCur, $h_ControlHwnd, $p_Original_WindowProc, $s_OnEventFunc]
    ReDim $aItems[1]
    $sAppend = ""
    $__hCur = 0
    $h_ControlHwnd = 0
    $p_Original_WindowProc = 0
    $s_OnEventFunc = ""
    Return $aRet

EndFunc   ;==>_Edit_List_Suspend

Func _Edit_List_Restore($aData)
    If IsArray($aData) = 0 Then Return
    $aItems = $aData[0]
    $sAppend = $aData[1]
    $__hCur = $aData[2]
    $h_ControlHwnd = $aData[3]
    $p_Original_WindowProc = $aData[4]
    $s_OnEventFunc = $aData[5]

EndFunc   ;==>_Edit_List_Restore

Func _Edit_List_GetActive()
    Return $h_ControlHwnd
EndFunc   ;==>_Edit_List_GetActive

Func _Edit_List_InsertItem($s_Text, $iIndex = -1)

    Local $sEdit_Text = _GUICtrlRichEdit_GetText($h_ControlHwnd)
    Local $iMaxLen = StringLen($sEdit_Text)

    If IsInt($iIndex) = 0 Then Return SetError(2, 0, 0) ;bad $iIndex
    $s_Text = StringRegExpReplace($s_Text, "\v+", @LF)

    If $iIndex >= UBound($aItems) Then Return SetError(3, 0, 0)

    If $iIndex >= 1 Then

        Local $iUbound = UBound($aItems)
        If $iIndex > $iUbound Then Return SetError(3, 0, 0) ;bad $iIndex

        _GUICtrlRichEdit_GotoCharPos($h_ControlHwnd, $aItems[$iIndex - 1] + StringLen($sAppend))
        _GUICtrlRichEdit_InsertText($h_ControlHwnd, $s_Text & $sAppend)

        Local $Change = StringLen($s_Text & $sAppend)

        _ArrayInsert($aItems, $iIndex - 1, $aItems[$iIndex - 1])
        ;reset the array
        For $i = $iIndex To $iUbound
            $aItems[$i] += $Change
        Next


    ElseIf $iIndex = -1 Then

        _ArrayAdd($aItems, StringLen($sEdit_Text & $s_Text))
        _GUICtrlRichEdit_AppendText($h_ControlHwnd, $s_Text & $sAppend)

    Else
        Return SetError(1, 0, 0) ;$iIndex parameter is wrong.
    EndIf

    Return 1

EndFunc   ;==>_Edit_List_InsertItem

Func _Edit_List_GetItemText($iIndex = -1) ;by default gets the selected items text
    If $iIndex = -1 Then Return _GUICtrlRichEdit_GetSelText($h_ControlHwnd)
    If $iIndex <= 0 Or IsInt($iIndex) = 0 Then Return SetError(1, 0, 0)
    If $iIndex >= UBound($aItems) Then Return SetError(3, 0, 0)
    Return _GUICtrlRichEdit_GetTextInRange($h_ControlHwnd, $aItems[$iIndex - 1] + StringLen($sAppend), $aItems[$iIndex])
EndFunc   ;==>_Edit_List_GetItemText

Func _Edit_List_GetSelItemIndex()
    Local $iLowerIndex = _GUICtrlRichEdit_GetSel($h_ControlHwnd)
    If @error Then Return SetError(1, @error, 0)
    $iLowerIndex = $iLowerIndex[0]

    For $i = 1 To UBound($aItems) - 1
        Switch $iLowerIndex
            Case $aItems[$i - 1] + StringLen($sAppend) To $aItems[$i]
                Return $i
        EndSwitch
    Next

    Return SetError(2, 0, 0)
EndFunc   ;==>_Edit_List_GetSelItemIndex

;The Following function was works using the functions of the already present library.
;Therefore it would work with both OnEvent as well as MsgLoop methods.
;PS: The OnEvent macros won't work like @GUI_CTRLID, etc.
;Use _Edit_List_SetOnClick("") to deregister an already registered function.
;The function should not have any parameter.
Func _Edit_List_SetOnEvent($s_FuncName)
    $s_OnEventFunc = $s_FuncName
EndFunc   ;==>_Edit_List_SetOnEvent


Func _Edit_List_SetCursor($hCursor)
    $__hCur = $hCursor;_WinAPI_CopyCursor()
EndFunc   ;==>_Edit_List_SetCursor

Func _Edit_List_SetSel($iIndex, $iReverse = False)
    ;key: the index of the array is the length of the item,
    ;use the index of the previous item to get the initial position of the required item
    If IsInt($iIndex) = 0 Or $iIndex < 1 Or $iIndex >= UBound($aItems) Then Return SetError(1, 0, 0)

    Local $iAnchor = $aItems[$iIndex - 1] + StringLen($sAppend)
    Local $iActive = $aItems[$iIndex]

    If $iReverse Then _ArraySwap($iActive, $iAnchor)

    Return _GUICtrlRichEdit_SetSel($h_ControlHwnd, $iAnchor, $iActive)
EndFunc   ;==>_Edit_List_SetSel

Func _Edit_List_RemoveItem($iIndex)

    If $iIndex >= UBound($aItems) Then Return SetError(3, 0, 0)

    _GUICtrlRichEdit_SetSel($h_ControlHwnd, $aItems[$iIndex - 1] + StringLen($sAppend), $aItems[$iIndex] + 1)
    _GUICtrlRichEdit_ReplaceText($h_ControlHwnd, "", False)

    Local $Change = StringLen(_Edit_List_GetItemText($iIndex) & $sAppend)

    _ArrayDelete($aItems, $iIndex)
    ;reset the array
    For $i = $iIndex To UBound($aItems) - 1
        $aItems[$i] -= $Change
    Next

    _SendMessage($h_ControlHwnd, $WM_SETFOCUS)

EndFunc   ;==>_Edit_List_RemoveItem

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




    Switch $hWnd
        Case $h_ControlHwnd
            Switch $iMsg

                Case $WM_RBUTTONDOWN, $WM_CHAR
                    Return 0

                Case $WM_SETCURSOR
                    If $__hCur <> 0 And _WinAPI_LoWord($lParam) = 1 Then Return _WinAPI_SetCursor($__hCur) ;lparam = hittest = 1 = client area

                Case $WM_KEYDOWN

                    Local Const $VK_UP_ = 0x26
                    Local Const $VK_DOWN_ = 0x28
                    Local Const $VK_ENTER_ = 0x0D

                    Switch $wParam
                        Case $VK_UP_, $VK_DOWN_

                            _Edit_List_SetSel(_Edit_List_GetSelItemIndex() + $wParam - 0x27, $wParam - 0x28)
                            _GUICtrlRichEdit_ScrollToCaret($hWnd)

                        Case $VK_ENTER_

                            If IsFunc($s_OnEventFunc) Then $s_OnEventFunc($hWnd, 1)

                    EndSwitch
                    Return 0

                Case $WM_KILLFOCUS

                    $iRet = _WinAPI_CallWindowProc($p_Original_WindowProc, $hWnd, $iMsg, $wParam, $lParam)

                    DllCall("user32.dll", "int", "ShowCaret", "hwnd", $hWnd)

                    Return $iRet

                Case $WM_SETFOCUS
                    $iRet = _WinAPI_CallWindowProc($p_Original_WindowProc, $hWnd, $iMsg, $wParam, $lParam)

                    DllCall("user32.dll", "int", "HideCaret", "hwnd", $hWnd)

                    Return $iRet

                Case $WM_LBUTTONDOWN, $WM_LBUTTONDBLCLK

                    $iX = _WinAPI_LoWord($lParam)
                    $iY = _WinAPI_HiWord($lParam)
                    $iChar = _GUICtrlRichEdit_GetCharPosFromXY($hWnd, $iX, $iY);

                    For $n = 1 To UBound($aItems) - 1
                        Switch $iChar
                            Case $aItems[$n - 1] + StringLen($sAppend) To $aItems[$n]

                                _Edit_List_SetSel($n, 1)
                                _GUICtrlRichEdit_ScrollToCaret($hWnd)

                        EndSwitch
                    Next
                    If IsFunc($s_OnEventFunc) Then $s_OnEventFunc($hWnd, 0)

                    Return 0;

            EndSwitch
        Case Else
            Switch $iMsg

                Case $WM_LBUTTONDOWN, $WM_LBUTTONDBLCLK

                    If IsFunc($s_OnEventFunc) Then $s_OnEventFunc($hWnd, 0)
                    Return 0;
            EndSwitch

    EndSwitch
    ;go with the original processing.
    Return _WinAPI_CallWindowProc($p_Original_WindowProc, $hWnd, $iMsg, $wParam, $lParam)

EndFunc   ;==>_NewWnd_Proc_

Func _Subclass_($hWnd, $pNew_WndProc)

    ;substitute the WndProc of the control.
    Return _WinAPI_SetWindowLong($hWnd, $GWL_WNDPROC, $pNew_WndProc)

EndFunc   ;==>_Subclass_

Func Destroy()

    _Subclass_($h_ControlHwnd, $p_Original_WindowProc)
    _GUICtrlRichEdit_Destroy($h_ControlHwnd)
    _WinAPI_DestroyCursor($__hCur)

EndFunc   ;==>Destroy

Func _Edit_List_Clear()
    ReDim $aItems[1]
    Local $iRet = _GUICtrlRichEdit_SetText($h_ControlHwnd, "")
    _SendMessage($h_ControlHwnd, $WM_SETFOCUS)

    Return $iRet
EndFunc   ;==>_Edit_List_Clear

Test Script.au3

;Note the script requries AutoIT v3.3.10++

#include <EditList.au3>
#include <WinAPIRes.au3>

If StringMid(@AutoItVersion, 3, 4) <> "3.10" Then Exit MsgBox(16, "Error", "The script requries AutoIT v3.3.10++" & @CRLF & "You have " & @AutoItVersion)

$hMain = GUICreate("Test", 700, 300)
Global $hRichEdit_1 = _Edit_List_Create(10, 10, 300, 280, $hMain)

_Edit_List_InsertItem("1. The usual high-level elements for functions, loops and expression-handling.")
_Edit_List_InsertItem("4. A staggering amount of string handling functions and a Perl Compatible Regular Expression Engine(PCRE)" & @CRLF)
_Edit_List_InsertItem("2. Call Win32 and Third-Party DLL APIs." & @CRLF, 2)
_Edit_List_InsertItem("3. COM support", 3)

Local $hCur = _WinAPI_LoadCursor(0, $IDC_HAND)
_Edit_List_SetCursor($hCur)
_WinAPI_DestroyCursor($hCur)

_Edit_List_SetOnEvent(OnEvent_Handler)

;Now before creating a new EditList we have to suspend the first EditList
Global $aData = _Edit_List_Suspend()


Global $hRichEdit_2 = _Edit_List_Create(390, 10, 300, 280, $hMain)

_Edit_List_InsertItem("The only things that evolve by themselves in an organization are disorder, friction and malperformance." & @CRLF)
_Edit_List_InsertItem("The mind is everything. What you think you become.  –Buddha" & @CRLF)
_Edit_List_InsertItem("There is only one way to avoid criticism: do nothing, say nothing, and be nothing. –Aristotle" & @CRLF)
_Edit_List_InsertItem("A person who never made a mistake never tried anything new. – Albert Einstein" & @CRLF)
_Edit_List_InsertItem("The battles that count aren’t the ones for gold medals. The struggles within yourself–the invisible battles inside all of us–that’s where it’s at. –Jesse Owens")

_Edit_List_SetOnEvent(OnEvent_Handler)


GUISetState()

_SendMessage($hRichEdit_2, $WM_SETFOCUS) ;required for initial hiding of the caret. The one created at last should be set the focus

Do
    Sleep(10)
Until GUIGetMsg() = -3 ;$GUI_EVENT_CLOSE = -3

Func OnEvent_Handler($hRichEdit, $iEvent)
    ;$hRichedit is the handle of the richedit from where the function is called
    ;$iEvent
    ;   1| OnEnterDown (received when it is the current editlist)
    ;   0| OnLeftClick
    Switch $iEvent
        Case 0  ;onmouse click
            If _Edit_List_GetActive() <> $hRichEdit Then
                Local $bData = _Edit_List_Suspend()
                _Edit_list_Restore($aData)
                $aData = $bData
                MouseClick('left', Default, Default, 1, 0)  ;simulate a click to set selection
            EndIf
    EndSwitch
    ConsoleWrite("Item Selected: " & _Edit_List_GetSelItemIndex() & @TAB & "  ItemText: " & _Edit_List_GetItemText() & @CRLF)

EndFunc   ;==>OnEvent_Handler


 

Let me know what you think.

Thumbs up if it helped

Regards :)

Edited by PhoenixXL
  • Like 1

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
mLipok
Very interesting piece of code.
I began to wonder about other possible uses.

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
AndreyS
So so so so much! :) I see the code that is something very similar to the one that I need! :)
 
It is true when you start I get errors:
 
D: Program Files AutoIt3 Include APIConstants.au3 (1989,41): ERROR: $ FR_DIALOGTERM previously declared as a 'Const'.
Global Const $ FR_DIALOGTERM = 0x00000040
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
D: Program Files AutoIt3 Include APIConstants.au3 (1991,41): ERROR: $ FR_ENABLEHOOK previously declared as a 'Const'.
Global Const $ FR_ENABLEHOOK = 0x00000100
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
... and so on.
 
How to fix it?
I'd like to see the results!
Edited by AndreyS

Share this post


Link to post
Share on other sites
mLipok

it works on latest beta

but not on AutoIt 3.3.8.1

  • Like 1

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button

Spoiler

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * 

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

Signature last update: 2018-03-17

Share this post


Link to post
Share on other sites
AndreyS
Ahh that's it! :)
Thank mlipok!
Then I see that you have to switch to this version. It is very necessary to implement this functionality.

Share this post


Link to post
Share on other sites
AndreyS
Soooo PhoenixXL! Experienced! A great solution! It was then that I had! That's it! :)
Finally! :) Not easy but you did it! :)
Thank you so much!
Edited by AndreyS

Share this post


Link to post
Share on other sites
TheSaint

But it is an edit control and we are speaking about ListBox, can you provide an example for a listbox ?

Doh!  :wacko:

(insert facepalm here)

Where was my brain?  :blink:

Sorry AndreyS - I think my brain was taking a vacation on another planet.  :ermm:

Haven't been myself, since the damn AUS election went to the Immoral party.

P.S. To be fair to my brain though, Word Wrap in a ListBox is a little out of the ordinary ... traditionally you just use a horizontal scrollbar to see the entire entry in a line. ListBox isn't dynamic like an Excel spreadsheet, and I only see trouble spreading things over more than one line. That said, I haven't really looked at the proposals you've been given so far ... certainly not in detail anyway.

For myself, I have always used a Tooltip to display what may be a long entry. I also often use a long Input, that is wider than the Listbox ... when feasible. Another way, is to show a shorter List version, linked to an ini file entry, that displays the full entry over two or more Inputs or a multiline Edit ... done that before too. Obviously they are just for the selected entry in the ListBox.

EDIT

Noticing your Thumbnail again, I can see why my mind thought Edit.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites
PhoenixXL
How to fix it?
I'd like to see the results!

I made it on Autoit 3.3.8.1, the problem arises due to the errors in the APIConstants.au3 that you may not have rectified/updated.

I replaced the includes and it would work without APIConstants w/o any problem on the stable release. Check the code again in the stable release.

Edited by PhoenixXL
  • Like 1

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites
guinness

Guys,

Try to refrain from using -3 and opt for $GUI_EVENT_CLOSE instead. Also I'm not getting any errors with APIIConstants.au3. What version of then beta are you using please PhoenixXL?


UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

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  

  • Similar Content

    • kneze
      By kneze
      Hi
      first step i write ipconfig output to ipconfig.txt. Now i try to find all Adapters and get for each adapter: Adapter Name, Description, Media State and Mac Adress and put it to listbox. I search for "Ethernet Adapter" but they are other entrys like Wireless Adapter .. How can i get all Adapters from ipconfig.txt and information for each adapter Adapter Name, Description, Media State and Mac Adress and write to listbox ? 
      Would appreciate any help!
      #include <File.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 451, 328, 856, 237) $Button1 = GUICtrlCreateButton("Button1", 8, 8, 75, 25) $List1 = GUICtrlCreateList("", 88, 8, 353, 305) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select ;Case $GUI_EVENT_CLOSE Case $msg = $GUI_EVENT_CLOSE Exitloop Case $msg = $Button1 $FilePath= "C:\temp\IPconfig.txt" $StringToSearch= "Ethernet adapter" $CaseSense=0 $Lines=_FileCountLines($FilePath) $hFile=FileOpen($FilePath,0) $Lines=_FileCountLines($FilePath) For $i=0 To Number($Lines) $Test=FileReadLine($hFile,$i) If StringInStr($Test,$StringToSearch,$CaseSense) Then $filereadAdapter = FileReadLine($hFile,$i) $filereadDescription = FileReadLine($hFile,$i+4) $filereadMediaState = FileReadLine($hFile,$i+2) $filereadMAcAdress = FileReadLine($hFile,$i+5) GUICtrlSetData($List1 , "Adapter: " & $filereadAdapter & @CRLF& "Description: "& $filereadDescription & @CRLF & "Media State: " & $filereadMediaState & @CRLF & "Mac Adress: " & $filereadMAcAdress& @CRLF) ;ExitLoop EndIf Next FileClose($hFile)  
       
    • nacerbaaziz
      By nacerbaaziz
      can we  create a list box with  Columns?
      welcome everybody
      Dears I have a question if you let me
      can we  create a list box with  Columns?
      i know we can create a list view with Columns
      but my question is about the list box
      I'm waiting your responses
      Thank you in advance
    • hcI
      By hcI
      Hello
      Today I'm working on listbox but there might be something that I'm missing...
      I made a little script that allow the user to swap 2 items for the listbox. So the user select for example the 3rd item, press the button "Up" and it switch with the 2nd one, same with the "Down" button that switch with the 4th one.
      But when I select the 3rd item and switch it the item become unselected and I would like to select it again after the manipulation :
      As you can see in the comment of the script, _GUICtrlListBox_SetSel don't highlight/select them once the swap process is done..
      What am I missing ?
    • Daka
      By Daka
      I know there are listbox and listview, but now I have?
      here is the video of infowindow 
      I tried to read mouse selection like for listbox:
      $listWindow = "[CLASS:TFormResearchGR]" $topicsList = "[CLASS:TMWrapper; INSTANCE:255]" WinWait($listWindow, "", 60) $hdlWindow = WinGetHandle($listWindow) $hdlList = ControlGetHandle($hdlWindow, "", $topicsList) _GUICtrlListBox_ClickItem($hdlList, 0, "left") $countOfList = _GUICtrlListBox_GetCount($hdlList) ConsoleWrite("Count of list: " & $countOfList & @LF) count of list is not working.
      I realiezed that there are difference between listbox and listview, but this is something different.
      and till now I never saw that you can go inside with infotool and also get instances.
       
      so Im confused how to get the list number and the names of selection?
    • Guy_
      By Guy_
      This is not a working example -- I'm asking about the principle...
      Here we have the often seen code to detect a double-click on an item in one ListBox (ID in $idListBox is of course created by other code).
      To catch that ListBox item, I have only added $sBookmark to it. This could be a pick list application.
      $idListBox = 0x004A0FB0 GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox, _ $sBookmark If Not IsHWnd($idListBox) Then $hWndListBox = GUICtrlGetHandle($idListBox) $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $idListBox, $hWndListBox $sBookmark = _GUICtrlListBox_GetText( $hWndFrom, _GUICtrlListBox_GetCurSel($hWndFrom) ) Switch $iCode Case $LBN_DBLCLK ConsoleWrite("you double-clicked " & $sBookmark & @CRLF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc  
      Now, my question is: can one modify the _WM_COMMAND function to allow for a dynamic number of ListBoxes? (meaning, user-defined -- the amount of ListBoxes/pick lists can change at any time).
      Let's assume I dynamically obtained an array with ListBox ID's for (in this case) 5 pick lists:

      One part of the solution seems to work with the For... Next loop I added below, but I'm wondering if that is the ultimate? (knowing this Func has to be as fast as possible)
      The part where I can't find anything that works for a dynamic amount of ListBox ID's is in the Case check...
      I tried _ArrayToTxt($aIdListBox, ", ", 1), messed with Eval(), and trying Case $aIdListBox[start] To $aIdListBox[end]
       
      Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox, _ $sBookmark For $i = 1 To UBound($aIdListBox) - 1 ; is this solution fast enough? (it seems to work well) If Not IsHWnd($aIdListBox[$i]) Then $hWndListBox = GUICtrlGetHandle($aIdListBox[$i]) ExitLoop ; cause there can only be one hit(?) EndIf Next $hWndFrom = $lParam $iIDFrom = BitAND($wParam, 0xFFFF) ; Low Word $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case [WHAT TO PUT HERE if nr of ListBoxes is dynamic?], $hWndListBox ; <= MAIN question $sBookmark = _GUICtrlListBox_GetText( $hWndFrom, _GUICtrlListBox_GetCurSel($hWndFrom) ) Switch $iCode Case $LBN_DBLCLK ConsoleWrite("you double-clicked " & $sBookmark & @CRLF) EndSwitch Return $GUI_RUNDEFMSG EndFunc - - -
      As a workaround, I can probably add the maximum number of allowed ListBoxes to the Case check, seperated by commas, but only display the number of ListBoxes needed. But I'm hoping it can be made truly dynamical...?
      Thank You : )
       
×