Re: Text window
- Posted by Derek Parnell <ddparnell at bigpond.com> Aug 25, 2001
- 407 views
Hi, here is a sample program that loads a text file into a displaying area. See what you can make of it. ------------------ include win32lib.ew without warning with trace object VOID -- To avoid flicker VOID = classDefaults(Window, {{CCwinstyle,0}}) constant win = create(Window, "Show Text Test", 0, 0, 0, 400, 430, 0), SB = create(StatusBar, "", win, 0,0, 0,0,0), fName = create(EditText,"", win, 5, {w32AltEdge,-30}, 300 , 20, 0), fTextArea = create(MleText, "", win, 5,5, w32Edge, {w32Edge,-35}, {WS_CHILD, WS_VISIBLE, WS_HSCROLL, -- Remove this if you want word wrap WS_VSCROLL, WS_BORDER, ES_LEFT, ES_MULTILINE, ES_READONLY} ) setWindowBackColor(fTextArea, getSysColor(COLOR_INFOBK)) setFont(fTextArea, "Courier New", 12, Normal) procedure LoadFile(integer keycode, integer shifts) sequence filename integer fh object dirinfo sequence data if keycode != VK_RETURN then return end if returnValue(-1) filename = getText(fName) if length(filename) = 0 then setText(SB, "I require a file name first.") return end if dirinfo = dir(filename) if equal(dirinfo, -1) then setText(SB, sprintf("File '%s' not found.", {filename})) return end if if dirinfo[1][D_SIZE] > 32000 then setText(SB, sprintf("File '%s' is larger than 32000 bytes.", {filename})) return end if fh = open(filename, "rb") if fh <= 0 then setText(SB, sprintf("Unable to open file '%s'.", {filename})) return end if data = get_bytes(fh, dirinfo[1][D_SIZE]) setText(fTextArea, data) close(fh) setText(SB, "File loaded.") end procedure onKeyPress[fName] = routine_id("LoadFile") procedure fName_resize(integer style, integer w, integer h) setCtlSize( fTextArea, w32Edge, {w32Edge, -35}) setRect( fName ,5, {w32AltEdge,-30}, 300 , 20, True) end procedure onResize[win] = routine_id("fName_resize") VOID = command_line() setText(fName, VOID[2]) setHint(fName, "Enter a file name and press return to see its contents.") WinMain(win,0) ------------------ ----- Original Message ----- From: "Travis Weddle" <Weddle at tcia.net> To: "EUforum" <EUforum at topica.com> Sent: Sunday, August 26, 2001 4:59 AM Subject: Text window > > Hi All, > > In the Win32Lib tutorial, EX12.exw is a text window, i'd like to use a > text window but is there any EASY way to make a text window (reading > text from a .txt file), with out all the stuff to change color of the > font??? > > Thanks > Trav > > > > >