home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / cnrexm.zip / FIGURE8.c < prev    next >
Text File  |  1993-04-16  |  2KB  |  61 lines

  1. /* This function will allocate a record and insert it into the 3
  2.  * container windows passed in.  After allocating the record, 3 unique
  3.  * (x,y) positions will be assigned, as well as 2 sets of unique
  4.  * attributes. */
  5. BOOL AllocateAndInsertRecord(HWND hwndCnr1, HWND hwndCnr2,
  6.                              HWND hwndCnr3, HPOINTER hIcon,
  7.                              PSZ pszIconText, RECORDINSERT RecordInsert)
  8. {
  9.  PMINIRECORDCORE  pRecord;
  10.  LONG             rc = 0;
  11.  
  12.  /* Allocate one MINIRECORDCORE structure from the first container.
  13.   * Do not allocate any addition bytes of storage. */
  14.  pRecord = (PMINRECORDCORE)WinSendMsg (hwndCnr1, CM_ALLOCRECORD,
  15.                                        MPFROMLONG(0), MPFROMSHORT(1));
  16.  
  17.  /* If we don't get a record, bail out now. */
  18.  if (pRecord)
  19.  {
  20.    /* Fill in the record memory with the initial information. */
  21.    pRecord->cb           = sizeof(MINIRECORDCORE);
  22.    pRecord->hptrIcon     = hIcon;
  23.    pRecord->ptlIcon.x    = 100;
  24.    pRecord->ptlIcon.y    = 100;
  25.    pRecord->flRecordAttr = CRA_SELECTED | CRA_RECORDREADONLY;
  26.    pRecord->pszIcon = malloc (TEXT_SIZE);
  27.    strcpy (pRecord->pszIcon, pszIconText);
  28.  
  29.    /* Insert the record into the first container. */
  30.    rc = (LONG)WinSendMsg (hwndCnr1, CM_INSERTRECORD,
  31.                           MPFROMP(pRecord), MPFROMP(&RecordInsert));
  32.  
  33.    if (rc)
  34.    {
  35.      /* Change the (x,y) position of the record, and insert the same
  36.       * record into the second container. */
  37.      pRecord->ptlIcon.x += 50;
  38.      pRecord->ptlIcon.y -= 30;
  39.  
  40.      rc = (LONG)WinSendMsg (hwndCnr2, CM_INSERTRECORD,
  41.                             MPFROMP(pRecord), MPFROMP(&RecordInsert));
  42.    }
  43.  
  44.    if (rc)
  45.    {
  46.      /* Change the (x,y) position again, and turn the selection
  47.       * attribute off of the same record and insert it into the
  48.       * third container.  If all is successful, return TRUE,
  49.       * otherwise return FALSE. */
  50.      pRecord->ptlIcon.x = 275;
  51.      pRecord->ptlIcon.y = pRecord->ptlIcon.x + 40;
  52.      pRecord->flRecordAttr &= ~CRA_SELECTED;
  53.  
  54.      rc = (LONG)WinSendMsg (hwndCnr3, CM_INSERTRECORD,
  55.                             MPFROMP(pRecord), MPFROMP(&RecordInsert));
  56.    }
  57.  }
  58.  /* Convert rc to BOOL and return. */
  59.  return !!rc;
  60. }
  61.