Board index » delphi » changing cursor when dragging?

changing cursor when dragging?

How do I change the cursor when I start dragging
the mouse with the button down?  Changing the
cursor property seems to have no effect when
the mousebutton is pressed.

plz email I often miss responses in the newgroup

-Erik Johnson
e...@phidias.colorado.edu
http://phidias.colorado.edu/vgallery.html

 

Re:changing cursor when dragging?


Quote
> How do I change the cursor when I start dragging
> the mouse with the button down?  Changing the
> cursor property seems to have no effect when
> the mousebutton is pressed.

> plz email I often miss responses in the newgroup

> -Erik Johnson
> e...@phidias.colorado.edu
> http://phidias.colorado.edu/vgallery.html

You could assign the new cursor when the MouseDown event fires.

If you declare a global booleen var like : IsDragging, then set it to true in
another OnDrag event, when the MouseDown event fires, it could check the
IsDragging var, and if it is true, then assign the cursor(s).

Example:

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 if IsDragging then
  begin
  Screen.Cursor := crDrag;
  ListBox1.Cursor := crNoDrop; {** See Note below ***}
  end
 else
  begin
  Screen.Cursor := crDefault;  
 end;
end;

The line:   ListBox1.Cursor := crNoDrop;
would change the cursor to indicate to the user that this object is not a valid
choice to drop the selection into..

Here is the MouseUp event

{Use this code as the OnMouseUp event handler of the form:}
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  IsDragging := False;
  ListBox1.Cursor := crDefault;
end;

Hope that is what you meant..

----
RKR

****************************************
E-Mail:  r...@primenet.com
****************************************

Re:changing cursor when dragging?


On Tue, 10 Dec 1996 23:23:07 +0000, Erik Johnson observed that:-

Quote
>How do I change the cursor when I start dragging
>the mouse with the button down?  Changing the
>cursor property seems to have no effect when
>the mousebutton is pressed.

Try using the DragMode(=dmAutomatic) and DragCursor properties (you
don't have to change the cursor property that way, it's all
automatic).

Then you handle the drag/drop with the OnStarDrag, OnEndDrag,
OnDragOver and OnDragDrop events.

--
Ian E. Hickson              

Other Threads