F.eks. når du markerer et element i den ene rtb, kan du få markeret det tilsvarende i den anden rtb.
Hvis de er oprettet som control-array, gøres det f.eks. som vist herunder (blot med List1 og ikke rtb.
Private Sub List1_Click(Index As Integer) Select Case Index Case 0 List1(1).ListIndex = List1(0).ListIndex Case 1 List1(0).ListIndex = List1(1).ListIndex End Select End Sub
Mht scroll, er der vist ikke properties der styrer det, så der skal du vist have gang i noget api...
Synes godt om
Nybegynder
31. august 2003 - 12:35#2
virker den når den en rtb er i hex og den anden er i ascii tegn
'-------------------------------- Form1 -------------------------------- ' HUSK at sette ScrollBars til rtfVertical på RichTextBox1 '----------------------------------------------------------------------- Option Explicit
Private Sub Form_Load() Dim i As Integer With RichTextBox1 .Top = 50 .Left = 50 .Width = 3000 .Height = 1500 .Text = "" For i = 1 To 10 .Text = .Text & i & " Prøv at scrolle ned" & vbCrLf Next i End With
With RichTextBox2 .Top = 50 .Left = 3100 .Width = 3000 .Height = 1500 .Text = "" For i = 1 To 10 .Text = .Text & i & " Se så her..." & vbCrLf Next i End With
Call HookRich(RichTextBox1, RichTextBox2) End Sub
Private Sub Form_Unload(Cancel As Integer) Call UnHookRich(RichTextBox1) End Sub '-------------------------------- Form1 --------------------------------
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 Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _ ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" ( _ ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, _ ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long Private Declare Function SetClipboardViewer Lib "user32" (ByVal hwnd As Long) As Long
Private Const GWL_WNDPROC = (-4) Private ScrollHwnd As Long Private PrevProc As Long
Public Sub HookRich(Rtf As RichTextBox, ScrollRtf As RichTextBox) PrevProc = SetWindowLong(Rtf.hwnd, GWL_WNDPROC, AddressOf WindowProc) ScrollHwnd = ScrollRtf.hwnd End Sub
Public Sub UnHookRich(Rtf As RichTextBox) SetWindowLong Rtf.hwnd, GWL_WNDPROC, PrevProc End Sub
Private Function WindowProc(ByVal hwnd As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long WindowProc = CallWindowProc(PrevProc, hwnd, uMsg, wParam, lParam) If uMsg = 277 Then SendMessage ScrollHwnd, 277, wParam, vbNull End If End Function '-------------------------------- Module1 --------------------------------
Synes godt om
Nybegynder
31. august 2003 - 23:34#6
Mange tak. Det virker fint men hvis du ved hvordan man får det makeret i begge rtb så vil jeg give 100 point for det.
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.