home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cnrexm.zip / FIGURE1.c next >
Text File  |  1993-04-14  |  3KB  |  70 lines

  1. /* This function will track the splitbar in details view using the
  2.  * keyboard.  This function could be called as a result of a menu
  3.  * item selected by the user. */
  4. VOID TrackSplitbar (HWND hwndCnr)
  5. {
  6.  TRACKINFO  ti;
  7.  RECTL      rclDV, rclCnr, rclCnrTitle;
  8.  CNRINFO    CnrInfo;
  9.  
  10.  /* Query the CnrInfo structure from the container.  From it we will
  11.   * get the current position of the splitbar. */
  12.  WinSendMsg (hwndCnr, CM_QUERYCNRINFO,
  13.              MPFROMP(&CnrInfo), MPFROMSHORT(sizeof(CNRINFO)));
  14.  
  15.  /* Get the window rectangles for the container title window, the left
  16.   * details view window, and the container window itself. */
  17.  WinQueryWindowRect (WinWindowFromID (hwndCnr, CID_CNRTITLEWND), &rclCnrTitle);
  18.  WinQueryWindowRect (WinWindowFromID (hwndCnr, CID_LEFTDVWND), &rclDV);
  19.  WinQueryWindowRect (hwndCnr, &rclCnr);
  20.  
  21.  /* Initialize the TrackInfo structure.  The splitbar has the width of
  22.   * a SizeBorder, and has the height of the container window minus the
  23.   * container title window. */
  24.  ti.cxBorder = (SHORT)WinQuerySysValue (HWND_DESKTOP, SV_CXSIZEBORDER);
  25.  ti.cyBorder = (SHORT)(rclCnr.yTop - rclCnrTitle.yTop);
  26.  ti.cxGrid   = (SHORT)rclCnr.xRight;
  27.  ti.cyGrid   = (SHORT)rclCnr.yTop;
  28.  
  29.  /* Set the x Keyboard increment to be the number of pels you want the
  30.   * splitbar to move when the user presses the right and left arrow
  31.   * keys.  Set the y Keyboard increment to 0. */
  32.  ti.cxKeyboard = 10;
  33.  ti.cyKeyboard = 0;
  34.  
  35.  /* Set up the rectangle that is to be tracked.  This is the rectangle
  36.   * of the splitbar. */
  37.  ti.rclTrack.xLeft   = CnrInfo.xVertSplitbar;
  38.  ti.rclTrack.xRight  = ti.rclTrack.xLeft + ti.cxBorder;
  39.  ti.rclTrack.yBottom = rclCnr.yBottom;
  40.  ti.rclTrack.yTop    = ti.cyBorder;
  41.  
  42.  /* Set up the absolute boundary rectangle.  This is the rectangle
  43.   * specifying the boundary which the tracking rectangle cannot exceed.
  44.   * Set it to be the left, right, and bottom of the container, and the
  45.   * top of the splitbar. */
  46.  ti.rclBoundary.xLeft   = rclCnr.xLeft;
  47.  ti.rclBoundary.xRight  = rclCnr.xRight;
  48.  ti.rclBoundary.yBottom = rclCnr.yBottom;
  49.  ti.rclBoundary.yTop    = ti.cyBorder;
  50.  ti.ptlMinTrackSize.x   = ti.cxBorder;
  51.  ti.ptlMinTrackSize.y   = ti.cyBorder;
  52.  ti.ptlMaxTrackSize.x   = ti.cxBorder;
  53.  ti.ptlMaxTrackSize.y   = ti.cyBorder;
  54.  
  55.  /* Set the track flags.  TF_SETPOINTERPOS will put the mouse pointer
  56.   * in the middle of the tracking rectangle (splitbar). */
  57.  ti.fs = TF_MOVE | TF_ALLINBOUNDARY | TF_SETPOINTERPOS;
  58.  
  59.  /* If the tracking is successful, inform the container of the new
  60.   * splitbar position. */
  61.  if (WinTrackRect (hwndCnr, NULL, &ti))
  62.  {
  63.    /* Inform the container of the new splitbar position. */
  64.    CnrInfo.xVertSplitbar = ti.rclTrack.xLeft;
  65.    WinSendMsg (hwndCnr, CM_SETCNRINFO,
  66.                &CnrInfo, MPFROMLONG(CMA_XVERTSPLITBAR));
  67.  }
  68.  return;
  69. }
  70.