Solved

RichTextBox & Huge files

Posted on 2004-09-17
9
326 Views
Last Modified: 2010-04-24
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
0
Comment
Question by:delphi112497
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
9 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 12092198
I think that is not possible in most cases. RTF files have some "header" information including styles, you can't divide an RTF file as easy as a text file. It is similar to divide a HTML file, it also contains some header information.
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.
0
 

Author Comment

by:delphi112497
ID: 12092783
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 :(

0
 

Author Comment

by:delphi112497
ID: 12092799
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 ?
0
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

 
LVL 16

Expert Comment

by:nonubik
ID: 12100011
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.
0
 

Author Comment

by:delphi112497
ID: 12120099
nonubik,

isn't CWnd from MFC ? ... how can I do this with VC NET ?

thanks!
0
 
LVL 16

Accepted Solution

by:
nonubik earned 500 total points
ID: 12121772
I thought you don't use managed code. MFC can be used in VC++.NET as unmanaged code.
With managed code, you can use the VScrollBar class along with Maximum property (to set the range) and Value (to set the position).
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question