Thread: CListCtrl selection problem

  1. #1
    Registered User
    Join Date
    Sep 2003
    Posts
    87

    CListCtrl selection problem

    Hi.

    In my program I have a ListView control in report mode, which is associated with a CListCtrl object(MFC). I need to know which items are selected at a moment. Something like the function CListBox::GetSel().

    But it doesn't seem such a function to be available.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    Start with getting the position of the mouse pointer via GetCursorPos().

    Kuphryn

  3. #3
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    CListCtrl::GetFirstSelectedItemPosition()

    [Edit]
    Incase it's not obvious, the above is a link with example source.
    [/Edit]

    gg
    Last edited by Codeplug; 10-08-2004 at 02:06 PM.

  4. #4
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Use GetSelectedCount() to get the number of selected items. Then use GetFirstSelectedItemPosition() to get the first selected item. Then you use GetNextSelectedItem() to iterate through the selected items.

  5. #5
    Registered User
    Join Date
    Sep 2003
    Posts
    87
    Thank you for your answers!

    This solves my problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 11-07-2005, 11:34 PM
  2. searching problem
    By DaMenge in forum C Programming
    Replies: 9
    Last Post: 09-12-2005, 01:04 AM
  3. Bin packing problem....
    By 81N4RY_DR460N in forum C++ Programming
    Replies: 0
    Last Post: 08-01-2005, 05:20 AM
  4. half ADT (nested struct) problem...
    By CyC|OpS in forum C Programming
    Replies: 1
    Last Post: 10-26-2002, 08:37 AM
  5. Replies: 0
    Last Post: 02-05-2002, 07:44 PM