Microsoft Visual Studio 2005 Unleashed翻译请教【2】

本文介绍了一种使用宏代码编辑器编辑宏的方法,通过创建递归助手程序处理UIHierarchyItem对象,调整其属性并进行子项遍历。此外,还介绍了如何初始化窗口对象并获取UIHierarchy的根节点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. (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)递归的调用这个程序。

  2. 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对象的根节点。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值