wpQueryIconPosition
This method is specific to Version 4, or higher, of the OS/2 operating system.
This instance method finds the saved icon position for this record.
Syntax
_wpQueryIconPosition(somSelf, pszIdentity, pptl, pIndex)
Parameters
- somSelf (WPFolder *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPFolder.
- pszIdentity (PSZ) - input
- Object identity string.
- pptl (PPOINTL) - input
- A pointer to a POINTL structure containing the X- and Y-coordinates of the icon.
- pIndex (PULONG) - input
- Reserved. Set to **0**.
Returns
- rc (BOOL) - returns
- Success indicator
- TRUE Successful completion.
- FALSE Error occurred.
How to Override
This method is not generally overridden.
Usage
You can call the **wpQueryIconPosition** method to obtain the position of the icon for an object within an open Icon View of an folder. This method can be called only between calls to the wpInitIconPosData and wpFreeIconPosData methods.
Example Code
#define INCL_WINWORKPLACE
#include <os2.h>
WPFolder *somSelf; /* Pointer to the object on which the method is being invoked. */
PSZ pszIdentity; /* Object identity string. */
PPOINTL *pptl; /* A pointer to a POINTL structure containing the X- and Y-coordinates of the icon. */
PULONG *pIndex; /* Reserved. Set to 0. */
BOOL rc; /* Success indicator */
rc = _wpQueryIconPosition(somSelf, pszIdentity,
pptl, pIndex);
Remarks
This method functions only when the folder is opened. To conserve memory, the ICONPOS data is thrown away after the initial records are placed. This method is only valid in between calls to wpInitIconPosData and wpFreeIconPosData (that is, when the icon position information is in memory).
Example Code
This example shows how you can use the wpInitIconPosData, wpIdentify, **wpQueryIconPosition**, and wpFreeIconPosData methods to find the icon position information for all objects within a folder. In this example, **somSelf** contains the pointer to the folder being examined.
BOOL bSem;
WPObject *Object;
CHAR szIdentity[CCHMAXSTRING];
POINTL ptl;
ULONG ulIndex;
/* Retrieve the icon position information for all objects within
* the folder */
_wpInitIconPosData(somSelf);
/* Find the every object within the folder */
bSem = !_wpRequestObjectMutexSem(somSelf,SEM_INDEFINITE_WAIT);
for (Object = _wpQueryContent(somSelf,NULL,QC_FIRST);
Object;
Object = _wpQueryContent(somSelf,Object,QC_NEXT));
{
/* For each object in the folder, find the position of its icon
* in an Icon View of the folder */
if (_wpIdentify(Object,szIdentity))
{
if (_wpQueryIconPosition(somSelf,szIdentity,&ptl,&ulIndex))
{
/***** ptl contains the position of the icon for this object *****/
}
}
}
if (bSem)
{
_wpReleaseObjectMutexSem(somSelf);
}
/* Free the icon position data structure */
_wpFreeIconPosData(somSelf);