Page 1 of 2 12 LastLast
Results 1 to 40 of 47

Thread: [RESOLVED] RTB and Speed Issues

  1. #1

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Resolved [RESOLVED] RTB and Speed Issues

    Okay, since I've got this form splayed open, I'd like to see if there's a way to speed up the dumping of data to a RTB.

    I'm using an RTB to circumvent the data limits of a standard TextBox.

    Here's a cut-down example of the code I'm currently using to dump my data (just a form with an RTB and a single button):

    Code:
    
    Option Explicit
    
    Private Sub Command1_Click()
        Dim i As Long
    
        rtb.Text = ""
        rtb.Refresh
        rtb.Visible = False
    
        For i = 1 To 40000
            out Format$(i, "00000")
        Next i
    
        rtb.Visible = True
    End Sub
    
    Private Sub out(s As String)
        rtb.SelStart = &H7FFFFFFF
        rtb.SelText = s & vbCrLf
    End Sub
    
    
    I've also attached it as a little project, if you wish to take a look at it.

    Now, I'm running on a fairly high-performance computer, and that loop still takes within the neighborhood of 5 seconds to execute.

    The slowdown is clearly all about the RTB, as I'm also looping through this same data and plotting it, and that process is much faster.

    Any ideas on how to get my data into that RTB in a faster way?

    Thanks,
    Elroy
    Attached Files Attached Files
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  2. #2
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: RTB and Speed Issues

    have you tried locking the window update? that's usually my first attempt.

    also https://msdn.microsoft.com/en-us/lib...(v=vs.85).aspx

    Those are my go to's before trying more involved optimization.

  3. #3
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    FYI: Textbox limits can be exceeded. But is it necessary? Wouldn't logging the data be a reasonable alternative vs storing all that info in memory?

    Here's a good thread on the limitation of the textbox, workarounds and how the limit is not really a limit.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  4. #4

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Hmmm, ok, I tried the following and couldn't see any noticeable difference:

    Code:
    
    Option Explicit
    Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByRef lParam As Any) As Long
    Private Const WM_SETREDRAW = &HB
    
    Private Sub Command1_Click()
        Dim i As Long
    
        rtb.Text = ""
        rtb.Refresh
        rtb.Visible = False
        SendMessage Me.hWnd, WM_SETREDRAW, 0, 0
    
        For i = 1 To 40000
            out Format$(i, "00000")
        Next i
    
        SendMessage Me.hWnd, WM_SETREDRAW, 1, 0
        rtb.Visible = True
    End Sub
    
    Private Sub out(v As Variant)
        rtb.SelStart = &H7FFFFFFF
        rtb.SelText = v & vbCrLf
    End Sub
    
    

    Now, regarding the TextBox: LaVolpe, are you thinking that, if I go back to a TextBox that things will go faster? I'll definitely take a look at that link and try some testing.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    @Elroy. Likely

    If I recall correctly, one can simply use SendMessage WM_PASTE to keep appending to a textbox, assuming you're at the end of the textbox content. However, don't recall whether the scrollbars had any issues or not. In that link, dilettante provided an example to get past issues related to VB's limit, but those may not be necessary if the your only purpose is display vs. editing.

    When adding non-rtf text to the RTB, I think additional processing needs to take place to convert it to rtf internally; hence, the slow down. That's just a guess. I'm sure this topic has been addressed and if wanting to stay with the RTB, would be worth searching.
    Last edited by LaVolpe; Jul 7th, 2017 at 01:15 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: RTB and Speed Issues

    What's the point of using SelStart and SelText like that?
    Just store all the text in a variable and put it in the RTB at the end...

  7. #7
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: RTB and Speed Issues

    I ran a couple of tests here using the code in the OP and a slightly modified version

    The code in the op takes on average 3.7 seconds on this PC

    When the loop is changed to
    Code:
        For i = 1 To 40000
            out Right$(i & "00000", 5)
        Next i
    It takes on average 3.5 seconds
    Not much faster but a little bit.

  8. #8

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Other than circumventing the 64k limit, I'm not married to the RTB.

    I've just tested with dilettante's code (from your link), and I'm not seeing much (if any) speedup though. But there's got to be some, as a regular TextBox isn't jumping through all the hoops to build an RTF string.

    I'm starting to think that the slowdown has to do as much with formatting my numbers as it does with filling some textbox.

    EDIT1: There's no getting around formatting my numbers though, as with the production code, there are multiple columns and it's important that they're nicely lined up.

    EDIT2: Eduardo, I also tried building a string in memory and then setting the whole string to the textbox, but that didn't help with speed either.
    Last edited by Elroy; Jul 7th, 2017 at 01:40 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: RTB and Speed Issues

    I also tried using the selrtf method but that was a little slower

  10. #10
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    Using a textbox, not RTB, this took about 4-5 seconds on a relatively slower pc (over 5 years old and wasn't top-notch then). Not sure it is any better, but it does show a vb Textbox can handle the large text.

    FYI: note Wide version of SendMessage
    Code:
        SendMessageW Text1.hwnd, WM_SETREDRAW, 0, ByVal 0&
        For i = 1 To 40000
            SendMessageW Text1.hwnd, EM_SETSEL, &H7FFFFFFF, ByVal &H7FFFFFFF
            SendMessageW Text1.hwnd, EM_REPLACESEL, 0, ByVal StrPtr(Format$(i, "00000") & vbCrLf)
        Next
        SendMessageW Text1.hwnd, WM_SETREDRAW, 1, ByVal 0&
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  11. #11
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: RTB and Speed Issues

    Elroy

    I take it that this is the "box" on the left of PB's in your 1st post of the other thread.

    If so, then 2 thoughts:

    1. Maybe a FlexGrid instead .. I'll do a comparison test when I have a chance.

    2. Why post all the data at once? My bet is that you don't show more than 40 or 50 rows at a time, Assuming that the data is in an array (or even a database), why not just post what can be "seen"? If and when the user uses the vertical scrollbar, populate newly visible rows "on demand"

    In the alternative, have some command buttons in lieu of the scrollbar, such as ..

    o Top
    o PgUp
    o PgDn
    o Bottom
    o GoTo

    .. or some variation of that. Then you'd "know" how many rows to populate at-a-time.

    EDIT:

    In fact, maybe your FlexGrid would indeed only have the number of rows visible at a time, say 50.
    Do away with the scrollbar, and using the CB's, just repopulate the FG with the appropriate data. Column 0 (1st col) could contain the corresponding row numbers (or time, or whatever) for reference purposes.

    The results should be displayed instantaneously.

    Spoo
    Last edited by Spooman; Jul 7th, 2017 at 09:57 PM.

  12. #12

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Hmmm, LaVolpe, I like it. And removing the Unicode/Ansi conversion had to help a bit.

    I'll work these ideas in after lunch. I don't suspect it'll be any huge improvement, but if I can trim a couple of seconds off, it'll help.

    Thanks,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  13. #13
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    Elroy, in your other thread you mentioned a major speed problem. Is this it? Is this slowing down the ability to process/plot faster?

    If so, suggestions...

    1. Log the info to a file opened as Append, formatted as desired, close file when done with app/feed.
    2. Use a listbox or similar tool to display last 100 or so items, adding newest on top of list and removing last item when exceeds 100

    Thinking that should alleviate slow downs and still offers all the data on demand if and when needed. Just read/load the text file

    Edited: Replying to your last post. Not sure ANSI/Unicode conversion is being averted. Since VB textbox is ANSI, likely conversion is being done anyway, at some point -- if just on display, then yep, maybe no conversion done in the background while in the loop. But I would think the code would run faster on your pc. Like I said, mine is quite older compared to something fairly new. Use my pcs like my cars -- drive them til the wheels fall off
    Last edited by LaVolpe; Jul 7th, 2017 at 02:15 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  14. #14
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: RTB and Speed Issues

    It seems the update isn't the bottleneck, but good old Format$.
    I bet you remember now the thread where dilettante resorted to using a customized number formatting function to get around how slow Format is.


    FYI the mshflexgrid has a 64K limit on it's scrollbar - although workarounds have been posted elsewhere on the net.

  15. #15
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: RTB and Speed Issues

    Quote Originally Posted by Elroy View Post
    EDIT2: Eduardo, I also tried building a string in memory and then setting the whole string to the textbox, but that didn't help with speed either.
    Yes, if you concatenate in the normal VB way.

    But use SmartConcat instead.
    I have the RTB filled in less than 0.2 second.

  16. #16
    PowerPoster
    Join Date
    Jun 2015
    Posts
    2,224

    Re: RTB and Speed Issues

    Oh that too. There's a bunch of VB6 StringBuilder classes floating around. Dragokas just posted one in the code bank. I have one that mimics the .NET features, and Schmidt has one that's performant (less features).

  17. #17
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    Not discounting the advantage of filling text with better concatenation methods... I find it a bit difficult to foresee a user wanting to scroll thru a control containing tens of thousands of entries real-time. I would think the entries would be needed for subsequent number crunching/review at a later time, or for historical purposes; hence logging. That being said, I don't see the advantage of trying to display all that data when in all likelihood, it'll never be used real time, just a waste of time & effort. I can see the most recent entries being of interest in real time, but not the entire data set. I doubt all those entries would be displayed on the graph (previous thread content) as the graph is likely moving. And if that is the case, any entries in that text control, no longer on the graph, are meaningless relative to the content of the graph.

    Edited: And for a bit of additional consideration. What good is actively viewing all that data if it will be constantly updated. Let's say you are scrolling around looking for something and an update occurs. Couldn't that update force the current text position to change, force a scrolling action, while you are trying to view something? How annoying would that be? I think we've all experienced apps like that -- jumps to the bottom or top of the textbox without our consent.
    Last edited by LaVolpe; Jul 7th, 2017 at 03:02 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  18. #18

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Ok, lots of posts while I ate lunch. Just to try and cover the highlights:

    1) Yes, this is the same form that has the plotting on it. However, the plotting and the filling of this textbox are two entirely different processes. Said a bit differently, I certainly don't refill this textbox if/when the form is resized. There's no need.

    2) The name of this form is C3D reader. C3D stands for Coordinates-in-3-Dimensions. In other words, these files are full of data from infra-red (IR) markers attached to people moving through space in various ways:

    Name:  new_marker_set_front.jpg
Views: 472
Size:  80.6 KB

    Even for people who conceptually "get" what's happening, these C3D files are a mystery to many people. The internal format is binary, and goes back to the 70's. They actually pre-date micro-computers.

    I have a chunk of code that reads anything/everything that's in these files. But one of the primary things that's in them is a set of X,Y,Z coordinates recorded at a set Hertz (typically 120 these days). These X,Y,Z coordinates are millimeter measurements of those IR markers as they move through space over some time duration (based on some <0,0,0> coordinate basis).

    Okay, people can copy-and-paste this data, but a large purpose of this form is to de-mystify these C3D files for folks. Through good use of the TreeView, it allows users to "see" everything that's in these C3D files. I've got other Excel files (with macros) that do a better job of opening these files for actual calculations, but people still like a quick-and-dirty way to see the data that's in these files.

    You'd be surprised at how often my users "snoop" into these files.

    3) Okay, I have another program (not written by me) that had the plotting feature. It's also shareware, but it wasn't mine. It did display the data just like mine. And interestingly, it displays the data quite quickly. It's shareware, but not open source, so I don't know what it's doing. I'm friends with the person who distributes it, but he didn't write it, and the programmer is long gone into the wind. Therefore, in the last few days, I've added plotting to my C3dReader form. That's all working fairly well, but I may tweak the plotting speed a bit more.

    However, the reporting of the actual data has always been slow, especially for the "analog" channels, which can range up to 40,000 points of data. This is actually either EMG or force-plate data, which is somewhat different from the IR coordinate data, but it's also in these C3D files.

    And yes, I suspect Dex is correct that it's the "good old Format$" that's probably more of my problem than loading up the textbox. I'll be looking into that.

    Many Thanks!
    Y'all have my mind going in many different directions (but maybe that's a good thing).

    Best Regards,
    Elroy

    EDIT1: Also, none of what I do is "real-time". The software that does the mocap (motion capture) does display the markers on a screen in real time. It also allows a dragging of the 3D screen to get any perspective you want on the markers.

    Name:  markers.jpg
Views: 475
Size:  21.0 KB

    That software has a "record" button which then creates one of these C3D files. (I'm leaving out a few steps, that that's okay.) And then, it's these C3D files that I pick up and subsequently process.
    Last edited by Elroy; Jul 7th, 2017 at 03:22 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  19. #19
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    Said a bit differently, I certainly don't refill this textbox if/when the form is resized.
    Elroy, if you were doing that, we'd have to bar you from any programming forum.

    If the textbox/rtb isn't being filled while in the process of plotting, then ignore my previous posts. Otherwise, it is clear that doing so is taking a bit of hit in the thread's ability to plot faster, as would any additional code. And to negate that speed bump -- come up with a faster way of appending to the control or, as I was suggesting, just don't do it -- include just the most recent data in the textbox/rtb, for information only. Thoughts come to mind of displaying every record in a database in a grid control when it isn't necessary.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  20. #20

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Quote Originally Posted by LaVolpe View Post
    Said a bit differently, I certainly don't refill this textbox if/when the form is resized.
    Elroy, if you were doing that, we'd have to bar you from any programming forum.
    Haha, I would hope so.

    However, if you look at the image of that guy in front of the paneled wall, you see many IR markers. Imagine they have labels. Maybe think LeftElbow, LeftKnee, etc. These are listed in a TreeView (along with lots of other stuff). The user can click on these labels to get the X,Y,Z through-time coordinates of each of those markers.

    When they click on different markers, the do re-fill that textbox. That's where the 2-to-4 second lag is a bit painful. If I could make that a bit more spiffy, my users would appreciate it.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  21. #21
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    Sounds almost like you might consider pre-processing the source data file to a better format that could allow searching/plotting more efficiently for you. Just throwing it out there, but possibly process the data file into an ADODB recordset? This would take more time at startup (progress bar could be useful), but could be significantly faster to respond to the user via your GUI. Also, there are several controls available for displaying data from recordsets. Just a thought. Most times user are ok with a little startup time instead of delays in run time.

    P.S. Thanx for the clarification. Not sure why I assumed real-time plotting was in play.
    Last edited by LaVolpe; Jul 7th, 2017 at 03:52 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  22. #22
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: RTB and Speed Issues

    I just tried using TOM to access properties of the RTB as follows, and it was very fast:

    Code:
        lo_Tom.TextDocument.Freeze
        For i = 1 To 40000
            lo_Tom.TextDocument.Range(&H7FFFFFF, &H7FFFFFFF) = Format$(i, "00000") & vbCrLf
        Next i
        lo_Tom.TextDocument.Unfreeze
    Check out this thread by Dilettante for examples on how to use TOM:

    http://www.vbforums.com/showthread.p...ode-Formatting

  23. #23

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Hmmm, not the worst of ideas LaVolpe. An Excel file would probably be more useful than an ADODB file though. But I actually already do that.

    Here's the problem. Even though these C3D files are somewhat a mystery to many, in the mocap community, everyone knows that these C3D files are the "fundamental" data files. If you were a typist/secretary, you'd think of DOC (or DOCX) files as your core data files. For mocap people, it's absolutely these C3D files. All hardware (and capture software) vendors produce these C3D files. They know they have to to be accepted in the community.

    My users use them to study the movements of children with handicaps. However, others use these things to study sports (from golf swings to hockey skating). It became quite popular in the movie industry for a while (Polar Express, Lord of the Rings, Avatar), but the CGI technology has taken over there.

    This particular C3dReader form is just one form of a much larger VB6 program. It's just a way for a user to quickly snoop at a C3D file that they're processing. It really works fairly well the way it is. I was just "in that form" so I thought I'd try and spiff it up a bit.

    I think I'm going with your ...

    Code:
    
        Dim i As Long
        '
        SendMessageW Text1.hWnd, WM_SETREDRAW, 0, ByVal 0&
        Text1.Text = ""
        For i = 1 To 40000
            SendMessageW Text1.hWnd, EM_SETSEL, &H7FFFFFFF, ByVal &H7FFFFFFF
            SendMessageW Text1.hWnd, EM_REPLACESEL, 0, ByVal StrPtr(Format$(i, "00000") & vbCrLf)
        Next
        SendMessageW Text1.hWnd, WM_SETREDRAW, 1, ByVal 0&
        Text1.Refresh
    
    ... approach to filling the Textbox (and using the regular textbox), and also your calculation of the pixel being filled for the plotting. That'll give me something to do for the afternoon, that is, if I ever pull myself out of splashing in these forums.

    Take Care,
    Elroy

    EDIT1: Ooookkkk, looking at dilettante's TOM approach.

    EDIT2: Hmmm, after some more study, I'm not sure the RichEd20.dll is going to buy me much. I'm now convinced that my slowdown is in the Format$() statement. If anyone's got any ideas on how to quickly format numbers with leading and following decimals, I'm listening. But I seriously doubt that's happening. Thank you though for looking into these things.
    Last edited by Elroy; Jul 7th, 2017 at 04:31 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  24. #24
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: RTB and Speed Issues

    The TOM post by Dilettante also shows the dramatic difference in timings when using TOM vs. using other methods of updating an RTB. IMHO if you are doing frequent updating/formatting of an RTB you should always use the TOM.

  25. #25
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    and also your calculation of the pixel being filled for the plotting.
    Don't. I figured it out & there is a built-in method, I was just using it incorrectly.

    To determine the pixel coordinate from the source point, in user-defined scalemode, use ScaleX/Y, but ensure you use it on the destination object. For example, I tried: ScaleX(x, vbUser, vbPixels) and got an error. That was because, ScaleX is the form's ScaleX method and the form was not in a custom scalemode. I needed it this way: picBox.ScaleX(x, vbUser, vbPixels) and bingo. Now you have an easier way to recognize duplicate plot points.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  26. #26

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Ahhhhh, THANK you, LaVolpe. That's HUGE.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  27. #27
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: RTB and Speed Issues

    Quote Originally Posted by Elroy View Post
    Ahhhhh, THANK you, LaVolpe. That's HUGE.
    Just don't use vbUser if the picbox scalemode isn't yet customized: error
    or better yet: picBox.ScaleX(x, picBox.ScaleMode, vbPixels) .. error averted

    I now wonder how many lines of my code, are out there floating around, where I've used the following:
    z = ScaleX(x, target.ScaleMode, vbWhatever)
    Kind of painful realization now knowing those will error if target is in user scalemode; should've been:
    z = target.ScaleX(x, target.ScaleMode, vbWhatever)
    At least over 99% of any such code knows the scalemode will never be vbUser. But I know I've got some out there where a generic class, for example, is passed an object and the scalemode is not guaranteed to not be vbUser.
    Last edited by LaVolpe; Jul 7th, 2017 at 05:10 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  28. #28

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: RTB and Speed Issues

    Okay, I've got my RTB replaced with a regular textbox, and making calls to fill it with SendMessageW and SendMessageW.

    It's clearly quicker than it was. I'm going to wrap up my improvements to this particular form, and possibly call it a day.


    Again, thanks to all (with a high-five to LaVolpe).

    Y'all Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  29. #29
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: [RESOLVED] RTB and Speed Issues

    Can I know what is the reason of changing a control 40000 times to show a single block of text?
    Of course that willl be slow.
    It must be something that I have to be missing.

  30. #30
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: [RESOLVED] RTB and Speed Issues

    Code:
    Private Sub Command1_Click()
        Dim i As Long
        Dim s() As String
        Dim iUb As Long
        Dim i2 As Long
        Dim iT1
        
        iT1 = Timer
        
        rtb.Text = ""
        rtb.Refresh
        
        ReDim s(1000)
        iUb = UBound(s)
        i2 = 0
        For i = 1 To 40000
            If i2 > iUb Then
                iUb = iUb + 1000
                ReDim Preserve s(iUb)
            End If
            s(i2) = Format$(i, "00000") & vbCrLf
            i2 = i2 + 1
        Next i
        
        ReDim Preserve s(i2)
        
        rtb.Text = Join(s, "")
        
        MsgBox Timer - iT1
    
    End Sub

  31. #31
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: RTB and Speed Issues

    Quote Originally Posted by Elroy View Post
    EDIT1: There's no getting around formatting my numbers though, as with the production code, there are multiple columns and it's important that they're nicely lined up.
    No sure if you were able to address this issue.
    Seems like most of the test times involve only 1 "col", just the number, eg, 05000.

    Again, I offer that a FlexGrid with CommandButtons (see post #11) would enable
    instantaneous updates, while simultaneously dealing with the multi-column alignment
    issue.

    EDIT-1:

    In addition, you could incorporate a MouseDown event on the chart that the user invokes
    as an area of interest to look at the "surrounding" raw data. Your app could determine
    the "requested" row (the X-Position), and put it in the middle visible row of the FG, with
    the prior-25 and following-25 data results also shown.

    No need for scrollbar at all. User just clicks areas of interest.

    Bingo.
    Instant results.

    EDIT-2:

    As a further enhancement, you could add a track line to each of your PBs that tracks
    the MouseMove of your cursor. You could make it such that if the user's cursor is in any of
    the 3 PB's, the track-lines would move in synch.

    Then, when user clicks the mouse, the MouseDown event is triggered and the FG would
    populate as suggested above, plus you could highlight the middle row by changing the
    CellBackColor of the middle row's cells to distinguish it from adjacent data.

    Name:  Elroy1.jpg
Views: 447
Size:  24.0 KB

    Note that in my image, the highlight wipes out the data. I did it in Paint, and the best
    I could do was to draw a yellow line. Nonetheless, I trust you get the idea.

    And yes, there wouldn't be a vertical scrollbar ..

    Spoo
    Last edited by Spooman; Jul 8th, 2017 at 06:01 AM.

  32. #32
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,412

    Re: RTB and Speed Issues

    Quote Originally Posted by Elroy View Post
    EDIT2: Hmmm, after some more study, I'm not sure the RichEd20.dll is going to buy me much. I'm now convinced that my slowdown is in the Format$() statement. If anyone's got any ideas on how to quickly format numbers with leading and following decimals, I'm listening. But I seriously doubt that's happening. Thank you though for looking into these things.
    I won't keep on this since you have found another (possibly better) solution, but since the post title is RTB speed issues, I thought I follow up in case anyone searching in the future stumbles across this thread.

    In my tests, the Format$ function is absolutely not the problem - printing the raw counter variable made almost no difference in speed vs. using Format$.

    Using TOM with Freeze/Unfreeze made a very significant difference though. Using your original code, filling the RTB took about 6 seconds, whereas using TOM with Freeze/Unfreeze only took about .6 seconds. So for anyone using the RTB with frequent updates/style modifications that are running too slowly, I recommend using TOM with Freeze+Unfreeze.

  33. #33

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: [RESOLVED] RTB and Speed Issues

    @Eduardo: At one point, I actually tried it similar to the way you suggest. I didn't do it exactly like you're doing it, as I just use string concatenation to build the string, and then set the entire string into the textbox. That didn't seem to go any faster than appending text directly to the textbox. It was then that I concluded that it must be the Format$() function causing the slowdown.

    Your method of using a string array, and then the Join statement might be an improvement on all the string concatenation I did. Actually, truth be told, I'll know exactly how many lines will be in the textbox before I even start, so I'd only need to ReDim once.


    @Spoo: I was just showing one column of numbers as a cut-down demo. Typically, there are several columns of numbers...

    Name:  Cols1.jpg
Views: 425
Size:  33.4 KB

    It's just important that those columns be nicely formatted.

    Also, I like your ideas about a track-line, but that's just more sophisticated than I want to get with it right now. Thanks though.


    @jpbro: I'm not questioning your results, but I thought I tried the TOM (using Freeze and Unfreeze) and didn't see any noticeable differences in the time. Maybe I should take another look.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  34. #34
    PowerPoster
    Join Date
    Feb 2017
    Posts
    4,997

    Re: [RESOLVED] RTB and Speed Issues

    Quote Originally Posted by elroy View Post
    @eduardo: At one point, i actually tried it similar to the way you suggest. I didn't do it exactly like you're doing it, as i just use string concatenation to build the string, and then set the entire string into the textbox. That didn't seem to go any faster than appending text directly to the textbox. It was then that i concluded that it must be the format$() function causing the slowdown.

    Your method of using a string array, and then the join statement might be an improvement on all the string concatenation i did. Actually, truth be told, i'll know exactly how many lines will be in the textbox before i even start, so i'd only need to redim once.
    lol!
    Last edited by Eduardo-; Jul 8th, 2017 at 10:35 AM.

  35. #35
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: [RESOLVED] RTB and Speed Issues

    Quote Originally Posted by Elroy View Post
    It's just important that those columns be nicely formatted.
    Also, I like your ideas about a track-line, but that's just more sophisticated than I want to get with it right now. Thanks though.
    No probs.

    You haven't mentioned the FlexGrid approach and it's speed benefit, so I'll assume you've
    got the speed issue solved. As for formatting, the FG provides so many opportunities ..
    forecolor, backcolor, to name just 2. But again, it was just food for thought.

    Spoo
    Last edited by Spooman; Jul 8th, 2017 at 12:09 PM.

  36. #36
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: [RESOLVED] RTB and Speed Issues

    @Spoo. Look at post #14 from DEXWERX regarding the flex grid. That may be a deciding factor -- worth the workarounds? Not confirming nor denying the comments, but the messenger is otherwise trustworthy
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  37. #37
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: [RESOLVED] RTB and Speed Issues

    Well there is also the option of a ListView in Virtual mode.

    Sure seems like a wacky thing to do though. Scrolling through 100K lines of stuff is a scenario a little hard to take seriously. Sure there are unreasonable users who will make claims it is necessary... and then never actually use the ability.

    Paging through the data makes more sense, but a virtual ListView can work as a compromise.

  38. #38

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: [RESOLVED] RTB and Speed Issues

    *shakes head* Maybe I should learn to let more stuff go.

    But here goes another justification.

    It's just a way for users to see what they've got. Think of one of those IR markers (best illustrated in post #18) moving through space in some way. And let's say we're measuring it at 60 hertz (60 times a second). And each time we measure it, we'll get a X distance from origin, Y distance from origin, and Z distance from origin.

    It's just nice to take one of these C3D files (which has this data in it), and see that a particular marker is moving the way we think it is, and to see the actual numbers. It absolutely helps a novice to this mocap stuff get their head around what's happening. And to have to page through the data would defeat the purpose.

    Or, said more arrogantly, it's the way I'd like to display the data, and it's also the way that other programs display the same type of data. Geez.

    Have A Nice Saturday,
    Elroy

    EDIT1: And I've also got macros built into an XLSM file that can read these C3D and place the data into Excel columns. For people who want to do more processing of this data, they can use that. The form I'm discussing in this thread is a down-and-dirty dump of sections of data found in one of these C3D files. That's all it is.
    Last edited by Elroy; Jul 8th, 2017 at 01:23 PM.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  39. #39
    Fanatic Member Spooman's Avatar
    Join Date
    Mar 2017
    Posts
    868

    Re: [RESOLVED] RTB and Speed Issues

    LaVolpe

    Look at post #14 from DEXWERX regarding the flex grid. That may be a deciding factor -- worth the workarounds? Not confirming nor denying the comments, but the messenger is otherwise trustworthy
    Yes, and no ,,,

    Yes, I did notice it .. Thanks. It so happens that I was not aware of that limitation.

    No, in that my subsequent posts suggested using a FG with only 50 rows (or however many would fit on
    his form). No scrollbar used, rather the FG would be populated only with "rows of interest", repopulated
    at user "demand" .. using MouseDown over the chart (with or without the track-bar).

    As dilletante has also opined, necessitating the user to scroll thru thousands of lines of data doesn't
    strike me as being "user friendly", especially as no "tie-in-to the chart" is provided. OK, so I'd know
    I'm looking at datapoint 12,652 .. but where the heck is it on the chart?

    EDIT:

    Elroy

    ,,, it's the way I'd like to display the data
    I guess I'm as passionate about the FG.
    So, we're even ..

    Spoo
    Last edited by Spooman; Jul 8th, 2017 at 03:11 PM.

  40. #40

    Thread Starter
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,853

    Re: [RESOLVED] RTB and Speed Issues

    Hey Spoo,

    We're good.

    And I've also used the FlexGrid to good advantage elsewhere. In fact, I've worked up procedures to make the thing editable (overlaying textboxes and/or comboboxes).

    I'm really just trying to call this one done, at least for the time being.

    Take Care,
    Elroy
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

Page 1 of 2 12 LastLast

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