Diono
asked on
TDragObject
How to correctly implement.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ouch Mike, stop spanking me so hard! :o)
Mike is right. I confused TDropTarget with TDragObject.
I'll withdraw the answer... If you really meant the drag/drop stuff I pointed you at you know what to do :-)
Cheers,
Raymond.
Mike is right. I confused TDropTarget with TDragObject.
I'll withdraw the answer... If you really meant the drag/drop stuff I pointed you at you know what to do :-)
Cheers,
Raymond.
;-) didn't mean it hard...
Ciao, Mike
PS: This is the first answer withdraw I'
ve seen. Cool feature I think...
Ciao, Mike
PS: This is the first answer withdraw I'
ve seen. Cool feature I think...
ASKER
An example would've been great!
Well, there's nothing special. Look at this code:
type
TMyDragObject = class(TDragObject)
protected
procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
end;
TMainForm = class(TForm)
private
FMyDragObject: TMyDragObject;
end;
procedure TMainForm.ListBox1StartDra g(Sender: TObject; var DragObject: TDragObject);
begin
if FMyDragObject = nil then FMyDragObject := TMyDragObject.Create;
DragObject := FMyDragObject;
end;
{ TMyDragObject }
procedure TMyDragObject.Finished(Tar get: TObject; X, Y: Integer;
Accepted: Boolean);
begin
Beep;
inherited;
end;
procedure TMainForm.FormDragOver(Sen der, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept := True;
end;
procedure TMainForm.FormDragDrop(Sen der, Source: TObject; X, Y: Integer);
begin
if Source = FMyDragObject then ShowMessage('It''s mine');
end;
Ciao, Mike
type
TMyDragObject = class(TDragObject)
protected
procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
end;
TMainForm = class(TForm)
private
FMyDragObject: TMyDragObject;
end;
procedure TMainForm.ListBox1StartDra
begin
if FMyDragObject = nil then FMyDragObject := TMyDragObject.Create;
DragObject := FMyDragObject;
end;
{ TMyDragObject }
procedure TMyDragObject.Finished(Tar
Accepted: Boolean);
begin
Beep;
inherited;
end;
procedure TMainForm.FormDragOver(Sen
State: TDragState; var Accept: Boolean);
begin
Accept := True;
end;
procedure TMainForm.FormDragDrop(Sen
begin
if Source = FMyDragObject then ShowMessage('It''s mine');
end;
Ciao, Mike
http://www.melander.dk/delphi/dragdrop/
Cheers,
Raymond.