The pfnCompare parameter must be declared as:
SHORT EXPENTRY pfnCompare( PRECORDCORE p1, PRECORDCORE p2, PVOID pStorage);
Note: If the CCS_MINIRECORDCORE style bit is specified when a container is created, then MINIRECORDCORE should be used instead of RECORDCORE and PMINIRECORDCORE should be used instead of PRECORDCORE in all applicable data structures and messages.
The pfnCompare parameter points to an application-provided function that compares two RECORDCORE structures and returns a SHORT value that specifies their relationship. The pfnCompare parameter is called one or more times during the sorting process and is passed pointers to two RECORDCORE structures on each call. The routine must compare the RECORDCORE structures, and then return one of the following values:
Value
The container records are sorted in increasing order, as defined by the pfnCompare parameter. The records can be sorted in reverse order by reversing the sense of "greater than" and "less than" in the pfnCompare parameter.
If the container has only one record, the PMERR_COMPARISON_FAILED error is set.
The application must provide an NLS-enabled function for the pfnCompare parameter. The container control does not provide NLS enablement for sorting.
An alternative to using the CM_SORTRECORD message is to provide an application-defined comparison function to sort the container records, which can be specified in the CNRINFO structure's pSortRecord field. If this function is provided, the container records are sorted as they are inserted into the container control. If this field is NULL, the records are not sorted on insertion.