tags:

views:

121

answers:

3

hi all

Is there any way to assign more memory for a Memo or RichEdit (if working with big files)

thanks

+5  A: 

Allocate memory with LocalAlloc and then give it to the edit control with the em_SetHandle message. You can handle the en_ErrSpace notification if the edit control requires more space. MSDN describes the process in the "About Edit Controls" article. It doesn't work on rich-edit controls, though; they don't store their data in a contiguous buffer like edit controls do.

Rob Kennedy
+4  A: 

Rather than load the whole file, wouldn't it be better to use the control as a 'window' to the data? Just load your data in chunks, loading more (and getting rid of some) as the user scrolls up or down.

Steve
+2  A: 

I would recommend switching to another edit control like SynEdit(it can load 80 mb of text file in few miliseconds).

delphigeist
That's hyperbole, as this would come close to the normal in-memory transfer rate of current PCs. There is no way to load files faster than the I/O bandwidth allows. However, SynEdit loads files into a `TStrings` object, which is quite fast (as long as the file is small enough to fit into the free physical memory of the system and the address space of the app). For larger files something like memory mapped files needs to be employed, which can of course be faster as it doesn't cause much I/O initially. But SynEdit could indeed be a better fit than `TMemo`.
mghie