Board index » delphi » Can't see TDragObject.DragImage when dragging over other VC's

Can't see TDragObject.DragImage when dragging over other VC's

Kind reader;

I have successfully created my TDragObject in the OnStartDrag event
handler and  loaded my TImageList.  The drag image is visible, but only
when dragging over 1) a Ttreeview or 2) outside of my Delphi forms.  I
have been studying the VCL source code, and experimented with calls to
ShowDragImage and others, but all to no avail.  The Delphi components
are doing something that kills the underlying windows ImageList from
showing its image during drag/drop operations.

I'm sure it must be something simple, but I do not know what it is.

Thank you.
B. Linton

 

Re:Can't see TDragObject.DragImage when dragging over other VC's


Quote
On Tue, 11 Nov 1997 17:58:07 -0600, WRL <Bill.Lin...@MCI.com> wrote:
>Kind reader;

>I have successfully created my TDragObject in the OnStartDrag event
>handler and  loaded my TImageList.  The drag image is visible, but only
>when dragging over 1) a Ttreeview or 2) outside of my Delphi forms.  I
>have been studying the VCL source code, and experimented with calls to
>ShowDragImage and others, but all to no avail.  The Delphi components
>are doing something that kills the underlying windows ImageList from
>showing its image during drag/drop operations.

>I'm sure it must be something simple, but I do not know what it is.

i found a reference to this problem in an earlier item in the news
group. The problem is that virtually all delphi's components are
created with the csDisplayDragImage NOT in the ControlStyle set.
Refer to help on ControlStyle.

I have worked around it by subclassing all components, and modifying
the Create constructor to add csDisplayDragImage to the ControlStyle,
eg:

TBorlandDidntGetThisRightForm = class(TForm)
  constructor Create(AOwner : TComponent);override;
end;

constructor TBorlandDidntGetThisRightForm.Create(AOwner : TComponent);
begin
  inherited;
  ControlStyle := ControlStyle + [csDisplayDragImage];
end;

Possibly one can do this at runtime, altho i doubt it. My solution is
pretty horrific, when you start to think about it.

Chris

Re:Can't see TDragObject.DragImage when dragging over other VC's


Hi Bill

Quote
On Tue, 11 Nov 1997 17:58:07 -0600, WRL <Bill.Lin...@MCI.com> wrote:
> ... The drag image is visible, but only
>when dragging over 1) a Ttreeview or 2) outside of my Delphi forms.

the ControlStyle of all controls that should display the drag image
when it is dragged over must include csDisplayDragImages.

HTH

Quote
>I have successfully created my TDragObject in the OnStartDrag event
>handler and  loaded my TImageList. The drag image is visible, ...

could you please post or mail me an example how to do that, because I
tried but was not successful getting anything shown.

TIA

Lorenz Lenhardt
Marli_und_Lorenz_Lenha...@csi.com
Griesheim Germany

Re:Can't see TDragObject.DragImage when dragging over other VC's


On Fri, 14 Nov 1997 16:13:10 GMT, cwe...@bates-dorland.co.uk (Chris

Quote
Welsh) wrote:

...

Quote
>I have worked around it by subclassing all components, and modifying
>the Create constructor to add csDisplayDragImage to the ControlStyle,
...
>Possibly one can do this at runtime, altho i doubt it. My solution is
>pretty horrific, when you start to think about it.

I'm not sure, but there should be an Event that is triggert after a
form and all it's child controls have been created.
this event you can use to iterating throu the components list of the
form adding csDisplayDragImage to the ControlStyle set of all of them

HTH

Lorenz Lenhardt
Marli_und_Lorenz_Lenha...@csi.com
Griesheim Germany

Re:Can't see TDragObject.DragImage when dragging over other VC's


Quote
> I'm not sure, but there should be an Event that is triggert after a
> form and all it's child controls have been created.
> this event you can use to iterating throu the components list of the
> form adding csDisplayDragImage to the ControlStyle set of all of them

Try redefining the Loaded method:

procedure Txxx.Loaded;
begin
  inherited;
  //Change here all the ControlStyles to include csDisplayDragImage
end;

Saludos,
        Javier
        Spain
        ;)

Re:Can't see TDragObject.DragImage when dragging over other VC's


This seems to work pretty well:

procedure SetDragAccept(Form : TForm);
var
  i : integer;
begin
  for i := 0 to Form.componentcount - 1 do begin
    if (Form.components[i] is TControl) then
      (Form.components[i] as TControl).ControlStyle :=
        (Form.components[i] as TControl).ControlStyle +
       [csDisplayDragImage];
  end;
end;

Then in the Form's FormCreate event, simply call
  SetDragAccept(Self);

Re:Can't see TDragObject.DragImage when dragging over other VC's


Quote
> This seems to work pretty well:

Yep. But only optimize it a little:

Quote
> procedure SetDragAccept(Form : TForm);
> var
>   i : integer;
> begin

    With Form Do
     for i := 0 to componentcount - 1 do begin
       if (components[i] is TControl) then
         with TControl(components[i]) Do
           ControlStyle := ControlStyle + [csDisplayDragImage];
   end;
Quote
> end;

> Then in the Form's FormCreate event, simply call
>   SetDragAccept(Self);

Other Threads