怎么样在VC++6.0中添加和取消批量注释的功能
首先打开VC++6.0,选择“文件”,然后选择要新建的文件类型。并给文件起名字设置文件要保存的位置,如下图:
单击“OK“后,填写相应的描述,如下图:
单击“OK”,然后输入代码,单击保存后,关闭vc++6.0。如下图:
文中代码如下:Sub SetSelNote()'Sun DESCRIPTION: 过程SetSelNote 用于将选中的文本转换为注释dim CurWin '当前获得的窗口set CurWin = ActiveWindowif CurWin.type<>"Text" Then '判断当前窗口是否是文本窗口MsgBox "当前窗口不是代码窗口"elseNoteType = "//" BeginLine = ActiveDocument.Selection.TopLine EndLine = ActiveDocument.Selection.BottomLineif EndLine < BeginLine thenLine = BeginLineBeginLine = EndLineEndLine = Lineelsefor row = BeginLine To EndLine ActiveDocument.Selection.GoToLine row ActiveDocument.Selection.SelectLine'选中当前行 ActiveDocument.Selection = NoteType + ActiveDocument.SelectionNextEnd ifEnd ifEnd Sub
Sub CancelSelNote()dim CurWin '当前获得的窗口set CurWin = ActiveWindowif CurWin.type<>"Text" Then '判断当前窗口是否是文本窗口 MsgBox "当前窗口不是代码窗口"else BeginLine = ActiveDocument.Selection.TopLine EndLine = ActiveDocument.Selection.BottomLineif EndLine < BeginLine thenLine = BeginLineBeginLine = EndLineEndLine = Lineelsefor 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 ifNextEnd ifEnd ifEnd Sub这样在你刚才设置的位置就生成了一个.dsm文件,如下图:
打开一个C++工程,按照图片中的操作选择 Tool(工具)——>Customize(定制)。如下图:
选择Add--ins and Macro File(附加项和宏文件),选择刚才制作的文件Node.dsm,如下图:
勾选上Node,如下图:
选择命令, 在 类别 中选择Macros ,如下图:
将鼠标按住 SetSelNote,将其拖到工具栏中,会弹出下面的对话框:
从这里面随便选一个你喜欢的图标,单击OK,用于做“批量注释”的图标
CancelSelNote的做法与SetSelNote一样。
最后在工具栏中,就出现了你自己定义的批量注释和消除批量注释的图标了。