问题描述
嗨。
在控件的窗口程序中是否有办法检测按钮或更改编辑控件内容等内容?
在我看过的所有例子中,从父母那里检测出类似的东西。
我能想到的一个显而易见的方法是定义一种新类型的消息,例如: / p>
#define WM_COMMAND_SENT(WM_USER + 0x0001)
并从中调用父母的窗口程序:
// ...
case WM_COMMAND:
SendMessage((HWND) lParam,WM_COMMAND_SENT,wParam,0);
休息;
//...
这样,在孩子的窗口过程中我只能检测到WM_COMMAND_SENT消息知道从wParam发送了什么通知。
然而,这似乎不是一个非常干净的解决方案。
有没有人知道更好的方法?
Hi.
Is there any way to detect things like the push of a button or changes to the content of an edit control, within the control's window procedure?
In all the exapmples I have seen, things like those are detected from the parent.
One obvious way I can think of would be defining a new type of message, like:
#define WM_COMMAND_SENT (WM_USER + 0x0001)
And to call it from the parent's window procedure:
//... case WM_COMMAND: SendMessage((HWND)lParam, WM_COMMAND_SENT, wParam, 0); break; //...
This way, in the window procedure of the child I can just detect the WM_COMMAND_SENT message and still know what notification was sent from wParam.
However, this doesn't seem a very clean solution.
Does anybody know a better way?
这篇关于Win32 API:从控件WindowProc中检测WM_COMMAND的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!