WM_GETTEXT的帮助 [英] help with WM_GETTEXT

查看:105
本文介绍了WM_GETTEXT的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的操作方式

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);



问题是当我打开一个大文件时,我正在谈论一个20mb的文本文件,我似乎无法再捕获文本.我知道这是因为20mb文件的文本大于我的char大小.我认为char大小的最大大小为0x7FFF.

正确的方法是什么?

我的目标是捕获文本并进行编辑.


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

这只是你们给我的东西的跟进

好的,我尝试了



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);


我得到了一堆字符,它们的值是0xCC....

我试过了


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);



编译器阻止我进行编译,因为它超出了gig范围,它尝试删除2 0xFF,但是我得到了栈溢出....


我尝试了



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);



我收到一个错误:错误C2440:类型转换":无法从"std :: string"转换为"void *"

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

@richard
我不想加载任何东西,我只想获取窗口上显示的内容.如果我的方法有误,请教我如何正确执行.当用户滚动浏览内容时,我也不理解您的意思.有没有一种方法可以获取用户当前在窗口上查看的内容而不是整个窗口的内容?

为了更清楚一点,例如,我打开了一个新的记事本.首先,它为空,窗口标题为无标题-记事本".然后,我将按键盘上的整天/周/月的随机键.然后我运行我的程序.该程序应该能够读取记事本上的内容,找到所有可接受的英语单词,并在同一无标题-记事本"窗口上将它们显示为粗体或其他颜色.



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.

推荐答案

允许的最大大小约为您指定数字的 0x10000倍,您可以使用以下代码轻松进行验证:
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:

>错误C2148:数组的总大小不能超过 0x7fffffff 个字节
error C2148: total size of array must not exceed 0x7fffffff bytes


:)


您真的需要使用这么大的c样式字符数组并将其放在堆栈上吗?!

使用std::string会更好.
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.


我运行了一个简单的测试程序来做到这一点:

char * c =新的char [20 * 1024];

运行良好.是什么让您认为char数组的大小只能为0x7FFF?
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 ?


这篇关于WM_GETTEXT的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆