delphi112497
asked on
RichTextBox & Huge files
I want to load huge files into a read-only RichTextBox. The problem is RichTextBox uses too much memory and will eat off all the system-resources if I try to load a 400MB file.
What I was thinking of doing is the following:
- When one opens the 400MB file, the vertical scroll-bar of the RichTextBox updates itself to reflect the real size of the file
- Load the first 10MB chunk of the 400MB file to the RichTextBox
- Set the RichTextBox Vertical Scrollbar to reflect the actual size of the file (400 MB) rather than the loaded 10MB's.
- When the user moves the scroll-bar, the corresponding 10MB chunk will be read from the file and displayed in the RichTextBox
This aproach, will actually handle extremely huge files in a RichTextBox and will require very little memory to do so.
The problem is this is my first time using VC++ NET and I have no idea on how to do this.
Can someone please help me ?
Please provide a working example.
Thanks
What I was thinking of doing is the following:
- When one opens the 400MB file, the vertical scroll-bar of the RichTextBox updates itself to reflect the real size of the file
- Load the first 10MB chunk of the 400MB file to the RichTextBox
- Set the RichTextBox Vertical Scrollbar to reflect the actual size of the file (400 MB) rather than the loaded 10MB's.
- When the user moves the scroll-bar, the corresponding 10MB chunk will be read from the file and displayed in the RichTextBox
This aproach, will actually handle extremely huge files in a RichTextBox and will require very little memory to do so.
The problem is this is my first time using VC++ NET and I have no idea on how to do this.
Can someone please help me ?
Please provide a working example.
Thanks
ASKER
jaime, i don't really need an RTF control for this, and since I'm completely new to .NET, don't know of any other control similar to a simple TextBox :(
ASKER
lol, just found my simple textbox control - TextBox(); :)
Ok, so using a textbox is exactly what I want.
Now, how can I go ahead and do this ?
Ok, so using a textbox is exactly what I want.
Now, how can I go ahead and do this ?
What you have to do is to get the textbox hWnd, then to play with its scrollbar. CWnd class provides SetScrollRange() and SetScrollPos() methods that enable you to do what you need.
ASKER
nonubik,
isn't CWnd from MFC ? ... how can I do this with VC NET ?
thanks!
isn't CWnd from MFC ? ... how can I do this with VC NET ?
thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But still think it is not impossible, you have to parse all the header and store it in memory, then you have to "chop" your file but not in an arbitrary point, you have to cut it at least at the beginning of a paragraph. Then you have to load the header first and then the portion you want in the control.
A better aproach I have used in the past with RTF files is to divide it manually (with an editor), and make the scrollbar trick. Just load the "section" you want and make the scrollbar appear like you have loaded the whole file.
Good luck,
Jaime.