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
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