如何在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
这里,我们用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
相关文章推荐
- C++读写文件
- C语言文件读写函数介绍
- C语言占位符总结
- C++回顾一
- (转载) C/C++编译和链接过程详解 (重定向表,导出符号表,未解决符号表)
- 实战基于Leap Motion体感外设使用Win32(VC++)环境配置
- C++中关于const的思考
- C语言中的无符号扩展和带符号扩展
- c语言中字符数组和数字的相互转换函数
- c语言通过89C51驱动1602液晶显示(入门级别)
- 如何在C++项目中引用Lib文件
- ACM题目中输入数据的处理(C++语言版)
- c++静态库与动态库的区别 .
- C++中public,protected,private的区别
- 抄书:C++ string
- c/c++内存泄漏检测
- C++ - 类的赋值操作 使用 "复制-交换(copy and swap) 技术" 详解
- C++ - 类的赋值操作 使用 "复制-交换(copy and swap) 技术" 详解
- 八皇后C++完整程序
- C++中自己理解的一些细节哈