gpt4 book ai didi

visual-studio - DTE.ExecuteCommand(“Edit.NextBookmark”)

转载 作者:行者123 更新时间:2023-12-04 07:29:22 27 4
gpt4 key购买 nike

使用VS2010

感谢汉斯(因为我要低调地回答我自己的问题8个小时)

 Sub CreateBreakPoint()

Dim doc As TextDocument = _
CType(DTE.ActiveDocument.Object("TextDocument"), TextDocument)
Dim point As EditPoint = doc.StartPoint.CreateEditPoint

While point.NextBookmark()
Try
point.ClearBookmark()
DTE.Debugger.Breakpoints.Add("", DTE.ActiveDocument.FullName, point.Line(), 1, "", dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, "c#", "", 0, "", 0, dbgHitCountType.dbgHitCountTypeNone)
Catch ex As Exception
MsgBox("error: " + ex.Message)
End Try
End While
MsgBox("Done")

End Sub


我有一个宏,它将在每个书签处设置断点。它可以工作(就像大锤一样)...但是出于好奇,我该如何执行以下一项操作,以便可以使用“适当的” For循环


检索书签对象列表(表面上带有行号属性)
检查DTE.ExecuteCommand(“ Edit.NextBookmark”)返回false或某些迹象表明我已经到达了最后一个书签
检索具有特定“查询”的书签对象的列表,因此我不必先删除所有当前的书签


当前代码

Public Module BookMarksToBreakPoints


Sub TemporaryMacro()
Dim bookmarkWin As Window = DTE.Windows.Item(WindowKinds.vsWindowKindBookmarks)

While True
Try
DTE.ExecuteCommand("Edit.NextBookmark")
DTE.ExecuteCommand("Edit.ToggleBookmark")
DTE.ExecuteCommand("Debug.ToggleBreakpoint")
Catch e As Exception
MsgBox("Done")
Exit While
End Try
End While

End Sub
End Module

最佳答案

感谢Hans Passant朝着正确的方向前进。最后的宏:

Sub CreateBreakPoint()

Dim doc As TextDocument = _
CType(DTE.ActiveDocument.Object("TextDocument"), TextDocument)
Dim point As EditPoint = doc.StartPoint.CreateEditPoint

While point.NextBookmark()
Try
point.ClearBookmark()
DTE.Debugger.Breakpoints.Add("", DTE.ActiveDocument.FullName, point.Line(), 1, "", dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, "c#", "", 0, "", 0, dbgHitCountType.dbgHitCountTypeNone)
Catch ex As Exception
MsgBox("error: " + ex.Message)
End Try
End While
MsgBox("Done")

End Sub

关于visual-studio - DTE.ExecuteCommand(“Edit.NextBookmark”),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7731231/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com