首先在根目录下找到你的vc++6.0,个人是在c盘的一个叫MSDev98的文件夹里,打开文件夹后,在Macros文件夹中有下面的文件:java
找到以后,先新建一个文本框,并命名为comment.dsm,最开始的时候,我直接把程序粘贴到文本框里,保存后,发现是txt的格式,而后想在属性里改格式,可是没能成功。以后百度过不少转换格式的,包括暴风影音也能够在文件下的工具里转换dsm文件。最后是在无心间看到一个问题的回答,终于解决了问题。c++
在记事本里面把txt转换成其余格式的方法:另存为的时候,选择保存类型为全部文件,而后在文件名中输入文件名,并输入你要的格式的后缀,好比我输入的是commend.dsm(其实应该是comment)网络
在记事本里面输入如下程序,ide
Sub CustomCommentOut() 工具
'DESCRIPTION: 注释/取消注释宏,可处理VB和C++、Java注释 spa
Dim win orm
set win = ActiveWindow blog
If win.type <> "Text" Then 资源
MsgBox "This macro can only be run when a text editor window is active." get
Else
TypeOfFile = 3
If TypeOfFile > 0 And TypeOfFile < 6 Then
If TypeOfFile > 3 Then
CommentType = "'" ' VB注释
CommentWidth = 1
Else
CommentType = "//" ' C++、java 注释
CommentWidth = 2
End If
StartLine = ActiveDocument.Selection.TopLine
EndLine = ActiveDocument.Selection.BottomLine
If EndLine < StartLine Then
Temp = StartLine
StartLine = EndLine
EndLine = Temp
End If
' 单行
If EndLine = StartLine Then
ActiveDocument.Selection.StartOfLine dsFirstColumn
ActiveDocument.Selection.CharRight dsExtend, CommentWidth
If ActiveDocument.Selection = CommentType Then
ActiveDocument.Selection.Delete
Else
ActiveDocument.Selection.StartOfLine dsFirstText
ActiveDocument.Selection.CharRight dsExtend, CommentWidth
If ActiveDocument.Selection = CommentType Then
ActiveDocument.Selection.CharRight dsExtend
ActiveDocument.Selection.Delete
Else
ActiveDocument.Selection.StartOfLine dsFirstText
ActiveDocument.Selection = CommentType + vbTab + _
ActiveDocument.Selection
End If
End If
' 多行
Else
For i = StartLine To EndLine
ActiveDocument.Selection.GoToLine i
CommentLoc = dsFirstColumn
ActiveDocument.Selection.StartOfLine CommentLoc
ActiveDocument.Selection.CharRight dsExtend, CommentWidth
If ActiveDocument.Selection = CommentType Then
ActiveDocument.Selection.Delete
Else
ActiveDocument.Selection.StartOfLine CommentLoc
ActiveDocument.Selection = CommentType + _
ActiveDocument.Selection
End If
Next
End If
Else
MsgBox("Unable to comment out the highlighted text" + vbLf + _
"because the file type was unrecognized." + vbLf + _
"If the file has not yet been saved, " + vbLf + _
"please save it and try again.")
End If
End If
End Sub
成功后的文件应该是这样的:
以后打开vc++6.0, 工具->定制->附加项和宏文件,选择commend以下:(英文版的相似)
再选择命令,在下拉选项中选择Macros,出现以下的,拖动CustomCommentOut放置在工具栏里
拖动后出现以下界面,选择本身喜欢的方式便可:
出现的效果以下:
我以为在这个过程当中,网络的资源特别重要,不懂得多在网上查找,多看一些资料和回答,让我对一个我不清楚的问题认识的更清楚,印象也更深入。