Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

how to drag cursor in the manner of TListView

Posted on 2001-07-05
6
Medium Priority
?
545 Views
Last Modified: 2011-09-20
in TListView dragging an item would yield a drag cursor in the form of the item caption (when listview is in vsReport viewstyle).

Is it possible to replicate this behaviour on a tlist or any other component ?
0
Comment
Question by:fadyg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 6254685
get the free drag&drop suite at
http://www.melander.dk/delphi/dragdrop/
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6254709
also look here for another components for drag and drop

http://www.torry.net/draganddrop.htm


0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6254735
Yes, you can write a TDragObject descendant (overriding GetDragImages) and assign it to DragObject parameter in OnStartDrag event.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:fadyg
ID: 6255249
thanks all for the links

TOndrej, do you happen to have a small working example of your solution ?

FadyG
0
 
LVL 8

Accepted Solution

by:
TOndrej earned 1200 total points
ID: 6255338
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;

type
  TMyDragObject = class(TDragObject)
  private
    FDragImages: TDragImageList;
  protected
    function GetDragImages: TDragImageList; override;
  public
    constructor Create;
    destructor Destroy; override;
  end;

  TForm1 = class(TForm)
    Label1: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Label1StartDrag(Sender: TObject;
      var DragObject: TDragObject);
    procedure FormDragOver(Sender, Source: TObject; X, Y: Integer;
      State: TDragState; var Accept: Boolean);
    procedure Label1EndDrag(Sender, Target: TObject; X, Y: Integer);
  private
    FDragObject: TMyDragObject;
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

{ TMyDragObject protected }

function TMyDragObject.GetDragImages: TDragImageList;
begin
  Result := FDragImages;
end;

{ TMyDragObject public }

constructor TMyDragObject.Create;
var
  B: TBitmap;
begin
  inherited Create;
  FDragImages := TDragImageList.CreateSize(32, 32);
  B := TBitmap.Create;
  B.Height := FDragImages.Height;
  B.Width := FDragImages.Width;
  try
    B.Canvas.Brush.Style := bsClear;
    B.Canvas.Ellipse(Rect(0, 0, 32, 32));
    B.Canvas.Font.Color := clRed;
    B.Canvas.TextOut(2, 4, 'Hello');
    FDragImages.AddMasked(B, clWhite);
  finally
    B.Free;
  end;
end;

destructor TMyDragObject.Destroy;
begin
  FDragImages.Free;
  inherited Destroy;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  { drag image is only displayed over controls which include csDisplayDragImage
    in their ControlStyle }
  ControlStyle := ControlStyle + [csDisplayDragImage];
end;

procedure TForm1.Label1StartDrag(Sender: TObject;
  var DragObject: TDragObject);
begin
  FDragObject := TMyDragObject.Create;
  DragObject := FDragObject;
end;

procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := True;
end;

procedure TForm1.Label1EndDrag(Sender, Target: TObject; X, Y: Integer);
begin
  FDragObject.Free;
end;

end.
0
 

Author Comment

by:fadyg
ID: 6255840
short and straight to the point
thanks !!
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question