home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cnrexm.zip / FIGURE9.c < prev   
Text File  |  1993-04-14  |  2KB  |  49 lines

  1. /* This function will change a specified record's position and-or
  2.  * attributes for a particular container. */
  3. BOOL ChangeRecordPosAndAttr(HWND hwndCnrChange, PMINIRECORDCORE pRecord,
  4.                             LONG DeltaX, LONG DeltaY, LONG NewAttrs)
  5. {
  6.  USHORT  usFlag = 0;
  7.  
  8.  /* Query the current information for the pRecord that is contained in
  9.   * hwndCnrChange. */
  10.  if (WinSendMsg (hwndCnrChange, CM_QUERYRECORDINFO,
  11.                  MPFROMP(&pRecord), MPFROMSHORT(1)))
  12.  {
  13.    /* Check to see if the new attributes are indeed different than the
  14.     * current record attributes.  If they are different, set the
  15.     * attributes and the minimum invalidate flag necessary. */
  16.    if (pRecord->flRecordAttr != NewAttrs)
  17.    {
  18.      pRecord->flRecordAttr = NewAttrs;
  19.      usFlag = CMA_NOREPOSITION;
  20.    }
  21.  
  22.    /* Make sure at least one of the delta amounts is not 0.  If so,
  23.     * change the current (x,y) by the delta amount and reset the
  24.     * invalidate flag such that the record will go to its new position. */
  25.    if (DeltaX || DeltaY)
  26.    {
  27.      pRecord->ptlIcon.x += DeltaX;
  28.      pRecord->ptlIcon.y += DeltaY;
  29.      usFlag = CMA_REPOSITION;
  30.    }
  31.  
  32.    /* If usFlag is set, a change has taken place with the record.
  33.     * Erase the record and invalidate it at its new position. */
  34.    if (usFlag)
  35.    {
  36.      WinSendMsg (hwndCnrChange, CM_ERASERECORD, MPFROMP(pRecord), NULL);
  37.      return ((BOOL)WinSendMsg (hwndCnrChange, CM_INVALIDATERECORD,
  38.                                MPFROMP(&pRecord), MPFROM2SHORT(1, usFlag)));
  39.    }
  40.    else
  41.    /* No error existed, but the record did not change either. */
  42.      return (TRUE);
  43.  }
  44.  
  45.  /* CM_QUERYRECORDINFO returned FALSE indicating that the given record
  46.   * does not exist in the container specified by hwndCnrChange. */
  47.  return (FALSE);
  48. }
  49.