If you scroll to the bottom of a richtextbox and hold the down arrow key the RTB beeps to tell you you can't scroll down any farther. Is there any way to keep it from beeping.
Printable View
If you scroll to the bottom of a richtextbox and hold the down arrow key the RTB beeps to tell you you can't scroll down any farther. Is there any way to keep it from beeping.
is it a windows beep or a pc speaker beep?
It's the window's beep.
VB Code:
Private Sub RichTextBox1_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = 40 Then KeyCode = 0 End Sub
Regards...
Very good, BUT
I find (after trying the code) that I can't scroll down using the arrow key AT ALL, no matter where I am.
I suppose you would have to modify the code such that it only intercepts key code 40 IF and ONLY IF the cursor is on the last line of the RTF box.
Is there anyone that knows how to kill this beep using an API call? I have a gut feeling that we just need a SEND_MESSAGE thing to achieve this.
Very good try, though zuperman, but just not quite good enough.
yep, i think you are right, I didn't think about that possibility ...Quote:
Originally posted by HaxSoft
Very good try, though zuperman, but just not quite good enough.
Just for the sake of argument: Suppose we could get the width of each line in the RTF box (we can find its width in pixels and the font and the width of the text).
That information should be sufficient to determine whether we are at the last line. IF so, then we implement the code you suggested. Otherwise, key 40 (Down Arrow) is enabled.
Just a thought. I don't really have time to experiment with this right now, but it's interesting nonetheless.
Friday, i not in the mood to do that, but... good idea:DQuote:
Originally posted by HaxSoft
Just for the sake of argument: Suppose we could get the width of each line in the RTF box (we can find its width in pixels and the font and the width of the text).
That information should be sufficient to determine whether we are at the last line. IF so, then we implement the code you suggested. Otherwise, key 40 (Down Arrow) is enabled.
Just a thought. I don't really have time to experiment with this right now, but it's interesting nonetheless.
I think, I will spend my hangover-Sunday looking into that, haha.
I think, I will spend my hangover-Sunday looking into that, haha.
sample u wanted HaxSoft
VB Code:
Option Explicit Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Const EM_GETLINECOUNT = &HBA Private Sub RichTextBox1_Change() Dim lineCount As Long On Local Error Resume Next lineCount = SendMessageLong(RichTextBox1.hwnd, EM_GETLINECOUNT, 0&, 0&) Label1 = Format$(lineCount, "##,###") End Sub
Tried it out ... it works like a charm. Thanks a million. Although it's not really MY problem, I really really wanted to know.
You're cool dude.
ALTHOUGH -- getting demanding now.... I also need to know which line the caret (insertion point [or cursor]) is currently at. If I don't get info, zuperman's suggested solution won't work.