|
-
Jan 24th, 2004, 12:55 AM
#1
Thread Starter
Hyperactive Member
RichTextBox scroll like a TextBox [unsolved]
If you have noticed, the TextBox scrolls down one line at a time while the RichTextBox scrolls down smoothly.
Since im using a richtextbox, How can I make it so when the user scrolls down via the Vertical scroll bar its scrolls down one line a time like the textbox instead of the smooth scrolling of the richtextbox?
Last edited by Narfy; Jan 28th, 2004 at 07:42 PM.
-
Jan 24th, 2004, 04:05 AM
#2
Frenzied Member
hmm
If there isn't a property to do it, SendMessage probably can help you... but... Why would you want it to scroll one line at a time? Why not just use a listbox or a normal textbpx ?
"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.
-
Jan 24th, 2004, 10:13 AM
#3
Thread Starter
Hyperactive Member
i want it to scroll one line at a time because im making a line numbering control and i cant get the line numbers to match exactly up with the text in a richtextbox because of the smooth scrolling, but i can get them to line up in the textbox because of the one-line-at-a-time scrolling.
-
Jan 24th, 2004, 10:32 AM
#4
Supreme User
You could subclass as vbNeo suggests, or better still make your own User Control
-
Jan 24th, 2004, 11:11 AM
#5
Thread Starter
Hyperactive Member
is there a example anywere on how to do a subclass?
-
Jan 24th, 2004, 11:56 AM
#6
Supreme User
Not sure, i believe its the hardest thing to do in VB
Woka, Marty or someone else should be able to help you more.
-
Jan 24th, 2004, 12:57 PM
#7
Frenzied Member
or MerrionComputing, drop them a mail
"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.
-
Jan 25th, 2004, 03:50 PM
#8
Thread Starter
Hyperactive Member
Ive been searching like mad to try to find a answer, and i found this in the Developers Pad Source code, they use a richtextbox and it scrolls one line at a time
im using the vbaccelerator subclassing
http://www.vbaccelerator.com/home/VB...Tmr_Binary.asp
VB Code:
Implements ISubclass
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const WM_USER = &H400
Private Const WM_MOUSEWHEEL = &H20A
Private Const WM_VSCROLL = &H115
Private Const EM_GETSCROLLPOS = (WM_USER + 221)
Private Const EM_SETSCROLLPOS = (WM_USER + 222)
Private Const WM_LBUTTONDOWN = &H201
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 Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function GetScrollPos Lib "USER32" (ByVal hwnd As Long, ByVal nBar As Long) As Long
Private lPixelsPerLine As Long
Private bResizingTriggered As Boolean
Private Property Let ISubclass_MsgResponse(ByVal RHS As EMsgResponse)
End Property
Private Property Get ISubclass_MsgResponse() As EMsgResponse
Select Case CurrentMessage
Case WM_VSCROLL, WM_MOUSEWHEEL
ISubclass_MsgResponse = emrConsume
Case Else
ISubclass_MsgResponse = emrPreprocess
End Select
End Property
Private Function ISubclass_WindowProc(ByVal hwnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim iScrollPos As Long
Dim bScrolling As Boolean
Dim tp As POINTAPI
' scroll events
Select Case iMsg
Case WM_MOUSEWHEEL
'go up or down 3 lines...
SendMessage hwnd, EM_GETSCROLLPOS, 0, tp
If wParam > 0 Then
tp.y = tp.y - (lPixelsPerLine * 5)
Else
tp.y = tp.y + (lPixelsPerLine * 5)
End If
SendMessage hwnd, EM_SETSCROLLPOS, 0, tp
DrawLines picLines, txtDocument
Case WM_VSCROLL
'are we scrolling, or scrolled?
bScrolling = (LoWord(wParam) = 4 Or LoWord(wParam) = 5)
If bScrolling Then
'get info using wparam
iScrollPos = HiWord(wParam)
Else
'call api
iScrollPos = GetScrollPos(hwnd, 1)
End If
'update lines
If Int(iScrollPos / lPixelsPerLine) <> (iScrollPos / lPixelsPerLine) Then
'not divisible by 16
'we are showing half a line...
If bScrolling Then
wParam = MakeDWord(LoWord(wParam), Int(iScrollPos / lPixelsPerLine) * lPixelsPerLine)
Else
'hmm...
End If
End If
'send message to rtf for processing
ISubclass_WindowProc = CallOldWindowProc(hwnd, iMsg, wParam, lParam)
'update the lines
DrawLines picLines, txtDocument
'reset flags
bResizingTriggered = False
If wParam = 8 Then '8=SB_END... scroll end
ElseIf wParam > 1 Then 'not up/down button
End If
Case WM_LBUTTONDOWN
Debug.Print lParam
End Select
End Function
Private Function LoWord(dwValue As Long) As Integer
CopyMemory LoWord, dwValue, 2
End Function
Private Function MakeDWord(LoWord As Integer, HiWord As Integer) As Long
MakeDWord = (HiWord * &H10000) Or (LoWord And &HFFFF&)
End Function
Private Function HiWord(dwValue As Long) As Integer
CopyMemory HiWord, ByVal VarPtr(dwValue) + 2, 2
End Function
it doesn't do anything but it works in developers pad but not in my program, i get a illegal operation then vb6 crashes.
anyone know what the problem is?
-
Jan 26th, 2004, 04:20 AM
#9
Hyperactive Member
try this
http://www.elitevb.com/content/01,0099,01/
exactly what you want ........
Can you in return help me ...
Dasith [email protected]
25-Jan-04
Is it possible to add a Black Line to indicate the end of the page (printer.height) .... So the user knows when a page ends and a new page starts ..
Like in ms word you get a line to indicate page margins ...
please email me if you can do it [email protected]
It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
-Aristotle As quoted in Rapid Development, chapter 8, page 167.
-
Jan 26th, 2004, 06:13 PM
#10
Thread Starter
Hyperactive Member
thanks, but it didn't work, the richtextbox they have in that project, it doesn't scroll one line at a time
-
Jan 27th, 2004, 06:23 PM
#11
Thread Starter
Hyperactive Member
bump
cmon, someone has got to know :P
-
Jan 28th, 2004, 07:41 PM
#12
Thread Starter
Hyperactive Member
-
Jan 29th, 2004, 07:32 PM
#13
Thread Starter
Hyperactive Member
cmon, someone answer, im desperate ive been searching everywhere
-
Feb 1st, 2004, 04:24 AM
#14
Hyperactive Member
what you want is a line numbered rtf control ...
try my above example ....... it has a line numbered rich text control
It is the mark of an instructed mind to rest satisfied with the degree of precision which the nature of the subject admits, and not to seek exactness when only an approximation of the truth is possible.
-Aristotle As quoted in Rapid Development, chapter 8, page 167.
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
|