|
-
Jul 25th, 2002, 07:06 PM
#1
Thread Starter
Frenzied Member
Editor line counter !
I am making an HTML editor, and i'm in the progress of making a counter in the left side of that screen, that shows wich line youre on, like i other editors as editplus... I use sendmessage, but i cant get it too work probably, here's the code i'm using:
VB Code:
Private Sub Form_Load()
Counter = 1
List1.AddItem Counter
End Sub
' Note "Counter" IS declared in the declarations !
Private Sub RTB1_Change()
Dim LineCount As Long
LineCount = SendMessage(RTB1.hwnd, EM_GETLINECOUNT, ByVal 0&, ByVal 0&)
' Add line
If LineCount > PrevCount Then
Counter = Counter + 1
List1.AddItem Counter
End If
' Delete Line
If LineCount < PrevCount Then
Counter = Counter - 1
List1.RemoveItem Counter
End If
End Sub
My problem is that if the user deletes more than one line, the listbox only get's one number removed .
This is driving me nuts !
Please help !!!
Thanks in advance !
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Jul 25th, 2002, 07:17 PM
#2
Thread Starter
Frenzied Member
Going too sleep !
I'm going too sleep now... But that doesn't prevent you guys from answering
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Jul 25th, 2002, 07:46 PM
#3
Addicted Member
Um, just a question, where do you set PrevCount? Shouldn't your code be something like (assuming it's error free - I can't check the code you do have):
VB Code:
Private Sub RTB1_Change()
Dim LineCount As Long
PrevCount = LineCount ' Shouldn't you add this?
LineCount = SendMessage(RTB1.hwnd, EM_GETLINECOUNT, ByVal 0&, ByVal 0&)
' Add line
If LineCount > PrevCount Then
...
Destined.
-
Jul 25th, 2002, 07:48 PM
#4
Thread Starter
Frenzied Member
Of course...
Yes ofcourse i should, and it is there 
Just forgot too write it in the post.
Thanks
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Jul 25th, 2002, 07:58 PM
#5
Addicted Member
Oh, perhaps I might actually know. 
In your remove statment, you have
VB Code:
If LineCount < PrevCount Then
Counter = Counter - 1
List1.RemoveItem Counter
End If
If I understand correctly, this will only remove one item, even though it may actually be more than one. I don't know where the index starts or stops, but here's a general idea that may work:
VB Code:
If LineCount < PrevCount Then
Dim diff As Long, i As Integer
diff = PrevCount - LineCount
For i = 1 to diff
Counter = Counter - 1
List1.RemoveItem Counter
Next i
End If
I'm not completely sure, but this might be what you need. Hope it helps in some way. 
Destined.
-
Jul 26th, 2002, 04:23 AM
#6
Thread Starter
Frenzied Member
Wohoo
Thanks, i woke up today turn on my computer and saw your piece of code... Suddenly everything made sense...
Noe it works !!! THANK YOU VERY MUCH !
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Jul 26th, 2002, 06:51 AM
#7
Addicted Member
Cool! Glad I could help.
Now it's my turn to go to bed. Just fixed a computer that had a complete hard drive failure.. *sigh*
Destined
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
|