Hi Olivier,
Your solution might work, but easier might be to use Shape.ClosestPoints (http://www.mapwindow.org/documentation/mapwingis4.9/class_shape.html#a50fb5435d697e3e59d31131d9e65c5e0) or Shapefile.GetClosestVertex (http://www.mapwindow.org/documentation/mapwingis4.9/group__shapefile__selection.html#ga43e6c5f88c8a0b1a01239b02acc8fa77)
Your solution might work, but easier might be to use Shape.ClosestPoints (http://www.mapwindow.org/documentation/mapwingis4.9/class_shape.html#a50fb5435d697e3e59d31131d9e65c5e0) or Shapefile.GetClosestVertex (http://www.mapwindow.org/documentation/mapwingis4.9/group__shapefile__selection.html#ga43e6c5f88c8a0b1a01239b02acc8fa77)