Locked CLIstView

  • Thursday, April 12, 2012 3:25 PM
     
     

    Hi,

    i am using CListview class, and  i need to use 

    OnNMDblclk(NMHDR *pNMHDR, LRESULT *pResult)   this  function give me information of the item 

    OnNMClick(NMHDR *pNMHDR, LRESULT *pResult) this function must edit the sub-item list 

    i supposed i must use OnLButtonDown  but i always get the  OnNMClick and give mi the edit sub-item 

    Is there any method to differentiate whether the User has clicked once or twice.

    thanks for help 


    Gio

All Replies

  • Thursday, April 12, 2012 6:33 PM
     
     

    In order to differentiate a simple click from a click that maybe will be followed quickly by second click, you can try the following approach. When you receive a click (OnNMClick), create a timer using SetTimer having a timeout obtained by GetDoubleClickTime plus few milliseconds. When the interval expires (OnTimer), stop the timer with KillTimer and start your editing flow, since this is a simple click. But if you receive double click (OnNMDblClk), then stop the timer and show information about the item.

    By the way, if you use LVS_EDITLABEL style, then the System will help you more by sending LVN_BEGINLABELEDIT notification.




    • Edited by Viorel_MVP Thursday, April 12, 2012 6:42 PM
    •  
  • Thursday, April 12, 2012 8:35 PM
     
     

    thanks for your answer, you gave me a good idea, i will try it,
    but I still have a question, how clistview handles the click and dbclick?


    Gio

  • Friday, April 13, 2012 12:35 AM
     
     Answered

    but I still have a question, how clistview handles the click and dbclick?


    You can see this for yourself by clicking in the right pane of Windows Explorer.  Click selects a file, double click opens the file. This is in accord with the Windows user interface guidelines.

    What you propose to do is the exact opposite and will annoy users. You should not perform a modal action (like open for edit) on a click if the same target also is expected to do something else on double-click.   You should consider reversing your planned user interface design.