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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TMemo, how long

Status
Not open for further replies.

StoneColdCrazy

Programmer
Jun 30, 2000
11
US
How much text VCL's TMemo can hold?<br>When it reaches it's maximum size, how can I know that?<br>
 
&nbsp;&nbsp;&nbsp;&nbsp;Here are a couple of snippets of code I got from Borland's Community. These <u>should</u> also work with TRichEdit. The first shows the number of lines a TMemo component is capable of showing.<br><br>void __fastcall TForm1::MemoLinesShowingClick(TObject *Sender)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;int Result;<br>&nbsp;&nbsp;&nbsp;&nbsp;TRect R;<br>&nbsp;&nbsp;&nbsp;&nbsp;Memo1-&gt;Perform(EM_GETRECT, 0,int(&R));<br>&nbsp;&nbsp;&nbsp;&nbsp;Result = (R.Bottom - R.Top) / Canvas-&gt;TextHeight('XXX');<br>&nbsp;&nbsp;&nbsp;&nbsp;Memo1-&gt;Lines-&gt;Add(Result);<br>}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;This code assumes that the form's and memo's font is the same. If it is not, the program must also take into account the size of the font.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;The second shows the current line you are on in TMemo.<br><br>void __fastcall TForm1::Button1Click(TObject *Sender)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;int LineNumber;<br>&nbsp;&nbsp;&nbsp;&nbsp;LineNumber = SendMessage(Memo1-&gt;Handle, EM_LINEFROMCHAR, -1 , 0);<br>&nbsp;&nbsp;&nbsp;&nbsp;ShowMessage(LineNumber);<br>}<br><br>&nbsp;&nbsp;&nbsp;&nbsp;If the two are equal, you have reached the maximum. I haven't tested it, but I <b>think</b> that TMemo will delete the oldest lines when the newest is added.<br> <p>James P. Cottingham<br><a href=mailto: > </a><br><a href= Veneer Co., Inc.</a><br>All opinions are mine alone and do not necessarily reflect those of my employer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top