The attached file has a little more than you asked for, but I didn't see any put in cutting it up any further. It will do a selection by rectangular window, polygon window, rectangle crossing or polygon crossing, with or without a filter.
To use the filter you create an array of the typed values you want to filter on, and pass the array to this function. For the window/crossing rectangle/polygon, you create a point3dcollection containing the points which define your polygon/rectangle. Note that with a rectangle you only pass the two points for the opposite corners, just like when you pick it on screen, but for a polygon you pass a point for each vertex.
The code chooses wether to do a Rectangle or Polygon based on the number of coordinates passed in the point collection, and there is a boolean argument for wether to do a window or a crossing. Also a couple of booleans to give you access to the RejectLockedLayer, RejectNonCurrentSpace, and Force/AllowSubSelections properties.
Dave O.