您的位置:首页 > 编程语言 > C语言/C++

如何在VC++6.0中添加批量注释和取消批量注释的功能

2013-11-09 15:07 579 查看
C++6.0开发环境虽然有丰富的功能,但是没有提供批量注释和取消批量注释的功能。

这里,我们用VBScript脚本来添加这个功能。

1.首先打开VC++6.0,选择File/New,然后选择要新建的文件类型。



2.点击确定后,填写相应的描述。



3.然后输入代码,点击保存后,关闭VC++6.0。



这样就在文件夹中生成了一个 .dsm 文件。



4. 打开一个C++工程,按照图片中的操作选择 工具——>定制 。



5. 选择 附加项和宏文件,选择刚才制作的文件node.dsm。



6. 勾上node。



7. 选择 命令, 在 类别 中选择 Macros 。





8. 将 鼠标 按住 SetSelNote ,将其拖到工具栏中,会弹出下面的对话框。



9. CancelSelNote的做法与SetSelNote一样。

10. 最后在工具栏中,就出现了你自己定义的批量注释和消除批量注释的图标了。



=====================================================================================================

文中的代码:

'------------------------------------------------------------------------------

'FILE DESCRIPTION: 为开发环境添加批量注释或取消注释

'------------------------------------------------------------------------------

Sub SetSelNote()'Sun DESCRIPTION: 过程SetSelNote 用于将选中的文本转换为注释

dim CurWin '当前获得的窗口

set CurWin = ActiveWindow

if CurWin.type<>"Text" Then '判断当前窗口是否是文本窗口

MsgBox "当前窗口不是代码窗口"

else

NoteType = "//"

BeginLine = ActiveDocument.Selection.TopLine

EndLine = ActiveDocument.Selection.BottomLine

if EndLine < BeginLine then

Line = BeginLine

BeginLine = EndLine

EndLine = Line

else

for row = BeginLine To EndLine

ActiveDocument.Selection.GoToLine row

ActiveDocument.Selection.SelectLine'选中当前行

ActiveDocument.Selection = NoteType + ActiveDocument.Selection

Next

End if

End if

End Sub

Sub CancelSelNote()

dim CurWin '当前获得的窗口

set CurWin = ActiveWindow

if CurWin.type<>"Text" Then '判断当前窗口是否是文本窗口

MsgBox "当前窗口不是代码窗口"

else

BeginLine = ActiveDocument.Selection.TopLine

EndLine = ActiveDocument.Selection.BottomLine

if EndLine < BeginLine then

Line = BeginLine

BeginLine = EndLine

EndLine = Line

else

for row = BeginLine To EndLine

ActiveDocument.Selection.GoToLine row

ActiveDocument.Selection.SelectLine'选中当前行

SelBlock = ActiveDocument.Selection

Trim(SelBlock)

pos = instr(SelBlock,"//")

if pos <>0 then

RightBlock = Right(SelBlock, Len(SelBlock)-2)

ActiveDocument.Selection = RightBlock

End if

Next

End if

End if

End Sub
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: