The Delphi Bug List

Entry No.
618
VCL - General - Drag and Drop
Any exception that occurs in the EndDrag handler will cause an Access Violation when run from the IDE, or show the correct Exception and then terminate the app if run as a standalone exe.
1.02 2.01 3.0 3.01 3.02 4.0 4.01 4.02 4.03 5.0 5.01 6.0 6.01 6.02 Kylix 1.0
AbsentExistsExistsExistsExistsExistsExistsExistsExistsExistsExistsFixedFixedFixedFixed
Description
Reported by Steve Bliss; checked by Reinier Sterkenburg
The bug has been verified in Delphi versions 3.01 through 5.01. I have not looked if other components have the bug, so TImage may not be the only one. I have submitted a report to Borland.

To reproduce:
Make a form with two TImages (Image1 and Image2) setup to drag and drop from 1 to 2 like this: ----------------------------------------------------------------------

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Image1: TImage;
    Image2: TImage;
    
    procedure Image1MouseDown( Sender: TObject; Button: TMouseButton;
                               Shift: TShiftState; X, Y: Integer);

    procedure Image1DragOver( Sender, Source: TObject; X, Y: Integer;
                              State: TDragState; var Accept: Boolean);

    procedure Image1EndDrag( Sender, Target: TObject; X, Y: Integer);

    procedure Image2DragOver( Sender, Source: TObject; X, Y: Integer;
                              State: TDragState; var Accept: Boolean);
  end;

var
  Form1: TForm1;

implementation
{$R *.DFM}

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

procedure TForm1.Image1MouseDown( Sender: TObject; Button: TMouseButton;
                                  Shift: TShiftState; X, Y: Integer);
begin
  if Button=mbLeft then
    Image1.BeginDrag( true)
end;

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

procedure TForm1.Image1EndDrag( Sender, Target: TObject; X, Y: Integer);
begin
  raise Exception.Create('Drop Exception')
end;

end.
If you run the program and drag and drop on one of the images, the exception that occurs in the EndDrag handler will cause an Access Violation when run from the IDE, or show the correct Exception and then terminate the app if run as a standalone exe.
Latest update of this entry: 2002-04-03

Post a comment on this bug


Index page
Delphi Bug List home page
The Delphi Bug Lists are presently maintained by Jordan Russell, who has taken over this task from Reinier Sterkenburg since August 2000.
All feedback is appreciated. See also the feedback section of the Delphi Bug List home page.