Delph / Builder drags the image, the image disappears when you exit the control mode

I have a tree control that implements drag and drop. I use the overridden OnStartDrag () to get my own TDragObjectEx that shows the image when dragging. This works fine in the control tree, but as soon as I leave the control tree, the image disappears. The cursor remains, though.

I tried to implement OnDragOver to reset the image, but it does not work.

Any hints of this? I am using C ++ builder 2010, but delphi will do the same.

Update: The found csDisplayDragImage parameter for each control in the form elements, and in the form itself, solves this problem. Is there some automated way to set csDisplayDragImage in its entire form, rather than manually setting it to Create for each element?

void __fastcall TForm1::FormCreate(TObject *Sender)
{
    ControlStyle << csDisplayDragImage;
    RMU->ControlStyle << csDisplayDragImage;
    Button1->ControlStyle << csDisplayDragImage;
}
+3
source share
2 answers

If I remember correctly, you should include the [csDisplayDragImage] flag in the "ControlStyle" of the controls for which you want drag and drop images to display in sth. dragged through them.

Update: setting the "AlwaysShowDragImages" of the DragObject object will display the drag and drop image on the entire desktop.

+4
source

, , , csDisplayDragImage . chilren :

void AddDisplayDragImageStyle(TControl* ctl)
{
  ctl->ControlStyle << csDisplayDragImage;
  TWinControl* win = dynamic_cast<TWinControl*>(ctl);
  if (win)
    for (int i = 0; i < win->ControlCount; ++i)
      AddDisplayDragImageStyle(win->Controls[i]);
}

, : AddDisplayDragImageStyle(this).

0

Source: https://habr.com/ru/post/1731964/


All Articles