View Single Post
  #2   Spotlight this post!  
Unread 12-08-2003, 12:20
rbayer's Avatar Unsung FIRST Hero
rbayer rbayer is offline
Blood, Sweat, and Code
no team (Teamless Orphan)
 
Join Date: Mar 2002
Rookie Year: 2001
Location: Minnetonka, MN
Posts: 1,087
rbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of lightrbayer is a glorious beacon of light
Send a message via AIM to rbayer
Depends on what language/API you're trying to do it in. For example, to insert the text stored in the CString object newText into line 2 of a CEdit object named m_big, the code would be:


int i=m_big.LineLength(0)+2;

m_big.SetSel(i, i);
m_big.ReplaceSel(newText + "\r\n");

The +2 is there so that it includes the the \r\n sequence at the end of every line.

The SetSel function will set the current selection, but since the start and end values are the same, it merely moves the insertion point.

ReplaceSel will either replace the currently selected text or insert the text at the current insertion point if there is no current selection.


[edit]
Please don't worry about "credit" for this. As long as you learn the stuff and write your own code, you really don't need to credit people. Think of it like learning out of a book--you don't credit the author unless you copy specific portions of code directly from the book.
[/edit]
__________________
New C-based RoboEmu2 (code simulator) available at: http://www.robbayer.com/software.php