Results 1 to 18 of 18

Thread: freezing richtextbox from scrolling while outputting text

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    freezing richtextbox from scrolling while outputting text

    Hi all ... just wonder if there is any codes out there that can freeze the richtextbox from scrolling when outputting a long string of text.

    My problem is when outputting a large amount of lines into a richtextbox, it tends to scroll along the last line of input. I want it to be fixed at the top of the richtextbox when outputting. Sometimes .. it remains at the top ... but sometimes .. it follows the last line ... this is weird ... probably due to the system graphic memory ...

    Appreciate if anyone can tell me how to freeze the richtextbox when outputting.

    Thanks !

    Chris

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: freezing richtextbox from scrolling while outputting text

    Any clues from any gurus out there ???

  3. #3
    Frenzied Member ice_531's Avatar
    Join Date
    Aug 2002
    Location
    Sitting w/ Bob Status: -Next -To- Null- Friend: Philip
    Posts
    1,152

    Re: freezing richtextbox from scrolling while outputting text

    can u simply disable the rtb while it is outputting?

    rtb.enabled = false
    :::`DISCLAIMER`:::
    Do NOT take anything i have posted to be truthful in any way, shape or form.
    Thank You!

    --------------------------------
    "Never heard about "hiking" poles. I usualy just grab a stick from the nature, and use that as a pole." - NoteMe
    "Finaly I can look as gay as I want..." - NoteMe
    Languages: VB6, BASIC, Java, C#. C++

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: freezing richtextbox from scrolling while outputting text

    Nope .. it is not working ... the rtb still scrolls ...


  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: freezing richtextbox from scrolling while outputting text

    how about making it not visible?

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: freezing richtextbox from scrolling while outputting text

    What code you are using to output text to the RTB?

  7. #7
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: freezing richtextbox from scrolling while outputting text

    I'd be interested in that, also.

  8. #8
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: freezing richtextbox from scrolling while outputting text

    Have you tried RTB.Selstart = 0 ?

    EDIT : Sorry just reread and saw that it is DURING the load that you have the issue.
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: freezing richtextbox from scrolling while outputting text

    Glad that someone also share the same interest in solving this problems with me ....

    Anyway ... cannot use rtb.selstart = 0 .... reason .... I am outputting text to the rtb using rtb.seltext = "blah .. blah blah ..."

    So ... when the list of text starts to hit the bottom of the rtb height ... it will automatically ... have a vertical scroll bar ... and starts scrolling down while I am still outputting text to it.

    Talk about it ... I think I can disable the vertical scrollbar when outputting and then turn it back on when I'm done outputting. I am going to try it now.

    Come back later to post the result.

    Cheers.

  10. #10
    Frenzied Member David.Poundall's Avatar
    Join Date
    Sep 2002
    Location
    Robin Hood Land
    Posts
    1,457

    Re: freezing richtextbox from scrolling while outputting text

    I am not sue if this helps but the attached code fills a Rich textbox in the blinkof an eye if that's what you are trying to do. I still am not sure what you mean by outputing you see. Outputting to the RTB or Outputting from the RTB. If it is TO the RTB then the highlighted line is what you need.

    Code:
    str = dLog & "\temp1log.txt"
    Set F1 = fso.GetFile(str)
    Set ts1 = F1.OpenAsTextStream(ForReading)
    If F1.Size < 10 Then
         RichTextBox1.Text = "Sorry but this file is Empty"
         GoTo Done
         End If
    RichTextBox1.TextRTF = ts1.ReadAll    '<<<<<<<<
    HTH

    .
    David

    Learn the Rules so that you know how to break them properly.

    Printing dll dBTools MZTools Winsock API WinsockVB More Winsock SGrid2 MSChart Mail2Web

    If you have found this thread useful then read this

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: freezing richtextbox from scrolling while outputting text

    Argghhh ..... rtb.scrollbar cannot be changed during runtime .... becos it is a read-only field ..... so sad ..... this method cannot be feasible ....

    thanks dave for your tips .... however, I am not outputting from a file. I am outputting from recordset ... from a database .... hence ... I read record by record ... and format them ... accordingly ... some bold .. some italic .. using selitalic ... selbold .... etc ... hence, the output is slow ... line by line outputting. I want it to appear in the rtb as it is outputting, but I dun want it to scroll when it hits the bottom of the rtb. That is my main problem.

    Anyone has any API .. or something to disable the scrolling of rtb ?

  12. #12
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: freezing richtextbox from scrolling while outputting text

    I'd like to see some examples of writing to a RTB. I haven't seen many, and can't believe that nobody has posted anything!

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: freezing richtextbox from scrolling while outputting text

    ok dglienna .. since you wanna see my code ... here is a small fraction of it ... hope it helps you in outputting to rtb

    Code:
            
    If ListNum = 7 Then
            If List7.ListCount <> 0 Then
                If List7.ListCount > 1 Then
                    RichTextBox1.SelBold = True
                    RichTextBox1.SelColor = vbBlack
                    RichTextBox1.SelIndent = 0
                    RichTextBox1.SelFontSize = 10
                    RichTextBox1.SelText = vbCrLf & "Antonym Translations" & vbCrLf
                    RichTextBox1.SelFontSize = 9
                Else
                    RichTextBox1.SelBold = True
                    RichTextBox1.SelColor = vbBlack
                    RichTextBox1.SelIndent = 0
                    RichTextBox1.SelFontSize = 10
                    RichTextBox1.SelText = vbCrLf & "Antonym Translation" & vbCrLf
                    RichTextBox1.SelFontSize = 9
                End If
                
                For I = 0 To List7.ListCount - 1
                    MyResult = List7.List(I)
                    MyResult = Replace(MyResult, ", ,", "")
                    Debug.Print MyResult
                    
                    RichTextBox1.SelBold = False
                    RichTextBox1.SelColor = vbBlack
                    RichTextBox1.SelFontSize = 9
                    RichTextBox1.SelIndent = 250
                    If I > 8 Then
                        RichTextBox1.SelHangingIndent = 270
                    Else
                        RichTextBox1.SelHangingIndent = 180
                    End If
                    RichTextBox1.SelText = I + 1 & ". "
                    RichTextBox1.SelText = Mid(MyResult, 1, InStr(MyResult, "="))
                    MyResult = Mid(MyResult, InStr(MyResult, "=") + 1)
    MyReDo3:
                    If InStr(MyResult, "(") Then
                        If I > 8 Then
                            RichTextBox1.SelHangingIndent = 270
                        Else
                            RichTextBox1.SelHangingIndent = 180
                        End If
                        RichTextBox1.SelBold = True
                        RichTextBox1.SelText = Mid(MyResult, 1, InStr(MyResult, "(") - 1)
                        RichTextBox1.SelBold = False
                        RichTextBox1.SelText = "("
                        MyResult = Mid(MyResult, InStr(MyResult, "(Also ") + 6)
                        RichTextBox1.SelItalic = True
                        RichTextBox1.SelText = "also "
                        RichTextBox1.SelItalic = False
                        RichTextBox1.SelText = Mid(MyResult, 1, InStr(MyResult, ")"))
                        MyResult = Mid(MyResult, InStr(MyResult, ")") + 1)
                        If MyResult <> "" Then
                            GoTo MyReDo3
                        Else
                            RichTextBox1.SelText = vbCrLf
                        End If
                    Else
                        RichTextBox1.SelBold = True
                        RichTextBox1.SelText = MyResult
                        RichTextBox1.SelBold = False
                        RichTextBox1.SelText = vbCrLf
                    End If
                Next I
            End If
        End If

  14. #14
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: freezing richtextbox from scrolling while outputting text

    Thanks. I will take a look at it to try to figure out how to use it. I have a WYSIWYG RTB that is the same as my printer, but haven't figured out how to center things. I have tried using the SPACE() function, but am having trouble. I see that I have to use twips for positioning, but am still unclear as to how. Is there a way to print at a tab location? I wonder if I can set tabs on the rtb? I have something that will do it for a Listbox.

  15. #15
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: freezing richtextbox from scrolling while outputting text

    Try the LockWindowUpdate API. Just pass the rtb's handle to lock it and
    then pass 0 to unlock it.

    Code:
    Private Declare Function LockWindowUpdate Lib "user32.dll" (ByVal hwndLock As Long) As Long
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  16. #16

    Thread Starter
    Lively Member
    Join Date
    Sep 2004
    Posts
    86

    Re: freezing richtextbox from scrolling while outputting text

    Thanks RobDog888 ... might be the one I am looking for.

    Cheers

  17. #17
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: freezing richtextbox from scrolling while outputting text

    No prob. hope it works out for you.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  18. #18
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: freezing richtextbox from scrolling while outputting text

    I'm having luck using .Find to find [1], and then replacing it with my variable, which I already have in a textbox on a form. It is already formatted!
    The only problem is that if I right-align it, then the lines on the table mess up. I can pad it with spaces, though. I probably have [50] variables.
    Makes for a *LOT* of code, but it works.

    You might want to use .Find to get to the top line of your RTF, after it writes the DB. It's not elegant, but it will work.

    I have a bmp in my RTF, and now I need a way to replace the contents with the one from the program. Any idea how to do it? It wouldn't be hard to save it as a file, if there is a way to read it into the right area, but I'd like to be able to paste it there.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width