如何在“另一个"上设置文本win32 应用程序 [英] How to set text on "another" win32 application

查看:27
本文介绍了如何在“另一个"上设置文本win32 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 spy++ 并看到我拥有的控件具有与 spy++ 中的十六进制匹配的十进制数(当然在转换之后),并且我看到父窗口也匹配,因此我有 IntPtr 用于标签和 IntPtr 用于表单/窗口,但我的 SendMessage 无法更改目标应用程序中的文本.

另一种方法可能是执行类似这篇文章的操作,但是控件 ID 是什么以及如何获取它外部应用中文本框的SetText.Win32 API

我认为这里的 hWnd 需要是控件 hWnd,对吗?

SendMessageCall(hWnd, WM_SETTEXT, (IntPtr)value.Length, value);

我注意到获取文本正在运行

SendMessageCall(hWnd, WM_GETTEXT, (IntPtr)sb.Capacity, sb);

我注意到我得到了测试,看到了正确的值,设置了文本但它没有改变,然后使用 SendMessage 再次获取文本,这是新值,但应用程序仍然显示错误的值....嗯,我是否需要发送重绘消息,如果需要,代码是什么?

谢谢,院长

解决方案

您不发送窗口消息来强制重绘,而是调用 InvalidateRect(hWnd, NULL, TRUE).>

I am using spy++ and see that the control I have has the decimal that matches the hex(after conversion of course) in spy++ and I see the parent window matches as well so I have the IntPtr for a Label and IntPtr for the form/window but my SendMessage is not working to change the text in the target application.

Another approach may be may be to do something like this post but what is the control id and how do I get that SetText of textbox in external app. Win32 API

I assume the hWnd here needs to be the controls hWnd, correct?

SendMessageCall(hWnd, WM_SETTEXT, (IntPtr)value.Length, value);

I notice that getting the text IS WORKING

SendMessageCall(hWnd, WM_GETTEXT, (IntPtr)sb.Capacity, sb);

and I notice that I get the test, see the correct value, set the text yet it doesn't change and then get the text again using SendMessage AND it is the new value but the application still shows the wrong value....hmmm, do I need to send a repaint message maybe and if so, what is the code for that?

thanks, Dean

解决方案

You don't send a window message to force repaint, instead you call InvalidateRect(hWnd, NULL, TRUE).

这篇关于如何在“另一个"上设置文本win32 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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