首页 > 编程语言 > 详细

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

时间:2019-10-25 13:45:21      阅读:149      评论:0      收藏:0      [点我收藏+]

VC++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

来自 <http://blog.163.com/fantasy_sunny/blog/static/195918212201222504855353/>


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

原文:https://www.cnblogs.com/qiulidong/p/11736982.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!