The CM_REMOVERECORD message can be used to remove one or more container records from the container control. The following sample code removes all records from a container and frees the memory associated with those records. It is the application's responsibility to free all application-allocated memory that is associated with the removed container records. The container is invalidated and repainted.

USHORT cNumRecord;             /* Number of records to be removed     */
USHORT fRemoveRecord;          /* Container message attributes        */

/**********************************************************************/
/*  Zero means remove all records.                                    */
/**********************************************************************/
cNumRecord = 0;

/**********************************************************************/
/*  Specify attributes to invalidate the container                    */
/*  and free the memory.                                              */
/**********************************************************************/
fRemoveRecord =
  CMA_INVALIDATERECORD | CMA_FREE;

/**********************************************************************/
/*  Remove the records.                                               */
/**********************************************************************/
WinSendMsg(hwndCnr,            /* Container window handle             */
  CM_REMOVERECORD,             /* Container message for removing      */
                               /* records                             */
  NULL,                        /* NULL PRECORDARRAY                   */
  MPFROM2SHORT(
    cNumRecord,                /* Number of records                   */
    fRemoveRecord));           /* Memory invalidation flags           */

The application must set the pointers to each record to be removed in an array. If the fRemoveRecord parameter of this message includes the CMA_FREE attribute, the records are removed and the memory is freed. If this attribute is not set, the records are removed from the list of items in the container, and the application must use the CM_FREERECORD message to free the memory. The default is not to free the memory.

If the fRemoveRecord parameter includes the CMA_INVALIDATERECORD attribute, the container is invalidated after the records are removed. The default is not to invalidate the container. The CMA_INVALIDATERECORD attribute can be used with the CMA_FREE attribute, separated by a logical OR operator (|), to free the record's memory and invalidate the container.


[Back] [Next]