Overriding default mouse cursors during drag and drop operation lazarus / 10-Designer ---------------------------------------------------------------------- giorgiotani · 2009-09-27 19:10 I'm implementing drag and drop events for a ListView object, and I need to override the default mouse cursor's type when the mouse leave the application's area, which is crNoDrop. I can avoid the cursor to turn into crNoDrop while it is inside the application's window, setting Accept:=true for OnDragOver events, but I've found no way to say to the cursor to not change to crNoDorp when leaving the application. I've also tried changing the approach, and I tried to set the cursor type during a OnTimer event. i.e. I tried to set: Screen.Cursor:=crCross; ListView1.Cursor:=crCross; ListView1.DragCursor:=crCross; Cursor:=crCross; DragCursor:=crCross; but seem working only when the cursor stays in the area of the application, and when during the drag and drop the mouse leaves the application the cursor change anyway to crNoDrop. Could you please suggest me a method to tell the application it doesn't need to change the mouse cursor to crNoDrop when leaving the application's area? ---------------------------------------------------------------------- Ocye · 2009-09-28 12:23 Brian Long wrote a very good article about drag and drop: http://www.blong.com/Conferences/BorCon2001/DragAndDrop/4114.htm ---------------------------------------------------------------------- giorgiotani · 2009-09-28 17:19 Thank you very much, I don't jet know if it has the information I need but the article is very interesting. ---------------------------------------------------------------------- giorgiotani · 2009-09-29 07:28 The article guided me to a working solution for my purposes (tested on Lazarus 0.9.26.2), modifying a featured example. Basically, I need to create a custom TDragObject which override GetDragCursor and EndDrag events type   TControlDragObject = class(TDragObject)   private     FDragImages: TDragImageList;     FX, FY: Integer;   protected     procedure EndDrag(Target: TObject; X, Y: Integer); override;     function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; override;   public     constructor CreateWithHotSpot(AControl: TWinControl; X, Y: Integer);     destructor Destroy; override;   end; I declare a global variable FDragObject:TDragObject; OnStartDrag from my ListView I create the DragObject with the custom method, and replace ListView's DragObject with it.   FDragObject := TControlDragObject.CreateWithHotSpot(Button1, Pt.X, Pt.Y);   DragObject := FDragObject; During the drag and drop operation of the FDragObject, consequently, the custom GetDragCursor will be used, and finally the custom EndDrag is triggered. This custom EndDrag is meant to allow me to perfrom an operation when the target is outside my application, while the DragDrop event would work only inside the application AFAIK. The overriding seem working as expected, if someone has experience with similar things and knows a better solution (or sees flaws in this overriding mechanism) I'll be glad for any suggestion. ---------------------------------------------------------------------- Ocye · 2009-09-29 09:50 If you only need to change the cursor there might be a more simple method. I'm using your approach successfully for a long time but removed the unusual cursors from the code since the user defined crDrag and crNoDrop herself. BTW: On Linux the dragobject (for me a 40x40 bitmap) is very slow compared to Windows. I have no idea about a reason.