Snapping not working when changing from NAD83(decimal degree) to  UTM 11N(meters)

Discussion created by amo2002 on May 22, 2013
I've used the following ESRI snippet to Convert the display extents in Pixels (at the current map scale) and then return out the map units.
public System.Double ConvertPixelsToMapUnits(ESRI.ArcGIS.Carto.IActiveView activeView, System.Int32 pixelUnits)

  if(activeView == null)
    return -1;
  //Get the ScreenDisplay
  ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;

  //Get the DisplayTransformation 
  ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;

  //Get the device frame which will give us the number of pixels in the X direction
  ESRI.ArcGIS.Display.tagRECT deviceRECT = displayTransformation.get_DeviceFrame();
  System.Int32 pixelExtent = (deviceRECT.right - deviceRECT.left);

  //Get the map extent of the currently visible area
  ESRI.ArcGIS.Geometry.IEnvelope envelope = displayTransformation.VisibleBounds;
  System.Double realWorldDisplayExtent = envelope.Width;

  //Calculate the size of one pixel
  if(pixelExtent == 0)
    return -1;
  System.Double sizeOfOnePixel = (realWorldDisplayExtent / pixelExtent);

  //Multiply this by the input argument to get the result
  return (pixelUnits * sizeOfOnePixel);

and then this to check if the snapping is within tolerance ITolerance which is in Pixels(Example 10 pixels) :
Double dblToleranceX;
dblToleranceX = snaptolerance(ITolerance);// call ESRI Snippet 
dblProximity = dblToleranceX;
ouble dblToleranceY = dblToleranceX;
pInputpoint = gpMxDocument.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(intX, intY);
pRectangle.PutCoords(pInputpoint.X - dblToleranceX, pInputpoint.Y - dblToleranceY, pInputpoint.X + dblToleranceX, pInputpoint.Y + dblToleranceY);
pSpatialfilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
IFeatureClass pFeatureClass = gpFeatureWorkSpace.OpenFeatureClass(strFeaturecls);
pSpatialfilter.Geometry = pRectangle;
pSpatialfilter.GeometryField = pFeatureClass.ShapeFieldName;
pFeatureCursor = pFeatureClass.Search(pSpatialfilter, false);
pFeature = pFeatureCursor.NextFeature();

if (pFeatureClass.FeatureCount(pSpatialfilter) < 1)
    MessageBox.Show("Snapping is not within tolerance");

The overall process will snap a point(flag) to an Edge,  the listed code will check if we are within the tolerance.

The code work perfectly on NAD83(decimal degree) but does not work when Changing the data frame's coordinate system to NAD 83 UTM Zone 11N (Meters).

Appreciate your help if you can figure out a way around this issue in order to make the code work for these kind of situation .