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

Triming a (locked) Rich Text box 1

Status
Not open for further replies.

Golggen

Programmer
Apr 28, 2001
2
US
I'm trying to trim the first line of a rich text box if it accumulates a certain number of lines. I have something to count the lines and execute the code to remove the first line.

The code I'm using right now is the following....

(in global)..
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const EM_GETLINECOUNT = &HBA
Private Const EM_LINEINDEX = &HBB
Private Const EM_LINELENGTH = &HC1
Private Const EM_GETFIRSTVISIBLELINE = &HCE
(end of global)


(code to delete first line)..
log.SelStart = Len(log.Text)
Label1.Caption = Len(log.Text)
Label2 = SendMessage(log.hwnd, EM_GETLINECOUNT, ByVal 0&, ByVal 0&)
log.SelStart = 0
log.SelLength = SendMessage(log.hwnd, EM_LINELENGTH, ByVal 0&, ByVal 0&)
log.SelText = ""
log.SetFocus
log.SelStart = len(log.text)


this will remove the text in the first line, though, since it is just replacing it with "" (nothing)... that line still exists, leaving a space at the top of the text box.... and making it so it doesnt delete any lines after the first, it just keeps doing the same thing to the same line...

now, I know I could use this to get rid of that line..

SendKeys "{delete}^{END}"

but, I have the rich text box locked, and I cannot have it unlocked anytime while its running



any ideas on how I would go about triming that first line without leaving that blank line... and without using sendkeys to get rid of it? Basically, I need to do the same thing as SendKeys "{delete}^{END}", but programmatically
 
hey cool... that worked hehe... tried adding 1 to that, didnt think of trying 2 though
 
BE CAREFUL. I heard tell somewhere in MSDN that different OS's and /or different locales MAY use JUST CR or JUST LF according to some registry setting.
Lines do not end in CRLF. They begin with a CRLF IF there is a line before it. For example, if CRLF are the ONLY characters in a file or RTF then you have two lines (or so it has been my experience). JOIN and SPLIT seem to work along this line of logic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top