home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / Chip_2002-02_cd1.bin / sharewar / apaths / APSOURCE.ZIP / LV_Help.c < prev    next >
C/C++ Source or Header  |  2001-03-26  |  1KB  |  60 lines

  1. /* LV_Help - March 26th, 2001
  2. **
  3. **      Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
  4. **
  5. **      This module contains functions to facilite simple ListView
  6. **      control manipulations.
  7. **
  8. **      Called:     list  = Handle to the ListView control to be used.
  9. **                  index = List item to be used (zero-based)
  10. **
  11. **      Returns:    TRUE upon success, or FALSE if an error exists.
  12. */
  13.  
  14.  
  15. #include "AppPaths.h"
  16.  
  17. extern int far LV_RowHit (HWND list)
  18. {
  19.     auto LV_HITTESTINFO     hit = { NIL };
  20.  
  21.     GetCursorPos   (&hit.pt);
  22.     ScreenToClient (list,&hit.pt);
  23.  
  24.     ListView_HitTest (list,&hit);
  25.  
  26.     return (hit.iItem);
  27. }
  28.  
  29. extern int far LV_GetCurSel (HWND list)
  30. {
  31.     auto int    count = ListView_GetItemCount (list);
  32.     auto UINT   mask  = LVIS_SELECTED;
  33.  
  34.     auto UINT   state;
  35.     auto int    inx;
  36.  
  37.     for (inx = NIL; inx < count; inx++) {
  38.  
  39.         state = ListView_GetItemState (list,inx,mask);
  40.  
  41.         if (state & mask)
  42.             return (inx);
  43.  
  44.         }
  45.  
  46.     return (-1);
  47. }
  48.  
  49. extern int far LV_SetCurSel (HWND list,int index)
  50. {
  51.     auto UINT   mask  = LVIS_SELECTED | LVIS_FOCUSED;
  52.  
  53.     ListView_SetItemState  (list,index,mask,mask);
  54.     ListView_EnsureVisible (list,index,FALSE);
  55.  
  56.     return (index);
  57. }
  58.  
  59. /* end of LV_Help.c - written by Gregory Braun */
  60.