在一个Dialog上放有一个有标题的listview控件,需要响应用户点击listview上的标题兰来对其item进行排序,即响应CHeaderCtrl的HDN_ITEMCLICK消息。
但是我现在是在ATL的工程中来实现的,映射消息与MFC有所区别,谁知道如何来在Dialog上响应这个消息的办法??CMyDialog:public CDialogImpl<CMyDialog>
{
....
BEGIN_MESSAGE_MAP(CMyDialog)
MESSAGE_HANDLER(..)
NOTIFY_HANDLER(..)
....
END_MESSAGE_MAP
....
}
但是我现在是在ATL的工程中来实现的,映射消息与MFC有所区别,谁知道如何来在Dialog上响应这个消息的办法??CMyDialog:public CDialogImpl<CMyDialog>
{
....
BEGIN_MESSAGE_MAP(CMyDialog)
MESSAGE_HANDLER(..)
NOTIFY_HANDLER(..)
....
END_MESSAGE_MAP
....
}
解决方案 »
- 一个前人未解决的问题:VC串口编程DCB.fparity设置失败
- 调用CFileDialog SaveDlg出错
- 我用VC一个程序,编译中遇到很多奇怪的语法错误,特来提问,奉上100分!!
- 怎么添加一个子项目作为树控件的第一个子项目
- 提示LINK : fatal error LNK1104: cannot open file "as.lib" 是怎么回事 怎么解决
- 怎么从ThreadId得到Thread Handle?大家不要说OpenThread啊,我要求的是98下面也可以使用.
- 个位大哥谁能给我一个winpacp的教程或是教教我怎么样用它
- 急~如何用setcolumn实现对已存在列表的列表名进行修改??
- 请教:关于VC下的回车键?
- 學習API的好方------正學API的進來
- *mciSendCommand如何换音频文件(关闭1.MIDI打开2.MIDI)---我的程序老是进入死循环( 有源码)
- 可否在类中创建线程
This macro defines an entry in a message map. NOTIFY_HANDLER maps a WM_NOTIFY message to the specified handler function, based on the notification code and the control identifier.NOTIFY_HANDLER(
id,
code,
func)
Parameters
id
[in] The identifier of the control sending the message.
code
[in] The notification code.
func
[in] The name of the message-handler function.
Res
For example:class CMyClass : ...
{
public:
... BEGIN_MSG_MAP(CMyClass)
NOTIFY_HANDLER(IDC_MYCTL, NM_CLICK, OnClick)
...
END_MSG_MAP() // When a CMyClass object receives a WM_NOTIFY
// message identified by IDC_MYCTL and NM_CLICK,
// the message is directed to CMyClass::OnClick
// for the actual processing.
LRESULT OnClick( ... )
{ ... }};Any function specified in a NOTIFY_HANDLER macro must be defined as follows:LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);The message map sets bHandled to TRUE before NotifyHandler is called. If NotifyHandler does not fully handle the message, it should set bHandled to FALSE to indicate the message needs further processing.Always begin a message map with BEGIN_MSG_MAP. You can then declare subsequent alternate message maps with ALT_MSG_MAP. The END_MSG_MAP macro s the end of the message map. Every message map must have exactly one instance of BEGIN_MSG_MAP and END_MSG_MAP.In addition to NOTIFY_HANDLER, you can use MESSAGE_HANDLER to map a WM_NOTIFY message without regard to an identifier or code. In this case, MESSAGE_HANDLER(WM_NOTIFY, OnHandlerFunction) will direct all WM_NOTIFY messages to OnHandlerFunction.
HDN_ITEMCLICK消息的lParam是一个NMHEADER 指针结构,而NOTIFY_HANDLER宏要求的是LPNMHDR结构,这样其信息量就丢失了,影响操作。
如果是 NOTIFY_HANDLER(IDC_MYCTL, HDN_ITEMCLICK, OnClick)类型,则编译器Link时会报错,搞不明白。有没有别的好办法解决(在atl中实现)