Jump to content

CM SORTRECORD

From EDM2

This message sorts the container records in the container control.

Syntax

param1
PFN pfnCompare;   /* Pointer to a comparison function. */

param2
PVOID pStorage;    /* Application use. */

Parameters

pfnCompare (PFN) - Input
Pointer to a comparison function.
pStorage (PVOID) - Input
Available for application use.

Returns

rc (BOOL) - returns
Success indicator.
TRUE: The records in the container were sorted.
FALSE: The records in the container were not sorted. The WinGetLastError function may return the following errors:
PMERR_COMPARISON_FAILED
PMERR_INSUFFICIENT_MEMORY.

Remarks

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:

Comparison Function Return Values
Value Meaning
> 0 p1 is less than p2.
0 p1 is equal to p2.
< 0 p1 is greater than p2.

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.

Default Processing

The default window procedure does not expect to receive this message and therefore takes no action on it other than to return FALSE.