-
(You edit macro code using the code editor just as you would to edit any other document with Visual Studio.) To rework this macro, you can start by establishing a recursive helper routine that takes in a UIHierarchyItem object, toggles its Expanded property to True, and calls itself for each sub item found in the UIHierarchyItems collection:
(
For Each subNode As UIHierarchyItem In node.UIHirerarchyItems
ExpandNodes(subNode)
Next
node.UIHierarchyItems.Expanded = True
)
【说明】括号中为辅助理解。文中并没有给出递归程序的签名,但是很容易猜出应该是:Sub ExpandNodes(UIHierarchyItem node)。
【难点】如何组织成符合汉语习惯的语序。
【目前翻译】(使用宏代码编辑器编辑宏和在Visual Studio中编辑其他文档的方式没什么两样。)回到刚才的宏,首先你可以创建一个递归的助手(工具??)程序,在这个程序以UIHierarchyItem对象为参数(后面未贴出的部分代码中显示确实将UIHierarchyItem作为参数,这里作者使用take in,也暗示了这一点),把它的Expanded属性(译者注:实际上是它的子项的集合UIHierarchyItems的属性)设置为True,并且对其子项集合UIHierarchyItems中的每一项(译者注:也是UIHierarchyItem)递归的调用这个程序。
-
Then, to kick things off, you need a parent, controlling routing that instantiates a window object (representing the Solution Explorer) and grabs the root-level UIHierarchy object from the window.
【说明】继续讨论上一段中的递归程序。
【难点】仍然是语言习惯问题。
【目前翻译】所以,我们需要一个控制程序来启动这个递归程序,一方面我们需要从这个控制程序获得窗口对象(即解决方案资源管理器),同时我们还需要从这个窗口中获得UIHierarchy对象的根节点。
Microsoft Visual Studio 2005 Unleashed翻译请教【2】
最新推荐文章于 2023-06-13 23:30:57 发布