wpclsQueryIconData
This class method allows the system to build the class default icon for a given class.
Syntax
_wpclsQueryIconData(somSelf, pIconInfo)
Parameters
- somSelf (M_WPObject *) - input
- Pointer to the class object for which you want the class icon data.
- pIconInfo (PICONINFO) - output
- Pointer to a buffer. Pointer to the buffer large enough to contain an ICONINFO data structure followed by the data needed to describe the icon. If pIconInfo is NULL, the return value is the required size of the buffer.
- ulReturn (ULONG) - returns
- Buffer size or number of bytes required to hold the output data. Depending of the contents of the pIconInfo parameter, ulReturn contains one of the following: NULL Number of bytes required to hold the output data for this class. Not NULL Number of bytes written into the buffer. If ulReturn is 0, an error occurred.
Returns
- ulReturn (ULONG) - returns
- Buffer size or number of bytes required to hold the output data. Depending of the contents of the pIconInfo parameter, ulReturn contains one of the following: NULL Number of bytes required to hold the output data for this class. Not NULL Number of bytes written into the buffer. If ulReturn is 0, an error occurred.
Remarks
If NULL is passed for the pIconInfo parameter, the caller is asking for the size of the ICONINFO buffer needed for this class (usually for memory allocation purposes). Otherwise, the pIconInfo parameter can always be assumed to be large enough to accommodate the ICONINFO and the variable data for this class.
Note that the ICONINFO structure allows you to specify the default icon in three different ways:
- Block of binary data
- Icon file name
- Module name and resource identifier
However, only one mechanism need be supported by any given class. For example, a caller cannot request one of the three formats by prefilling the ICONINFO structure.
How to Override
Workplace classes that wish to have a unique class default icon must override this method and fill out the appropriate fields within the ICONINFO structure. In addition, the correct size for the ICONINFO must always be returned.
Usage
This method may be called at any time. Typically, it would not be useful for another object class to make calls to this method.
Example Code
Declaration:
#define INCL_WINWORKPLACE #include <os2.h> M_WPObject *somSelf; /* Pointer to the class object for which you want the class icon data. */ PICONINFO pIconInfo; /* Pointer to a buffer. */ ULONG ulReturn; /* Buffer size or number of bytes required to hold the output data. */ ulReturn = _wpclsQueryIconData(somSelf, pIconInfo);
This example returns information about the icon associated with the class if pIconInfo is not NULL.
SOM_Scope ULONG SOMLINK CalendarM_wpclsQueryIconData(M_Calendar *somSelf, PICONINFO pIconInfo) { M_CalendarData *somThis = M_CalendarGetData(somSelf); M_CalendarMethodDebug('M_Calendar','myfM_wpclsQueryIconData'); if (pIconInfo) { pIconInfo->fFormat = ICON_RESOURCE; pIconInfo->hmod = _clsQueryModuleHandle(somSelf); pIconInfo->resid = ID_ICON; } /* endif */ return (sizeof(ICONINFO)); }