views:

154

answers:

2

My wife complains that I have too many icons on the Windows XP-Pro desktop.

I like to be able to quickly drop a file onto the icon for application I want to have open it. And I like to follow a link to open often-used deeply nested folders rather than navigate there. Thus, I have over 100 icons on the desktop.

(We share the same user account because we switch back and forth so often and because we both need to access the same e-mail, so separate accounts isn't the answer.)

I'd like to write a program which would have similar functionality to the Windows desktop. Then I could open that window to do the drag and drop work, but, when minimized, would leave the desktop display sparsely populated for my wife. As an added bonus, I could implement better organization of the icons than the desktop allows.

This is similar to what an Explorer window does, with the key exception that the desktop allows you to do some arrangement of icons. (For instance, program icons on the left (with the most used ones near the top), folders at the top, data files on the right.)

  1. How do I go about getting an icon to display in a Windows Form (or on an appropriate control on the form)? (For instance, if I drop in a link to Notepad or a link to a file folder.)

  2. How do I take the same action that the desktop does if the icon is double clicked? (For instance, if a link to a folder is double clicked.)

  3. How do I take the same action that the desktop does if the icon has something dragged onto it? (For instance, a text file is dragged onto the Notepad icon.)

I'm using Visual Studio and C#.NET for programming.

I know how to do basic drag and drop.

I do not know:
A. what controls to use on the form to display the icons
B. how to find the icon
C. what commands are built by the desktop under various situations (so I can emulate the functionality)

I apologize that this is a multi-part question, but it was hard to break apart without explaining the whole story again.

A: 

This is a big question, but I'll give you some quick thoughts to get things moving in the right direction. WinForms exposes the functionality needed to make this happen, it's just a matter of wiring everything up the way you want it.

The key piece that you will want to look into is Drag/Drop, which is very well supported by WinForms. If you implement your icons as ImageBoxes you can set the AllowDrop property on the program icons and then handle the DragDrop event and have it call an overload of System.Diagnostics.Process() to start the application with the dropped filename as an argument.

As far as finding icons, most programs have their icon included as a resource in their .EXE file or in a related .DLL.

Regarding question C, the underlying question is what behaviors of the desktop would you like to have in your program? Explorer.exe is a massive application that does far more than what you need or what you will need or want to implement. Once you decide what functionality you want, play around with the IntelliSense list of events for the form and imagebox controls. You'll find that a lot of behavior is given to you for free in the Windows common controls, and additional behavior is fairly easy to add by handling the appropriate events.

Phillip Knauss
Thanks for the reply.The behaviors that I want are the ones listed in the original question: add a program icon via drag/drop, open a program icon via double click, drop an item on a program icon and have that program open the dropped item. Most additional 'features' in Explorer I don't like and don't want.
Mark T
That question was in response to question C specifically, the other features you mention are covered elsewhere.A cool feature of drag/drop is that it works between WInForms and other parts of windows, so you can set your main form's AllowDrop property, and then drag icons from your desktop onto the form to create a new ImageBox appropriate to that program. You can open the program via double-click by calling System.Diagnostics.Process("program") in the DoubleClick event handler for the icon boxes.
Phillip Knauss
A: 

Why dont you just use a Virtual Desktop??

Try http://virtuawin.sourceforge.net/

You will skip a lot of coding.

Right from their page: "VirtuaWin is a virtual desktop manager for the Windows operating system (Win9x/ME/NT/Win2K/XP/Win2003/Vista). A virtual desktop manager lets you organize applications over several virtual desktops (also called 'workspaces'). Virtual desktops are very common in Unix/Linux, and once you get accustomed to using them, they become an essential part of a productive workflow."

Luis Lobo Borobia
Thanks for the suggestion. I had trouble with Visual Studio not playing nicely with VirtuaWin... but I'll update to the newest build and try again. I've loved using multiple desktops on UNIX for years.But this doesn't totally address the icon issue. All icons that I use would be on all my virtual desktops, including an e-mail one shared with my wife.
Mark T