Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here's how i do it

char tmp[0x7FFF] = {0};
LRESULT length = SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0);
SendMessage(hWnd, WM_GETTEXT, length+1, (LPARAM)(void*)tmp);


the problem is when i open a large file i'm talking about maybe a 20mb text file, i can't seem to capture the text anymore. i know it's because the text of the 20mb file is larger than my char size. i think the max size of a char size is 0x7FFF.

what is the correct way to do it?

my goal is to capture the text and edit them.


--------------------------

this is just a follow up from what you guys gave me

ok i tried

char * tmp = new char[20*1024];
LRESULT length = SendMessage(hwndChild, WM_GETTEXTLENGTH, 0, 0);
SendMessage(hwndChild, WM_GETTEXT, length+1, (LPARAM)(void*)tmp);

and i got a bunch of characters which were 0xCC in value....

i tried

char tmp[0x7FFFFFFF] = {0};
LRESULT length = SendMessage(hwndChild, WM_GETTEXTLENGTH, 0, 0);
SendMessage(hwndChild, WM_GETTEXT, length+1, (LPARAM)(void*)tmp);


the compiler prevented me to compile it because it exceeds to gig, it tried removing 2 0xFF but i got a stack over flow....


i tried

std::string tmp;
LRESULT length = SendMessage(hwndChild, WM_GETTEXTLENGTH, 0, 0);
SendMessage(hwndChild, WM_GETTEXT, length+1, (LPARAM)(void*)tmp);


i got an error: error C2440: 'type cast' : cannot convert from 'std::string' to 'void *'

-------------------------

@richard
i do not wish to load anything, i just want to grab what's being displayed on the window. if my method is wrong please teach me how to do it properly. I also didn't understand what you mean by edit as the users scroll through it. is there a method to grab the content of what a user currently views on the window and not the entire window content?

To be more clear, for example i opened a fresh notepad. First it's empty and has a window title of "Untitled - Notepad". I will then press random keys on my keyboard for a whole day/week/month. Then i run my program. The program should be able to read whats on the notepad, find all acceptable english words, and display them as bold or different color on the same "Untitled - Notepad" window.
Posted
Updated 8-Jan-10 1:35am
v3

The maximum allowed size is about 0x10000 times the number you indicate, as you may easily verify with the code:
char a[0xFFFFFFFF];

That makes the compiler reporting the following error:

error C2148: total size of array must not exceed 0x7fffffff bytes

:)
 
Share this answer
 
v2
Do you REALLY have to use such a huge c-style character array AND put it on the stack?!

You'll be much better off using std::string.
 
Share this answer
 
I ran a simple test program which did this:

char * c = new char[20*1024];

It ran fine. What makes you think a char array can only be 0x7FFF in size ?
 
Share this answer
 
For an array of this size you should be using heap or static memory. Trying to allocate such an array on the stack is bound to cause problems.

I also wonder why you need to load all this text into a Window (using more resources) and then copy it into an array to edit it (so now using 2 x 2G). Why not use an Edit Window in the first place, or read parts of the file, display in the Window and edit as the user scrolls through it?
 
Share this answer
 
I think this is the answer EM_STREAMOUT or EM_GETSELTEXT. Thanks for everyone who tried though. =)

I haven't coded anything with it...still going to try it out.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900