简体   繁体   English

窗口中的桌面图标功能

[英]desktop icon functionality in a window

My wife complains that I have too many icons on the Windows XP-Pro desktop. 我的妻子抱怨我在Windows XP-Pro桌面上图标太多。

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. 因此,我在桌面上有100多个图标。

(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. 我想编写一个程序,该程序具有与Windows桌面相似的功能。 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)? 如何使图标显示在Windows窗体(或窗体上的适当控件)上? (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. 我正在使用Visual Studio和C#.NET进行编程。

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 A.在窗体上使用哪些控件来显示图标
B. how to find the icon B.如何找到图标
C. what commands are built by the desktop under various situations (so I can emulate the functionality) C.桌面在各种情况下会生成什么命令(因此我可以模拟功能)

I apologize that this is a multi-part question, but it was hard to break apart without explaining the whole story again. 抱歉,这是一个包含多个部分的问题,但是如果不重新解释整个故事就很难分开。

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. WinForms公开了实现此功能所需的功能,这只是将所有内容按所需方式进行布线的问题。

The key piece that you will want to look into is Drag/Drop, which is very well supported by WinForms. 您将要研究的关键部分是“拖放”,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. 如果将图标实现为ImageBoxes,则可以在程序图标上设置AllowDrop属性,然后处理DragDrop事件,并让它调用System.Diagnostics.Process()的重载以使用删除的文件名作为参数来启动应用程序。

As far as finding icons, most programs have their icon included as a resource in their .EXE file or in a related .DLL. 至于查找图标,大多数程序的图标都作为资源包含在其.EXE文件或相关的.DLL中。

Regarding question C, the underlying question is what behaviors of the desktop would you like to have in your program? 关于问题C,潜在的问题是您希望程序中桌面具有哪些行为? Explorer.exe is a massive application that does far more than what you need or what you will need or want to implement. Explorer.exe是一个庞大的应用程序,其功能远远超出您的需求,所需的或想要实现的。 Once you decide what functionality you want, play around with the IntelliSense list of events for the form and imagebox controls. 一旦确定了所需的功能,就可以处理表单和图像框控件的事件的IntelliSense事件列表。 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. 您会发现Windows通用控件中免费提供了许多行为,并且通过处理适当的事件来添加其他行为相当容易。

Why dont you just use a Virtual Desktop?? 您为什么不只使用虚拟桌面?

Try http://virtuawin.sourceforge.net/ 试试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." 在他们的页面上:“ VirtuaWin是Windows操作系统(Win9x / ME / NT / Win2K / XP / Win2003 / Vista)的虚拟桌面管理器。虚拟桌面管理器使您可以在多个虚拟桌面(也称为“工作区”)上组织应用程序虚拟桌面在Unix / Linux中非常普遍,一旦您习惯了使用虚拟桌面,它们便成为高效工作流程的重要组成部分。”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM