PRECORD precord; // -> container records PRECORD precordFirst; // -> first container record RECORDINSERT recordInsert; // Record insertion control //---------------------------------------------------------- // Allocate memory for all user records //---------------------------------------------------------- cbExtraBytes = (ULONG)(sizeof(RECORD) - sizeof(MINIRECORDCORE)); precord = (PRECORD) WinSendDlgItemMsg (hwndDlg, idContainer, CM_ALLOCRECORD, MPFROMLONG (cbExtraBytes), MPFROMSHORT (cStates)); precordFirst = precord; //---------------------------------------------------------- // Initialize all records //---------------------------------------------------------- for (i = 0; i < cStates; i++, pastate++) { //------------------------------------------------------ // Initialize the container record control structure //------------------------------------------------------ precord->RecordCore.cb = sizeof (MINIRECORDCORE); //------------------------------------------------------ // Copy data to container record from our tables //------------------------------------------------------ strcpy (precord->szState, szStateName[i]); precord->RecordCore.pszIcon = precord->szState; strcpy (precord->szCapital, szStateCap[i]); precord->pszCapital = precord->szCapital; precord->ulPopulation = // Population precord->cdateAdmitted.month = // Month Admitted precord->cdateAdmitted.day = // Day Admitted precord->cdateAdmitted.year = // Year Admitted // Move to next record precord = (PRECORD) precord->RecordCore.preccNextRecord; } //---------------------------------------------------------- // Construct record insertion control structure //---------------------------------------------------------- memset (&recordInsert, 0, sizeof (RECORDINSERT)); recordInsert.cb = sizeof (RECORDINSERT); recordInsert.pRecordParent = NULL; recordInsert.pRecordOrder = (PRECORDCORE)((ULONG) MPFROMSHORT(CMA_END)); recordInsert.zOrder = (USHORT) CMA_TOP; recordInsert.cRecordsInsert = cStates; recordInsert.fInvalidateRecord = TRUE; //---------------------------------------------------------- // Insert the records //---------------------------------------------------------- WinSendDlgItemMsg (hwndDlg, idContainer, CM_INSERTRECORD, MPFROMP (precordFirst), MPFROMP (&recordInsert));