我要让我对话框上的ListCtrl响应NM_CLICK和NM_CUSTOMDRAW消息,怎么做啊??

解决方案 »

  1.   

    在mfc中只要ON_NOTIFY ( NM_CUSTOMDRAW, IDC_MY_LIST, OnCustomdrawMyList )就行,sdk中怎么做?
      

  2.   

    NM_CLICK后控件会向系统发送WM_NOTIFY消息This technical note provides background information on the new WM_NOTIFY message and describes the recommended (and most common) way of handling WM_NOTIFY messages in your MFC application.Notification Messages in Windows 3.xIn Windows 3.x, controls notify their parents of events such as mouse clicks, changes in content and selection, and control background painting by sending a message to the parent. Simple notifications are sent as special WM_COMMAND messages, with the notification code (such as BN_CLICKED) and control ID packed into wParam and the control’s handle in lParam. Note that since wParam and lParam are full, there is no way to pass any additional data — these messages can be only simple notification. For instance, in the BN_CLICKED notification, there’s no way to send information about the location of the mouse cursor when the button was clicked.When controls in Windows 3.x need to send a notification message that includes additional data, they use a variety of special-purpose messages, including WM_CTLCOLOR, WM_VSCROLL, WM_HSCROLL, WM_DRAWITEM, WM_MEASUREITEM, WM_COMPAREITEM, WM_DELETEITEM, WM_CHARTOITEM, WM_VKEYTOITEM, and so on. These messages can be reflected back to the control that sent them. For more information, see TN062: Message Reflection for Windows Controls.Notification Messages in Win32For controls that existed in Windows 3.1, the Win32 API uses most of the notification messages that were used in Windows 3.x. However, Win32 also adds a number of sophisticated, complex controls to those supported in Windows 3.x. Frequently, these controls need to send additional data with their notification messages. Rather than adding a new WM_* message for each new notification that needs additional data, the designers of the Win32 API chose to add just one message, WM_NOTIFY, which can pass any amount of additional data in a standardized fashion.WM_NOTIFY messages contain the ID of the control sending the message in wParam and a pointer to a structure in lParam. This structure is either an NMHDR structure or some larger structure that has an NMHDR structure as its first member. Note that since the NMHDR member is first, a pointer to this structure can be used as either a pointer to an NMHDR or as a pointer to the larger structure depending on how you cast it.In most cases, the pointer will point to a larger structure and you’ll need to cast it when you use it. In only a few notifications, such as the common notifications (whose names start with NM_) and the tool tip control’s TTN_SHOW and TTN_POP notifications, is an NMHDR structure actually used.The NMHDR structure or initial member contains the handle and ID of the control sending the message and the notification code (such as TTN_SHOW). The format of the NMHDR structure is shown below:typedef struct tagNMHDR {
        HWND hwndFrom;
        UINT idFrom;
        UINT code;
    } NMHDR;For a TTN_SHOW message, the code member would be set to TTN_SHOW.Most notifications pass a pointer to a larger structure that contains an NMHDR structure as its first member. For instance, consider the structure used by the list view control’s LVN_KEYDOWN notification message, which is sent when a key is pressed in a list view control. The pointer points to an LV_KEYDOWN structure, which is defined as shown below:typedef struct tagLV_KEYDOWN {
        NMHDR hdr;   
        WORD wVKey;  
        UINT flags;  
    } LV_KEYDOWN;Note that since the NMHDR member is first in this structure, the pointer you’re passed in the notification message can be cast to either a pointer to an NMHDR or a pointer to an LV_KEYDOWN.Notifications Common to All New Windows ControlsSome notifications are common to all of the new Windows controls. These notifications pass a pointer to an NMHDR structure.Notification code Sent because 
    NM_CLICK User clicked left mouse button in the control 
    NM_DBLCLK User double-clicked left mouse button in the control 
    NM_RCLICK User clicked right mouse button in the control 
    NM_RDBLCLK User double-clicked right mouse button in the control 
    NM_RETURN User pressed the ENTER key while control has input focus 
    NM_SETFOCUS Control has been given input focus 
    NM_KILLFOCUS Control has lost input focus 
    NM_OUTOFMEMORY Control could not complete an operation because there was not enough memory available 
      

  3.   

    你可以截取WM_NOTIFY消息,
    其中
    WM_NOTIFY 
        idCtrl = (int) wParam; 
        pnmh = (LPNMHDR) lParam; Parameters
    idCtrl 
    Identifier of the common control sending the message. This identifier is not guaranteed to be unique. An application should use the hwndFrom or idFrom member of the NMHDR structure (passed as the lParam parameter) to identify the control. 
    pnmh 
    Pointer to an NMHDR structure that contains the notification code and additional information. For some notification messages, this parameter points to a larger structure that has the NMHDR structure as its first member.