[[toc]]
=Displaying Multi-Line Text=
//by [[user:StPendl|1271661732]]//

> Every now and then one needs to display text of multiple lines, which the user should not be able to change.
> Using one STATICTEXT control for each line is cumbersome, but the STATICTEXT control is a multi-line control with automatic text wrapping, which most are not aware of.

> The following are some ways to display text.

==Using a Static Text Control==
> This allows the user to read the text, but he can not select and copy anything.

[[code format="vbnet"]]
    ' turn main window off
    nomainwin

    ' specify text to display
    Message$ = "The world is turning"; CHR$(13); _
        "till it gets stuck"; CHR$(13); _
        "in the mud of the population."

    ' set up the GUI
    statictext #m.txt, Message$, 10, 10, 200, 100

    ' open the window
    open "Multi-Line Message Demo" for window as #m

    ' trap closing the window, this line is mandatory
    #m "trapclose [quit]"

    ' wait for user action
    wait

[quit]
    ' close the window and terminate
    close #m
    end
[[code]]

==Using a Text Box with Scroll-Bar==
> This allows the user to read the text and he can select and copy anything.
> You can display a whole plain text file in a small space.

[[code format="vbnet"]]
    ' turn main window off
    nomainwin

    ' specify text to display
    filedialog "Open a Plain Text File ...", "*.txt;*.bas", FileName$

    ' no file selected then terminate
    if FileName$ = "" then end

    ' read the text
    open FileName$ for input as #f
        Message$ = input$(#f, lof(#f))
    close #f

    ' set up the GUI
    textbox #m.txt, 10, 10, 200, 100

    ' add a scroll bar for vertical scrolling and make the control read-only
    ' remove automatic horizontal scrolling
    stylebits #m.txt, _WS_VSCROLL or _ES_READONLY, _ES_AUTOHSCROLL, 0, 0

    ' open the window
    open "Multi-Line Message Demo" for window as #m

    ' trap closing the window, this line is mandatory
    #m "trapclose [quit]"

    ' fill the text box
    #m.txt Message$

    ' wait for user action
    wait

[quit]
    ' close the window and terminate
    close #m
    end
[[code]]