PDA

View Full Version : TDirectDraw.OnMouseMove



SixOfDLoC
13-12-2002, 03:01 PM
I am trying to draw on a TDirectDraw.Surface.Canvas by plotting the current (x,y) in my OnMouseMove, but to get a continous line, I have to move the mouse slowly. Does anyone know of a way to insure that each OnMouseMove event is triggered no more than one-pixel away from the last, or a way to insure that lines drawn in this manner are continous?

procedure TForm1.DXDraw1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
DXDraw1.Surface.Canvas.Pixels[x,y] := clWhite;
end;

Thanks!

TheLion
13-12-2002, 05:22 PM
You might want to use a flag and a GameLoop.
When the user clicks the mouse on a spot, set the flag to true and have a TPoint variable for the startpoint. Draw the line in your gameloop on the screen from the startpoint to the current mouse position and when the mouse is clicked again then save the endposition somewhere and then you have a continious line.

Or do you want to draw the line to another point everytime you move your mouse, then it's going to be difficult to get a contious line, since you'll have to have some sort of starting and ending point to draw the line and when you just move the mouse than there is no endpoint and no startpoint, just new lines everytime

SixOfDLoC
14-12-2002, 06:07 AM
That works. It is a little chunky, but I think that's because of the conversion happening each plot. Thanks for the help!