Jump to content

wpQueryIconData

From EDM2
Revision as of 18:31, 1 September 2025 by Martini (talk | contribs) (Created page with "{{DISPLAYTITLE:wpQueryIconData}} This instance method is called to allow the object to query the data to be used for its current icon. ==Syntax== _wpQueryIconData(somSelf, pIconInfo) ==Parameters== ;''somSelf'' (WPObject *) - input :Pointer to the object on which the method is being invoked. :Points to an object of class WPObject. ;''pIconInfo'' (PICONINFO) - output :Pointer to a buffer large enough to contain an ICONINFO data structure followed by the da...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This instance method is called to allow the object to query the data to be used for its current icon.

Syntax

_wpQueryIconData(somSelf, pIconInfo)

Parameters

somSelf (WPObject *) - input
Pointer to the object on which the method is being invoked.
Points to an object of class WPObject.
pIconInfo (PICONINFO) - output
Pointer to a 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.

Returns

ulReturn (ULONG) - returns
Buffer size or number of bytes required to hold the output data.
If pIconInfo is NULL, the return value is the number of bytes required to hold the output data.
If pIconInfo is not NULL, the return value is the number of bytes written into the buffer.
A return value of 0 indicates that 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 instance (usually for memory allocation purposes). Otherwise, the pIconInfo parameter can always be assumed to be large enough to accommodate the ICONINFO buffer and the variable data. 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. For example, a caller cannot request one of the three formats by prefilling the ICONINFO structure.

Usage

This method is called at any time in order to query the data for the current icon for this object.

How to Override

Workplace classes that wish to have a unique icon for each instance 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. This example shows how to override wpQueryIconData by returning information about the icon associated with the instance if pIconInfo is not NULL.

SOM_Scope ULONG SOMLINK Calendar_wpQueryIconData(_Calendar *somSelf,
                                                PICONINFO pIconInfo)
{
  _CalendarData *somThis = _CalendarGetData(somSelf);
  _CalendarMethodDebug("_Calendar","myf_wpQueryIconData");

  if (pIconInfo)
  {
    pIconInfo->fFormat = ICON_RESOURCE;
    pIconInfo->hmod    = _clsQueryModuleHandle(_somGetClass(somSelf));
    pIconInfo->resid   = ID_ICON;
  } /* endif */
  return (sizeof(ICONINFO));
}

Example Code

This example code shows how to call wpQueryIconData.

cbIconSize = _wpQueryIconData(Object,NULL);
pIconSize  = (PICONINFO)_wpAllocMem(Object,cbIconSize,NULL);
if (pIconInfo != NULL)
{
  _wpQueryIconData(Object,pIconInfo);
}

Related Methods