zoukankan      html  css  js  c++  java
  • VC++6.0注释及取消快捷键设置

    注释快捷键在程序编程当中的作用相当明显,提高了编程效率。我在网上找到了一个在VC++6.0工具中添加注释快捷键的方法,VC++6.0是以VB为脚本来配置的。

    首先,找到VC++6.0的安装路径,假设在:D:Program Files (x86)Microsoft Visual Studio 6.0,那么进入到CommonMSDev98Macros目录下,全路径为:D:Program Files (x86)Microsoft Visual Studio 6.0CommonMSDev98Macros。

    在该目录新建一个文本文件,并重命名为:comment.dsm,并打开增加以下内容:


    Sub CustomCommentOut()  
    'DESCRIPTION: 注释/取消注释宏,可处理VB和C++、Java注释  
        Dim win  
        set win = ActiveWindow  
        If win.type <> "Text" Then  
          MsgBox "This macro can only be run when a text editor window is active."  
        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  
    
    
    
    
    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

    此时打开VC++6.0窗口,以下步骤:

    1.打开菜单栏"Tools" -> "Customize" 打开了"Customize"对话框。

    2.

    3.


    4.在代码中,只需要选中代码或者在光标所在行,执行快捷键"Ctrl + /",进行注释或取消注释。

  • 相关阅读:
    第九十一天 how can I 坚持 技术-永远的技术
    第九十天 how can I 坚持
    Java控制台中输入中文输出乱码的解决办法
    【体系结构】转移预测器设计与比较1
    Ubuntu 13.04 用Sublime Text 2 编译运行 JAVA
    HDU 4605 Magic Ball Game (在线主席树|| 离线 线段树)
    个人重构机房收费系统之报表
    快速排序的递归和非递归实现
    HDU 3721 Building Roads (2010 Asia Tianjin Regional Contest)
    体验决定深度,知识决定广度。你的人生是什么呢? 操蛋和扯蛋没必要纠结 唯有继续
  • 原文地址:https://www.cnblogs.com/wangxueliang/p/9346504.html
Copyright © 2011-2022 走看看