CListCtrl - Disable click on the null text below an icon/image.


Hello,

Can you tell me if there is any way by which i allow selection to happen only on the icon. I have created a custom list control derived from CListCtrl. I have no text, only images closely packed. I have set the text as null. For every icon/bitmap below each item, when I click in some 10 pixel range below the icon/bitmap. It gets clicked. I want to disable this click ... any clues 

please help

jupitor




Answer this question

CListCtrl - Disable click on the null text below an icon/image.

  • Dave Hewitt

    hi Martin,

    I dont get the event for my CListCtrl at all !! :(

    Can you send me the sample you have created jupitor_rule@yahoo.com

    Jupitor ....



  • GlennGraham

    Overwrite OnLButtonDown, do your own calculation. You can use the CListCtrl::HitTest function. If the returned value is not LVHT_ONITEMICON just exit. Otherwise call the default handler.

  • Binnerup

    Hi Martin,

    Thanks for the reply.

    This is what I had initially thought I would do ....

    I need to put the following check on one of the message handlers - 
            // Select the item the user clicked on.
            UINT uFlags;
            int nItem = HitTest(GetMessagePos(), &uFlags);
            if  (!(uFlags & (LVHT_ONITEMICON |LVHT_NOWHERE)))
            {
                return CListCtrl::Default();
            }

    I had planned to use the lbuttondown for the list control or even its container window. But I never get this event for the control, nor do the parents get this event... We get the message NM_CLICK (list view), at this point the item is alredy selected and it would be quite a bit to keep a track of which one was selected previously . I want a more an elegant approach to fix this problem ... Now, how do I disable the default processing for this event !! :( :(

    Regards
    Jupuitor



  • dundask

    This coce is correct and works in my OnLButtonDown handler perfect!

    Sure that the entry was placed in the message Map Its a message for the list control not for the parent of the list control!


  • ibis1

    Sent!

  • CListCtrl - Disable click on the null text below an icon/image.