home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cnradvsc.zip / FIGURE2.c < prev    next >
Text File  |  1993-04-14  |  2KB  |  48 lines

  1. /* This function is used to bring a particular record in the container
  2.  * to the viewport.  It attempts to place the record as close to the
  3.  * top left corner as possible. */
  4. VOID ScrollToRecord (HWND hwndCnr, PRECORDCORE pRecord)
  5. {
  6.   RECTL             rclViewport, rclItem;
  7.   QUERYRECORDRECT   QueryRecordRect;
  8.   LONG              lMargin = 4L;
  9.   CNRINFO           CnrInfo;
  10.  
  11.   /* Query the container for the current view.  If a text view is the
  12.    * current view, then CMA_ICON is invalid for QueryRecordRect.fsExtent */
  13.   WinSendMsg (hwndCnr, CM_QUERYCNRINFO,
  14.               MPFROMP(&CnrInfo), MPFROMSHORT(sizeof(CNRINFO)));
  15.  
  16.   /* Query the container for the position of the record relative
  17.    * to the viewport.  We want the rectangle containing both the icon
  18.    * and the text of the record. */
  19.   QueryRecordRect.cb       = sizeof(QUERYRECORDRECT);
  20.   QueryRecordRect.pRecord  = pRecord;
  21.   QueryRecordRect.fsExtent = CMA_ICON | CMA_TEXT;
  22.   QueryRecordRect.fRightSplitWindow = FALSE;
  23.   if (CnrInfo.flWindowAttr & CV_TEXT)
  24.     QueryRecordRect.fsExtent = CMA_TEXT;
  25.   else
  26.     QueryRecordRect.fsExtent = CMA_ICON | CMA_TEXT;
  27.  
  28.   WinSendMsg (hwndCnr, CM_QUERYRECORDRECT,
  29.               MPFROMP(&rclItem), MPFROMP(&QueryRecordRect));
  30.  
  31.   /* Query the container for the size of the current viewport.
  32.    * This is necessary because the position of the record
  33.    * is relative to the bottom left corner of the viewport. */
  34.   WinSendMsg (hwndCnr, CM_QUERYVIEWPORTRECT,
  35.               MPFROMP(&rclViewport), MPFROM2SHORT(CMA_WINDOW, FALSE));
  36.  
  37.   /*  Scroll the container vertically to bring the record to a position
  38.    *  just below the top of the viewport. */
  39.   WinSendMsg (hwndCnr, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL),
  40.               MPFROMLONG(rclViewport.yTop - rclItem.yTop - lMargin));
  41.  
  42.   /*  Scroll the container horizontally to bring the record to a
  43.    *  position just to the right of the left edge of the viewport. */
  44.   WinSendMsg (hwndCnr, CM_SCROLLWINDOW, MPFROMSHORT(CMA_HORIZONTAL),
  45.               MPFROMLONG(rclItem.xLeft - lMargin));
  46.   return;
  47. }
  48.