EM_GETLINE错误C ++从文本框中获取最后一行 [英] EM_GETLINE error C++ Get last Line from Textbox

查看:115
本文介绍了EM_GETLINE错误C ++从文本框中获取最后一行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在EM_GETLINE上有一个小问题. 我有一个文本框,我想从中提取文本.该框始终保持更新(这是一个日志文件,然后不断更新,最后一条消息位于底部). 我只想要最后一行.

I'm having a minor problem with EM_GETLINE. I have a textbox I want to extract the text from. The box keeps updating all the time (it's a log file thet keeps updating, last message at the bottom). All I want is that very last line.

我的代码:

        HWND hwnd = (HWND)0x00020A72;
 TCHAR param[1000];
 char display[1000];
 LONG lResult;
 lResult = SendMessage( hwnd, WM_GETTEXT, 500, (LPARAM)param);
 //lResult = SendMessage( hwnd, EM_STREAMOUT, SF_RTF, (LPARAM)param);
 //lResult = SendMessage( hwnd, EM_GETLINE, 1, (LPARAM)param); 
 wcstombs(display, param, 1000);

 printf( " %s\n", display );

如您所见,我已经尝试了WM_GETTEXT(有效).使用GETLINE时,它可以很好地编译(VS2010express),但会返回垃圾.

As you can see I've tried WM_GETTEXT (that works). When using GETLINE it compiles nice (VS2010express) but returns rubbish.

真的很感谢您的帮助. 感谢您的收听.

Would be really gratful for help. Thanks for listening.

推荐答案

此窗口属于另一个进程,对吗?我可以看到您对窗口句柄进行了硬编码.不能确定该消息是否自动跨进程边界封送,只有系统消息是(WM_Xxx< 0x400).

This window belongs to another process, right? I can see you hard-coded the window handle. Not so sure that message is automatically marshaled across process boundaries, only the system message are (WM_Xxx < 0x400).

您自己编组它需要OpenProcess,VirtualAllocEx来分配缓冲区,WriteProcessMemory来初始化它,SendMessage,ReadProcessMemory来读取缓冲区.加上清理.

Marshaling it yourself requires OpenProcess, VirtualAllocEx to allocate the buffer, WriteProcessMemory to intialize it, SendMessage, ReadProcessMemory to read the buffer. Plus cleanup.

这篇关于EM_GETLINE错误C ++从文本框中获取最后一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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