I've got several little "utility" programs where I have a need to display a VERY long single line of text (sometimes > 1 million characters). They're lines out of XML files, and, other than some HTML tags, they're always numbers. So, if I'm restricted to ANSI, that's not a problem.
I've discussed this before, and I'm currently using the SCIVB2.OCX Scintilla control to get this done. However, I'm not terribly happy with that control. If I could do it with something more akin to a regular VB6 TextBox, that'd be better.
Also, I don't need a horizontal scrollbar, as all I'd ever be doing with the data is possibly putting it into the clipboard, and I can do that with a button (so long as this TextBox has a way to "select all"). I suppose if I had the option for a horizontal scrollbar, I wouldn't turn it down. Actually, a runtime toggle for the horizontal scrollbar would be very nice.
Ideally, I'd like the source code to a custom UC that got this done.
Just as an FYI, I also put a post in Krool's Common Controls to see what it'd take to have his TextBoxW accomplish this (and it currently doesn't).
For anyone who might like to play around with this, I've attached a zipped TXT file with a VERY long line in it. If you want to get that line in the clipboard, I'd recommend using Notepad++ (as Windows Notepad also chokes on these things).
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.
Maybe I didn't understand from your description but why would you want to put a single long line of text in a TextBox if you don't want to scroll through or edit it?
I don't need a horizontal scrollbar, as all I'd ever be doing with the data is possibly putting it into the clipboard, and I can do that with a button (so long as this TextBox has a way to "select all").
Of course, who is going to read a million characters in a textbox?
Cut the data at for example 10,000 characters and store the actual whole data in a variable.
If the user selected all, you can know that, and then copy to the clipboard the data from the variable. The built-in copy won't work, or you'll have to subclass it.
Maybe I didn't understand from your description but why would you want to put a single long line of text in a TextBox if you don't want to scroll through or edit it?
You didn't mis-read. There are a few different cases where I use the SCIVB2.ocx control for this:
Just showing a line where I'm also reporting the count of numbers in the line, possibly also reporting min-and-max values for the numbers.
Auto-generating the lines, where I might manually paste them back into an XML file I'm working with in NP++.
Just sometimes showing the line(s) from an XML file where I'm massaging certain things.
When writing some utility program that auto-edits these lines (such as maybe adding 10 to every 3rd number), it's just nice to see the line that's being editing, just for verification.
I tried Krool's RichTextBox and it didn't work. However, I didn't try the standard RTB. I'll try it in a moment and see what happens for me.
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.
I haven't tried Krool's TextBox but if it's not based on the newer "MsftEdit.dll" like mine then it's not going to work. You could continue using your Scintilla control or you could take a look at my work (feel free to change it to suit your purposes). I was just curious to test this very long line of characters and it worked fine.
I tried RichTx32.ocx, and it works, sort of. I can paste the line in, but I can't scroll to the end of it no matter what I try. However, if I do a ctrl+A then ctrl+C, and then go to Notepad++, and paste, it pastes the complete line. So, apparently the RTB can accept the line. It just can't show it to us.
Regarding Krool's RichTextBox, it truncates the line at 65536 (&h10000) characters. Apparently Krool has set some buffer at that length.
VanGogh, I'll test yours now.
Just as a further FYI, even though I won't be scrolling through the line, it would be nice to be able to tap my "End" key and see the end of it (for validation purposes).
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.
I just tried yours (both the richTest1 and richTest2 in your demo), and they're both truncating the long line at 32768 (&h8000) characters.
I also tried your MSFTEDIT50W constant and got the same results. And your OFFICERICHEDIT60W constant didn't work at all.
Last edited by Elroy; Sep 14th, 2024 at 03:44 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.
Have you tried the code snippet I posted above (post #2)? I just slapped that in "Form_Click" from the same demo... It definitely writes 1 million "A" characters and one "Z" at the end in the single line RichTextBox at the top!
I also tried your MSFTEDIT50W constant and got the same results. And your OFFICERICHEDIT60W constant didn't work at all.
MSFTEDIT50W is the default one and for OFFICERICHEDIT60W you need to have Microsoft Office installed (and copy its "riched20.dll" file in your App.Path folder) because that DLL is not shipped with Windows but it's supposed to be more feature-rich!
Last edited by VanGoghGaming; Sep 14th, 2024 at 03:59 PM.
Ok, that's working. I see you've got a MaxLength property.
Interestingly, it worked, but when I tapped the "End" key, it was doing some funky things with ForeColor and BackColor. Not sure what that was about. The screenshot is with MY test line pasted into it.
But this might be workable. I see that you're using CreateWindowEx to create the rich text window.
I'll play around with this some more though, possibly seeing if it can be worked into a custom UC.
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.
Interestingly, it worked, but when I tapped the "End" key, it was doing some funky things with ForeColor and BackColor. Not sure what that was about.
Hahaha, well it's a demo isn't it? It's supposed to showcase some features, in this case when you select a piece of text it will randomly change the background and foreground colors!
But this might be workable. I see that you're using CreateWindowEx to create the rich text window.
I'll play around with this some more though, possibly seeing if it can be worked into a custom UC.
Yeah, "CreateWindowEx" is the backbone of all such controls created from scratch out of Microsoft DLLs. Initially I slapped it directly on the form and it worked fine except it had no control whatsoever over when it got or lost focus and also Tab navigation wouldn't work. Then I learned I should've implemented the "IOleInPlaceActiveObject" interface and was like, that's more than I've bargained for! So I ended up creating a PictureBox container for it at runtime and everything was magically fixed.
Feel free to put it in a full-fledged UC but I'm not sure it's worth the trouble since the runtime PictureBox does exactly the same thing...
Hmm, I got the bright idea of trying to send a EM_SETLIMITTEXT message to a regular VB6 TextBox, but that didn't work at all. Here's the code I used:
Code:
Option Explicit
Private Declare Function SendMessageVal Lib "user32" Alias "SendMessageW" (ByVal hWnd As Long, ByVal uMsg As Long, ByVal wParam As Any, ByVal lParam As Any) As Long
Private Sub Form_Activate()
Const EM_SETLIMITTEXT As Long = &HC5&
SendMessageVal Text1.hWnd, EM_SETLIMITTEXT, 3000000, 0&
End Sub
When I pasted a long line into the Text1 TextBox, it just hung. I guess the windows "Edit" control just can't do 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.
If IOleInPlaceActiveObject is not used with the API created control, Validate event won't fire for the previous control that just lost focus when the user clicks on the API created one, and also Tab and navigation keys. I don't know if putting it on a PictureBox would solve this, never tried it.
Good to know! I think of the runtime PictureBox as the poor man's IOleInPlaceActiveObject implementation!
I haven't tested Validate events for previous controls but the Tab navigation works beautifully and that's what annoyed me the most. Also the PictureBox comes in handy for a host of other properties that it can lend to the RichTextBox (such as BackColor, Enabled, Font, ForeColor, TabIndex, Tag, Visible).
Turning it all into a custom UC will probably accomplish the same thing, as that's about the same as just putting it onto a PictureBox.
I've got other things going on, but I'll eventually get to this. Probably won't be a full-blown RTF control though, as that's not what I need.
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.
Regarding Krool's RichTextBox, it truncates the line at 65536 (&h10000) characters. Apparently Krool has set some buffer at that length.
Elroy,
65536 is the default limit for every rich edit if the .MaxLength property ( EM_EXLIMITTEXT for rich edit) is set to 0.
And 0 is the default for the VBCCR RichTextBox.
So, to change it set .MaxLength to 1M or more..
And to others: the VBCCR RichTextBox is using msftedit.dll and fallbacks to riched20.dll if msftedit.dll does not exist.
the hex-editors around they can read huge files. but that doesn't mean its all in memory.
the same can be done here. u only show "-page height to +page height" or something, so when u move down/up (or left/right) it will be updated accordingly.
its not much difference from my visual novel game where I have 12 million letters (total or 2 million words), I dont show everything at once.
think of "page" each page can show "X" amount. and u go from there.
Elroy,
65536 is the default limit for every rich edit if the .MaxLength property ( EM_EXLIMITTEXT for rich edit) is set to 0.
And 0 is the default for the VBCCR RichTextBox.
So, to change it set .MaxLength to 1M or more..
And to others: the VBCCR RichTextBox is using msftedit.dll and fallbacks to riched20.dll if msftedit.dll does not exist.
Krool,
This is good to know. I might use yours and do more testing with the EM_EXLIMITTEXT property. It seems like this might be an excellent solution, and I definitely like the idea of it already being a custom UC.
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.
It looks like "EM_EXLIMITTEXT" is better than "EM_SETLIMITTEXT" since it also increases Paste limits (not only the limit of text entered programmatically).