POINTS[] GetShortPositionFromInputArg(IntPtr location) {
POINTS[] position = null;
//the coordiantes are passed as variants containing short values. The y coordinate is an offset sizeof(variant)
//from pvaIn (which is 16 bytes)
object xCoordinateVariant = Marshal.GetObjectForNativeVariant(location);
object yCoordinateVariant = Marshal.GetObjectForNativeVariant(new IntPtr(location.ToInt32() + 16));
short? xCoordinate = xCoordinateVariant as short?;
short? yCoordinate = yCoordinateVariant as short?;
Debug.Assert(xCoordinate.HasValue, "Couldn't parse the provided x coordinate for show context command");
Debug.Assert(yCoordinate.HasValue, "Couldn't parse the provided y coordinate for show context command");
if (xCoordinate.HasValue && yCoordinate.HasValue) {
position = new POINTS[1];
position[0].x = xCoordinate.Value;
position[0].y = yCoordinate.Value;
}
return position;
}