I didn't test this results, but i think it should work.
Lets call the things by the names:
Start point coordinates: (X1,Y1)
End point coordinates: (X2, Y2)
Resultant closest End Point: (RX, RY)
A line that passes in Start point can be described as [y = x + (Y1 - X1)], for 45 degree slope. Slope equals the tangent of the desired angle, tan(pi/4) = 1. 45 degree is pi/4 radians.
Now you have a line with beginning on your Start Point, and with no end, defined by the given equation. We need to find it's End Point.
The End Point is closer to the line 1 wherever the line 1 intersects a line 2 with inverse slope, which passes in EndPoint. This line could be represented by [y = -x + (Y2+X2)], following the same principle, which has now -45 degrees slope.
The point of intersection is therefore described by:
[RX = (-Y1+X1+Y2+X2)/2]
And you can find its corresponding image calculating RX for the Line 1 (the one that we have interest in)
[RY = RX + (Y1-X1)]
And done, you have your line ready, its a line generated by the function [y = x + (Y1-X1)] with a start in StartPoint and a end in (RX,RY).
Since you have the line equation, you can calculate list of points the line passes through by changing x for any value between X1 and RX.
To get them for the order of selection, you just need to start changing x for X1 and go up to RX. Pretty straightforward.
Tell me if it works :) If you want the line in -45 degrees too, its the same, but the Line 2 is the important one instead of Line 1. You figure it out easily.
Hope it helps.