在一个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
 ....
}

解决方案 »

  1.   

    NOTIFY_HANDLER(IDC_LISTCTRL1, HDN_ITEMCLICK, OnClickToSort)不行么?
      

  2.   

    NOTIFY_HANDLER
    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.
      

  3.   

    这个方法我以及尝试了,不行的。
    HDN_ITEMCLICK消息的lParam是一个NMHEADER 指针结构,而NOTIFY_HANDLER宏要求的是LPNMHDR结构,这样其信息量就丢失了,影响操作。
    如果是 NOTIFY_HANDLER(IDC_MYCTL, HDN_ITEMCLICK, OnClick)类型,则编译器Link时会报错,搞不明白。有没有别的好办法解决(在atl中实现)