Older Version Newer Version

StPendl StPendl Apr 19, 2010

Displaying Multi-Line Text

by - StPendl StPendl Apr 19, 2010



Using a Static Text Control


 ' 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

Using a Text Box with Scroll-Bar


 ' 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 it 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