Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"GO BOTTOM" for EditBox? 1

Status
Not open for further replies.

Headwinds

Programmer
Feb 6, 2001
38
US
I have an extract-transform-load job that the user starts by clicking a button in a form. The form contains an EditBox that displays the contents of a memo column in an updatable cursor. As major events occur in the ETL job, I concatenate new lines of interesting and informative stuff about how it's all going, and I refresh the EditBox.

Everything works fine except that the only evidence that anything is happening in the EditBox is that the vertical scrollbar appears and the thumb grows shorter as the contents of the memo column grow longer. Once the EditBox fills with lines of text, that's all it ever displays, unless the user clicks on the vertical scrollbar to see what's being added.

How can I make the EditBox keep showing the new lines as they're added?

TIA for any solutions, guesses, workarounds.
 
Just adjust the EditBox.SelStart & EditBox.SelEnd values.
You may have to fiddle with DOEVENTS, setfocus and Refresh to get the movement to show on the screen.
 
Thanks wgcs.

My EditBoxes don't have the SelEnd method (in VFP6). I can calculate and set SelStart and SelLength. This is happening more or less correctly. I can display the programmatically selected lines in a message box with SelText. But I still haven't been able to get the EditBox to reveal anything below its bottom line (even though text below that line is now selected).

My DOEVENTS and Refresh fiddling must be defective.
 
Good luck. I tried fiddling with this for about a week once and could never get it to work right. I finally just added the messages to the top of the menu and let the older message scroll down.

Here is the code I use it has a few frills like turning the forecolor red and clearing the box.

lparameters cstring, lclear, lred
with thisform.edtmessage
IF lred
.forecolor = RGB(255,0,0)
ELSE
.forecolor = 0
ENDIF
if lclear
.value = ''
endif
.value = cstring + chr(13)+.value
wait window '' timeout .1
endwith


the wait window '' timeout .1

seems to force a refresh and is faster than calling a doevents

 
In case anybody's interested, I've found a workaround to this problem. The trick is to continually edit the value of the edit box to contain only lines you want to show (but keep the entire text available in a cursor). Here's how:

Make an updatable cursor with a memo column and append an empty record. As your process generates message strings, load them with carriage returns:
Code:
UPDATE my_log SET logtext = logtext + CHR(13) + m.msgstring
Test to see if MEMLINES() of your memo column exceeds the number of lines you want to display in your edit box. If not, set the value of the edit box equal to the memo column in the cursor. If so, iterate through the lines you want displayed and make that the edit box value.
Code:
IF MEMLINES(my_log.logtext) < m.editboxlinecount
  THISFORM.Edit1.VALUE = my_log.logtext
ELSE
  THISFORM.Edit1.VALUE = ''
  FOR m.knt = (MEMLINES(my_log.logtext) - m.editboxlinecount) TO ;
    MEMLINES(my_log.logtext)
    THISFORM.Edit1.VALUE = THISFORM.Edit1.VALUE + CHR(13) + ;
    MLINE(my_log.logtext, m.knt)
  ENDFOR
ENDIF
Also make a Click method for the edit box that sets the value of the edit box to the whole memo column of your cursor. That way, if a user wants to scroll back up to see what's gone out of sight, all the text will be available to view.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top