home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vpcvrsam.zip / VPCVRSAM / Main / Form.1 < prev    next >
Text File  |  1995-08-01  |  5KB  |  103 lines

  1. /* Event Opened - Form REXXAWAR\Main */
  2. CHAR aTextValue[255]="text";
  3. LONG anIntegerValue=0;
  4. ULONG anUnsignedValue=0;
  5. PSZ filename="SAMPLE.DAT";
  6. FILE *file;
  7.  
  8. /* View as details 1000 Container */
  9. {
  10.    CNRINFO cnrinfo;
  11.    cnrinfo.cb=sizeof(CNRINFO);
  12.    cnrinfo.flWindowAttr=CV_DETAIL | CA_DETAILSVIEWTITLES | CA_MIXEDTARGETEMPH;
  13.    WinSendDlgItemMsg(hwndDlg, 1000,
  14.                      CM_SETCNRINFO,
  15.                      MPFROMP(&cnrinfo),
  16.                      MPFROMLONG(CMA_FLWINDOWATTR));
  17. }
  18. file = fopen (filename, "r");
  19. if (file != NULL)
  20. {
  21.     int count;
  22.    fgets (aTextValue, sizeof (aTextValue), file);
  23.    
  24.    count = atoi (aTextValue);
  25.    while (count--)
  26.    {
  27.       /* Add a container record to end 1000 Container */
  28.       {
  29.          PMAIN_1000_REC pRecord; /* Pointer to cnr item. */
  30.          /* IMPORTANT!!!! Manually replace MAIN with the form name */
  31.          /* This pRecord typedef is contained in the .H for this form */
  32.          RECORDINSERT RecordInsert;
  33.       
  34.          /* IMPORTANT!!! we allocate 10*32 extra bytes for the pszIcon string */
  35.          /* We must allocate more than that if we have any extra PSZ members */
  36.          /* as columns */
  37.          pRecord=(PVOID)WinSendDlgItemMsg(hwndDlg, 1000,
  38.                         CM_ALLOCRECORD,
  39.                         MPFROMLONG(sizeof(*pRecord)-sizeof(MINIRECORDCORE)+10*32), /* Bytes of additional data */
  40.                         MPFROMLONG(1));                  /* Number of records        */
  41.          pRecord->Record.cb=sizeof(MINIRECORDCORE);
  42.          pRecord->Record.flRecordAttr=0;
  43.          pRecord->Record.hptrIcon=WinQuerySysPointer(HWND_DESKTOP,SPTR_FILE,FALSE);
  44.  
  45.          /* IMPORTANT!!! initiaize other members here if they exist */
  46.          fgets (aTextValue, sizeof (aTextValue), file); /* 1. */
  47.         pRecord->Record.pszIcon=(PBYTE)pRecord+sizeof(*pRecord);
  48.          aTextValue[31] = '\0';
  49.      strcpy(pRecord->Record.pszIcon,aTextValue);
  50.          fgets (aTextValue, sizeof (aTextValue), file); /* 2. */
  51.          pRecord->pszName=(PBYTE)pRecord+sizeof(*pRecord)+1*32;
  52.          aTextValue[31] = '\0';
  53.          strcpy (pRecord->pszName,aTextValue);
  54.          fgets (aTextValue, sizeof (aTextValue), file); /* 3. */
  55.          pRecord->pszDept__=(PBYTE)pRecord+sizeof(*pRecord)+2*32;
  56.          aTextValue[31] = '\0';
  57.          strcpy (pRecord->pszDept__,aTextValue);
  58.          fgets (aTextValue, sizeof (aTextValue), file); /* 4. */
  59.          pRecord->pszJob=(PBYTE)pRecord+sizeof(*pRecord)+3*32;
  60.          aTextValue[31] = '\0';
  61.          strcpy (pRecord->pszJob,aTextValue);
  62.          fgets (aTextValue, sizeof (aTextValue), file); /* 5. */
  63.          pRecord->pszYears=(PBYTE)pRecord+sizeof(*pRecord)+4*32;
  64.          aTextValue[31] = '\0';
  65.          strcpy (pRecord->pszYears,aTextValue);
  66.          fgets (aTextValue, sizeof (aTextValue), file); /* 6. */
  67.          pRecord->pszSalary=(PBYTE)pRecord+sizeof(*pRecord)+5*32;
  68.          aTextValue[31] = '\0';
  69.          strcpy (pRecord->pszSalary,aTextValue);
  70.          fgets (aTextValue, sizeof (aTextValue), file); /* 7. */
  71.          pRecord->pszCommision=(PBYTE)pRecord+sizeof(*pRecord)+6*32;
  72.          aTextValue[31] = '\0';
  73.          strcpy (pRecord->pszCommision,aTextValue);
  74.          fgets (aTextValue, sizeof (aTextValue), file); /* 8. */
  75.          pRecord->pszDepartment=(PBYTE)pRecord+sizeof(*pRecord)+7*32;
  76.          aTextValue[31] = '\0';
  77.          strcpy (pRecord->pszDepartment,aTextValue);
  78.          fgets (aTextValue, sizeof (aTextValue), file); /* ignore. */
  79.          fgets (aTextValue, sizeof (aTextValue), file); /* 9. */
  80.          pRecord->pszDivision=(PBYTE)pRecord+sizeof(*pRecord)+8*32;
  81.          aTextValue[31] = '\0';
  82.          strcpy (pRecord->pszDivision,aTextValue);
  83.          fgets (aTextValue, sizeof (aTextValue), file); /* 10. */
  84.          pRecord->pszLocation=(PBYTE)pRecord+sizeof(*pRecord)+9*32;
  85.          aTextValue[31] = '\0';
  86.          strcpy (pRecord->pszLocation,aTextValue);
  87.          /* add the item to the container */
  88.          RecordInsert.cb=sizeof(RECORDINSERT);
  89.          RecordInsert.pRecordOrder=(PRECORDCORE)CMA_END;/* add to the end */
  90.          RecordInsert.pRecordParent=(PRECORDCORE)0;     /* not a child record */
  91.          RecordInsert.zOrder=CMA_TOP;
  92.          RecordInsert.cRecordsInsert=1;
  93.          RecordInsert.fInvalidateRecord=TRUE;           /* repaint the record */
  94.          WinSendDlgItemMsg(hwndDlg, 1000,
  95.                            CM_INSERTRECORD,
  96.                            MPFROMP(pRecord),
  97.                            MPFROMP(&RecordInsert));
  98.       }
  99.    } /* end while */
  100.    fclose (file);
  101. }
  102.  
  103.