This seems to work ok:
function CalculateMouseDirection(const aStartPos, aCurrentPos : TPoint) : Integer;
{
North -> 0
North-East -> 45
East -> 90
South -> 180
West -> 270
NorthWest -> 315
etc.
}
var xDelta,yDelta : Integer;
ex : Extended;
begin
xDelta := aCurrentPos.X-aStartPos.X;
yDelta := aStartPos.Y-aCurrentPos.Y;
ex := (ArcTan2(xDelta, yDelta)*180) / PI;
if ex<0 then ex := ex+360;
Result := Round(ex);
end;