如何发送由ON_NOTIFY处理的通知? [英] How to send a notification that's handled by ON_NOTIFY?

查看:1555
本文介绍了如何发送由ON_NOTIFY处理的通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在向自定义网格表的所有者发布LVN_ ITEMCHANGED。我知道如何使用PostMessage发送WM_用户消息(如下所示)

I'm trying to post a LVN_ ITEMCHANGED to my custom gridlist's owner. I know how to send a WM_ User message using PostMessage (as shown here)

::PostMessage( AfxGetMainWnd()->GetSafeHwnd(), WM_REFRESH, (WPARAM)pBuffer, (LPARAM)GetOutputIdx() );

当我使用相同的代码发送LVN_ITEMCHANGED消息时,

When I use this same code to send a LVN_ITEMCHANGED message though,

::PostMessage( AfxGetMainWnd()->GetSafeHwnd(), LVN_ITEMCHANGED, 0, 0);

似乎并未被

ON_NOTIFY(LVN_ITEMCHANGED, ..., ...)


$ b b

我在所有者类中。

I have in the owner class.

我错误地使用:: PostMessage发送Notify事件?

在通知消息和WM_前缀消息之间有区别,或者如何处理它们?

有人可以发布样本,如何正确发送消息吗?

Am I wrong to be using ::PostMessage to send a Notify event?
Is there a difference between Notify messages and WM_ prefix messages or how they're handled?
Can someone post a sample of how I would send the message properly?

提前感谢。

编辑

我找到了另一种解决方法。请参阅下面的答案。

Edit
I found another solution to the problem. See my answer below.

推荐答案

我发现我可以覆盖我的派生类中的消息处理程序,我的父控件只需在消息映射中使用此代码:

I found out that I could override the message handler in my derived class and pass the message on to my parent control simply by using this code in the message map:

ON_NOTIFY_REFLECT_EX(LVN_ITEMCHANGED, OnListItemChanged)

然后在OnListItemChanged中,我首先调用基类函数,然后返回FALSE。这将使消息毫不费力地反映到父类。

Then in OnListItemChanged, I first call the base class function then return FALSE. This causes the message to be reflected to the parent class effortlessly.

这篇关于如何发送由ON_NOTIFY处理的通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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