Function declaration:
...
// Set the column to be sorted
Void setcolumssortasint (INT nsortcolumcount ,...);
...
Function body:
/*************************************** **************************************** *****************************
* Function:
* Function: Specify columns in the list control that can be sorted by integers.
* Parameter: nsortcolumcount -- In. Number of columns to be set
... -- In. Column number, separated ','
M_listcolsortasint -- out. Implicit parameter, which stores the specified Column
* Return value: None
**************************************** **************************************** ****************************/
// Set the column to be sorted
Void cmylistctrl: setcolumssortasint (INT nsortcolumcount ,...)
{
// Clear the original data in the linked list
M_listcolsortasint.removeall ();
Va_list argp; // defines the structure for saving function parameters.
Int argno = 0; // number of record parameters
Int intpara = 0; // stores the retrieved integer Parameter
// Argp points to the first input optional parameter. nsortcolumcount is the final parameter.
Va_start (argp, nsortcolumcount );
While (argno <nsortcolumcount)
{
// Retrieve the current parameter (INT type) and save it to the linked list for sorting.
Intpara = va_arg (argp, INT );
M_listcolsortasint.addtail (intpara );
Argno ++;
}
Va_end (argp); // set argp to null
Return;
}
M_listcolsortasint is a member of the cmylistctrl class and is defined as follows.
// Record the serial number of the column to be sorted by integer
Clist <int, int> m_listcolsortasint;
The function stores the sequence numbers of columns to be sorted by integers into linked list member variables. Then, you can use the linked list variable to determine whether a column needs to be sorted by integers.