Thread: CListCtrl & Double Click :: MFC

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348

    CListCtrl & Double Click :: MFC

    Hi.

    I am implemented a very simple MFC program without the powerful of ClassWizard.

    I added a CListCtrl listbox. Everything works as designed except for a double-click message handler. I cannot get the program to respond when the user double-clicks the listbox. I have tried different messages, but all failed.

    I would like to know, What message do you handler for double-click (left mouse button) on a CListCtrl that is not in a dialog box and was not implemented using ClassWizard.

    Thanks,
    Kuphryn

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    CListCtrl encapsulates a Listview common control. As with other common controls, look to WM_NOTIFY for specific notification messages. In the case of a double-click event, the message in question is NM_DBLCLK. Other useful notifications in this regard are similarly prefixed with 'NM_*'. It may also be worthwhile to read the sdk docs on the win32 listview common control for a complete list of all messages, macros, etc.

    Hope that helps.

    edit: as tempting as it is to insist that 'notifiction' is a real word, I accept that it's not.
    Last edited by Ken Fitlike; 10-19-2002 at 04:54 PM.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Okay. Thanks.

    I figured out the bug. The bug was a human-error, not an MFC error.

    I made an error during creation of the CListCtrl object.

    Here is the error.

    // Here is the incorrect creation code.
    -----
    m_LB_Box.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SORTASCENDING, CRect(0, 100, 100, 50), this, 1);
    -----

    Notice the "1" in the last parameter.

    // Here is the solution.
    -----
    m_LB_Box.Create(WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_SORTASCENDING, CRect(0, 100, 100, 50), this, IDC_LB_BOX);
    -----

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Structures within structures for a database
    By Holtzy in forum C Programming
    Replies: 2
    Last Post: 04-30-2008, 07:06 AM
  2. Copying 2-d arrays
    By Holtzy in forum C++ Programming
    Replies: 11
    Last Post: 03-14-2008, 03:44 PM
  3. C# Version of MFC CListCtrl
    By gotclout in forum C# Programming
    Replies: 6
    Last Post: 06-18-2007, 08:57 AM
  4. expected primary expression
    By mju4t in forum C Programming
    Replies: 2
    Last Post: 03-27-2007, 06:59 PM
  5. CListCtrl in Dialog Box & Select :: MFC
    By kuphryn in forum Windows Programming
    Replies: 0
    Last Post: 06-08-2002, 12:05 AM