I have this [incomplete] function:
void EditorWindow::OnLMClick(SObjectType sOT, short xPos, short yPos)
{
SObject* pSObject;
int nElements;
switch(sOT)
{
case SOT_Tile: nElements=TILETYPE_COUNT; pSObject = pSOTile[0]; break;
case SOT_Surface: nElements=SURFACEBMP_COUNT; break;
case SOT_Object: nElements=OBJECTBMP_COUNT; break;
case SOT_Edit: nElements=EDITBMP_COUNT; break;
default: MessageBox(NULL,"Switch does not include this SObjectType","Error in EditorWindow::OnLMClick()",NULL); return;
}
// From there on, pSObject may be pointing to any array of its child classes
for (int n = 0; n<nElements; n++)
{
if (xPos > pSObject->coor.X &&
xPos < pSObject->coor.X + pSObject->size.Width &&
yPos > pSObject->coor.Y &&
yPos < pSObject->coor.Y + pSObject->size.Height)
{
selectedItemRect.left = pSObject->coor.X;
selectedItemRect.top = pSObject->coor.Y + pSObject->size.Width;
selectedItemRect.right = pSObject->coor.X;
selectedItemRect.bottom = pSObject->coor.Y + pSObject->size.Height;
}
*(pSObject++);
}
Display();
}
I am trying to have pSObject point to the next element of the array pSOTile. How can I do that? Note that as I will update the function, pSObject will eventually have the possibility of pointing at other childs than just SOTile.