0

To thwart the nit-pickers, let me start with, I searched here with this and could not find an answer, and yes, also I did scroll through the "Similar questions."... Adding shortcuts to a TForm

I want to drag and drop some shortcuts from the Desktop to a TForm in my application. I am using Anders Melander's brilliant Drag Drop Suite (DDS).

I tried putting a TImage on the form but the DDS does not drop to an Image so I added a TPanel with a TImage on it. I could then drop on the panel and assign the image to the TImage.Picture. Problem was the Panel has no Transparent Property so the shortcut on the form looks clunky with the visible Panel behind it.

I need to be able to drop to the TImage or make the underlying TPanel transparent.

Can anyone help with code-snippets for either of those options, or better yet, a method of dropping a Shortcut directly on to my Form.

Thanks

user983145
  • 219
  • 1
  • 3
  • 12

2 Answers2

3

Coincidentally I needed to make a TWinControl (the base for every visible control with a window handle, including TPanel) transparent. I found numerous results and applied them to this answer.

It's been a while since I implemented drag and drop, but I assume you call some API and pass it the handle of the panel? That answers the question why you can't use TImage. TImage is a graphic control, a control without a handle, that relies on its parent for recieving messages and drawing itself.

It should be possible to use the form, though, since that has a handle too.

Community
  • 1
  • 1
GolezTrol
  • 114,394
  • 18
  • 182
  • 210
1

If the TImage is directly on the TForm, then let the TForm handle the drop, no TPanel needed. OLE Drag&Drop operations (which Ander's components implement) provide coordinates where dragging and dropping occurs. The TForm should be able to detect when a drag is over the area occupied by the TImage and what type of data is being dragged, and only allow dropping of supported types within that area, extracting the dropped data and updating the TImageas needed, and denying anything else that does not match that criteria.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770