WpclsQueryDetailsInfo: Difference between revisions
Created page with "{{DISPLAYTITLE:wpclsQueryDetailsInfo}} This method is called to allow the class object to specify its details to be used for its instances. ==Syntax== <pre> ULONG _wpclsQueryDetailsInfo(M_WPObject *somSelf, PCLASSFIELDINFO pClassFieldInfo, PULONG pSize) </pre> ==Parameters== ;''somSelf'' (M_WPObject *) - input :Pointer to the WPObject class object. ;''pClassFieldInfo'' (PCLASSFIELDINFO) - in/out :Pointer to details information. ;''pSize'' (PULONG) - i..." |
|||
Line 8: | Line 8: | ||
==Parameters== | ==Parameters== | ||
;''somSelf'' ([[M_WPObject | ;''somSelf'' ([[M_WPObject]] *) - input | ||
:Pointer to the [[WPObject]] class object. | :Pointer to the [[WPObject]] class object. | ||
Latest revision as of 21:30, 25 May 2025
This method is called to allow the class object to specify its details to be used for its instances.
Syntax
ULONG _wpclsQueryDetailsInfo(M_WPObject *somSelf, PCLASSFIELDINFO pClassFieldInfo, PULONG pSize)
Parameters
- somSelf (M_WPObject *) - input
- Pointer to the WPObject class object.
- pClassFieldInfo (PCLASSFIELDINFO) - in/out
- Pointer to details information.
- pSize (PULONG) - in/out
- Total number of bytes of details data. This total includes the details added by this class and ancestor classes.
Returns
- ulReturn (ULONG) - returns
- Sum of the number of detail columns for the object. This sum includes details added by this class and ancestor classes.
Remarks
All objects which have information to display in details view must override this method. The two possible queries are:
- Query 1**
A request for the CLASSFIELDINFO linked list segment associated with an object. This information is needed just prior to changing the view of a container control to details view.
If **pClassFieldInfo** is `NULL` (no subclasses have appended details data), the number of columns of details information for this class and all its superclasses is returned. If **pClassFieldInfo** is `NON-NULL`, the number of columns of details information is returned and ***pClassFieldInfo** points to the head of a linked list of CLASSFIELDINFO structures to which a linked list of CLASSFIELDINFO structures describing the details fields of objects of this subclass should be appended.
For example, on input ***pClassFieldInfo**:
CLASSFIELDINFO_1_grandparent CLASSFIELDINFO_2_grandparent CLASSFIELDINFO_1_parent
On output, ***pClassFieldInfo**:
CLASSFIELDINFO_1_grandparent CLASSFIELDINFO_2_grandparent CLASSFIELDINFO_1_parent CLASSFIELDINFO_1_self
The correct way to handle this request is to do the following:
- Call the parent method. The parent method returns the number of columns the ancestors have contributed.
- Walk the chain of CLASSFIELDINFO structures to the end and append the chain of CLASSFIELDINFO structures for the current class (using the **pNextFieldInfo** element).
- If ***pClassFieldInfo** is zero (indicating no parent columns), assign ***pClassFieldInfo** = beginning of CLASSFIELDINFO chain for this subclass.
- Return the sum of the details columns of the parent and the current subclass.
Note the following differences between the CLASSFIELDINFO and FIELDINFO structures:
- The **offFieldData** and **ulLenFieldData** fields are required so that appropriate offsets for the data can be computed. The application is responsible for providing **offFieldData** and **ulLenFieldData** fields.
- The **ulReserved** field should be left `NULL`.
- Owner draw, comparison, and sort functions may be specified for the field.
For example, if an object has three fields:
typedef struct _SAMPLE_DETAIL_DATA { CDATE cdate; CTIME ctime; PSZ psz; } SAMPLE_DETAIL_DATA; classfieldinfo[0].offFieldData = FIELDOFFSET(SAMPLE,cdate); classfieldinfo[0].ulLenFieldData = FIELDOFFSET(SAMPLE,ctime) FIELDOFFSET(SAMPLE,cdate); classfieldinfo[1].offFieldData = FIELDOFFSET(SAMPLE,ctime); classfieldinfo[1].ulLenFieldData = FIELDOFFSET(SAMPLE,psz) - FIELDOFFSET(SAMPLE,ctime); classfieldinfo[2].offFieldData = FIELDOFFSET(SAMPLE,psz); classfieldinfo[2].ulLenFieldData = sizeof(SAMPLE) - FIELDOFFSET(SAMPLE,psz);
Note that ***pClassFieldInfo** must be modified to point to the beginning of the CLASSFIELDINFO linked list only if ***pClassFieldInfo** is `0`. The application must return the sum of the details columns of the parent and itself:
return(n_cols + n_parent_cols);
Note also that the fields MUST be set up sequentially. `classfieldinfo[0]` must point to data at an offset of `0`. `classfieldinfo[n]` must point to data adjacent, and directly following that described by `classfieldinfo[-1]`.
- Query 2**
The number of bytes of details data associated with an object. This information is needed prior to allocating memory for a container control insert record.
If **pSize** is `NON-NULL`, the override should adjust ***pSize** by the number of bytes which must be added to the end of a MINIRECORDCORE structure to hold the details information for objects of this class.
Example:
*pSize += bytes_of_details_data;
In the case of the above example,
*pSize += sizeof(SAMPLE_DETAIL_DATA);
- Note:** All class field pointers returned should be pointers to static data areas.
How to Override
This method should be overridden by classes that introduce class-specific details to be displayed in details view. The parent method must always be called before appending the request information.
Usage
This method is generally called only by the system.
Example Code
This example adds details data for the Car object by appending `FIELDINFO` structures to `*ppClassFieldInfo`.
SOM_Scope ULONG SOMLINK carM_wpclsQueryDetailsInfo(M_Car *somSelf, PCLASSFIELDINFO *ppClassFieldInfo, PULONG pSize) { ULONG cParentCol; PCLASSFIELDINFO pCFI; ULONG i; /* M_CarData *somThis = M_CarGetData(somSelf); */ M_CarMethodDebug("M_Car","carM_wpclsQueryDetailsInfo"); /* Always call the parent method first to retrieve the number of details columns and any data already defined in the details buffer. */ cParentCol = parent_wpclsQueryDetailsInfo(somSelf, ppClassFieldInfo, pSize); /* If details columns exist, add the size of ours to it */ if (pSize) *pSize += sizeof(CARDETAILS); /* If the request was for the chained fieldinfo structures * (ppClassFieldInfo is non-NULL), link them in * * eventually the chain will look like * * Grandad - Dad - Me - Kid - Grandkid * * I will be getting the pointer to the beginning of the chain * * If the beginning of the chain is 0, I will assign the address * of my first CLASSFIELDINFO structure to *ppClassFieldInfo. * Otherwise *pp points to the first column description in the * chain. We need to walk the chain and link our CLASSFIELDINFO * structures at the end. */ if (ppClassFieldInfo) { if (*ppClassFieldInfo) { pCFI = *ppClassFieldInfo; for (i=0;i<cParentColumns;i++) pCFI = (pCFI->pNextFieldInfo) ? pCFI->pNextFieldInfo : pCFI; pCFI->pNextFieldInfo = fieldinfo; } else { *ppClassFieldInfo = fieldinfo; } /* endif */ } /* endif */ return ((ULONG) (cParentColumns + NUM_CAR_FIELDS)); }