0

Background

I want to drag "icons" from the desktop on to my form, they will then be visualised on the form, not changing in appearance.

When i say "icon", i mean shortcuts, folders and application icons.

Example

enter image description here

Question

What is the best way of recreating the icons on the form. Is there a tried and tested way, or do you have to recreated them using picture boxes and labels?

What I've Tried so Far?

  • Picture boxes
  • Forms

I've had limited success with both, with the latter being the best so far. However both have their limitations.

Notes.

I do not need help with other areas of my problem like, how to drag icons, extracting icons, etc. It's purely just recreating the icon visually i'm struggling with.

8
  • Mind using WPF? WinForms is not the best for doing these sort of things Dec 6, 2015 at 10:32
  • @Farnan Anan, Sorry,I have absolutely no experience with WPF.
    – KingCundy
    Dec 6, 2015 at 10:35
  • What about using a ListView? Dec 6, 2015 at 10:42
  • I think i would like to stay on the track of the icon appearing as if it has seamlessly moved from the desktop to the form, and then dropped into my application. A list view would change the aesthetics a little.
    – KingCundy
    Dec 6, 2015 at 10:48
  • 1
    You are only focusing on the way it looks but don't seem to have much an idea of what these icons actually represent. There are hundreds of megabytes of gritty compiled C++ code behind it that you cannot easily see. Explorer is a very non-trivial chunk of code. Just that tiny little arrow in the lower left corner takes a lot of glue to display the correct overlay icon and allow an application to select a custom one and change it. Replacing Explorer is the kind of project that is only ever started but never finished. Dec 6, 2015 at 11:44

1 Answer 1

0

Use a ListView and set the view property to LargeIcon.

You can obtain the icons through: Icon.ExtractAssociatedIcon. However, you may need to manage the icons as two files with the same extension may have different icons.

If you only want the image, then you can grab just the icon portion of the control after it's painted.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.