在使用ListCtrl时,怎样在LVS_ICON方式下,得到当前客户区显示的item范围?我用GetTopIndex和GetCountPerPage试了一下,好像只在LVS_REPORT方式下才有用。不知道另外有什么办法,请各位指教。

解决方案 »

  1.   

    试一试这个:CListCtrl::GetItemRect
    BOOL GetItemRect( int nItem, LPRECT lpRect, UINT nCode ) const;Return ValueNonzero if successful; otherwise zero.ParametersnItemThe index of the item whose position is to be retrieved.lpRectAddress of aRECT structure that receives the bounding rectangle. nCodePortion of the list view item for which to retrieve the bounding rectangle. It can be one of these values: LVIR_BOUNDS   Returns the bounding rectangle of the entire item, including the icon and label.
    LVIR_ICON   Returns the bounding rectangle of the icon or small icon.
    LVIR_LABEL   Returns the bounding rectangle of the item text. 
    Res
      

  2.   

    我现在的办法就是遍历所有的item,GetItemRect得到每个item的位置,然后判断在不在当前客户区内。但是这个办法效率实在是很低,不知道有没有好一点的办法?