|
-
January 11th, 2010, 08:58 AM
#4
Re: kill off top line in an RTB
In case it did not become clear, this is how you delete a line:
You set SelStart to the begin of the line,
then you set SelLength to the position behind the next vbCrLf to mark the line
Then you set SelText to "", deleting the marked text.
Only the problem is, if the line has been split due to word wrapping, because it is longer than the visible horizontal width, you might delete a whole paragraph.
Here is a method which deletes exactly one visible single line from the rtb:
Code:
Private Const WM_KEYDOWN = 256&
...
nRet = SendMessage(rtbCmdLog.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&)
dim e%
rtbCmdLog.SetFocus
Do While nRet > intLineLimit
rtbCmdLog.SelStart = 0 'make sure to be at the top of the file.
SendMessage rtbCmdLog.hWnd, WM_KEYDOWN, vbKeyDown, 0 'move key down
e = rtbCmdLog.SelStart 'get the position of the begin of line 2
rtbCmdLog.SelStart = 0 'back to the beginning
rtbCmdLog.SelLength = e 'mark the line
rtbCmdLog.SelText = "" 'delete the line
nRet = SendMessage(rtbCmdLog.hwnd, EM_GETLINECOUNT, 0&, ByVal 0&) 'get new line count (reduced lines)
rtbCmdLog.Refresh
Loop 'continue deleting lines at top
The method is:
move the cursor home
move the cursor down one line to get the length of the first line with a simulated down-key
set the cursor home and set the SelLength to mark the line
set the SelText to "" to delete the line.
This method takes in account if there is a real vbCrLf or not.
Sorry vb5, it seems you were a little faster'n me. 
Yes, your proposal seems to work, too.
Last edited by WoF; January 11th, 2010 at 09:01 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|