Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 编程语言 > C/C++ > 关于MSVC的一些宏
【标  题】:关于MSVC的一些宏
【关键字】:MSVC
【来  源】:http://blog.csdn.net/wswms/archive/2006/09/08/1193397.aspx

关于MSVC的一些宏

Your Ad Here

Build Duration

 

Sub Application_BeforeBuildStart()
    
' keep the build-starting time
    dBuildStartTime = Now
    Application.PrintToOutputWindow 
" "
    Application.PrintToOutputWindow 
"--------------------------------"
    Application.PrintToOutputWindow 
"Build start: " & dBuildStartTime
End Sub

Sub Application_BuildFinish(nNumErrors, nNumWarnings)
    
    
' get build time
    dNow = Now

    sec 
= DateDiff("s", dBuildStartTime, dNow)

    hours 
= sec  3600
    sec 
= sec - hours * 3600

    min 
= sec  60
    sec 
= sec - min * 60

    
' format
    Dim strH, strM, strS

    
If hours > 10 Then
        strH 
= hours
    
Else
        strH 
= "0" & hours
    
End If

    
If min > 10 Then
        strM 
= min
    
Else
        strM 
= "0" & min
    
End If

    
If sec > 10 Then
        strS 
= sec
    
Else
        strS 
= "0" & sec
    
End If

    
' display
    Application.PrintToOutputWindow "Build end:   " & dNow
    Application.PrintToOutputWindow 
"Build time:  " & strH & ":" & strM & ":" & strS
    Application.PrintToOutputWindow nNumWarnings 
& " warning(s), " & nNumErrors & " error(s)."

End Sub

  Macros to go to beginning or end of function body, and to find corresponding function definition.

 

Sub GoToBeginOfFunction()
'DESCRIPTION: Go to the previous { which is at the beginning of a line.
    set sel = ActiveDocument.Selection
    sel.Cancel
    sel.FindText 
"^{", dsMatchBackWard + dsMatchRegExpE
    sel.StartOfLine
End Sub

Sub GoToEndOfFunction()
'DESCRIPTION: Go to the next } which is at the beginning of a line.
    set sel = ActiveDocument.Selection
    sel.Cancel
    sel.FindText 
"^}", dsMatchRegExpE
End Sub

Sub FindFunction()
'DESCRIPTION: Open corresponding .h or .cpp file and 
'
find the function definition.

    
Set sel = ActiveDocument.Selection
    sel.WordRight
    sel.WordLeft dsExtend
    str 
= sel

    
if (right(activedocument.name, 2= ".h"then
    
' now in .h, open cpp and find the function
        filename = activedocument.path & "" & _
          
mid(ActiveDocument.name, 1len(ActiveDocument.name) - 2& ".cpp"
        documents.Open filename
        
set s1 = ActiveDocument.Selection
        s1.Cancel
        
if s1.FindText ("::" & str & "(", dsMatchFromStart) = false then
            s1.FindText 
" " & str & "("
        
end if

    
else
    
' now in .cpp, open .h and find the function
        if (right(activedocument.name, 4= ".cpp"then
            filename 
= activedocument.path & "" & _
              
mid(ActiveDocument.name, 1len(ActiveDocument.name) - 4& ".h"
            documents.Open filename
            
set s1 = ActiveDocument.Selection
            s1.Cancel
            s1.FindText str 
& "(", dsMatchFromStart
        
end if
    
end if
End Sub

Filter build output and add sound

 

Solution
To install the macro put it in your macro file under EnviromentEvents() function.

Here 
is the macro:

Declare 
Function sndPlaySound Lib "winmm.dll" _ 
    Alias 
"sndPlaySoundA" (ByVal lpszSoundName As String, _ 
    ByVal uFlags 
As LongAs Long 
  
  
     
Public Declare Function waveOutGetNumDevs Lib "winmm" () As Long 
     
'just after the sound is ended Exit Function 
     Const SND_SYNC = &H0 
     
'just after the beginning of the sound Exit Function 
     Const SND_ASYNC = &H1 
     
'if the sound cannot be found no Error message 
     Const SND_NODEFAULT = &H2 
     
'repeat the sound until the Function is called again 
     Const SND_LOOP = &H8 
     
'if currently a sound is played the 
     'Function will return without playing the selected sound 
     Const SND_NOSTOP = &H10 
     
Const Flags& = SND_ASYNC Or SND_NODEFAULT 
  
     
Public Sub BuildEvents_OnBuildDone(ByVal _
         Scope 
As EnvDTE.vsBuildScope, _ 
         ByVal Action 
As EnvDTE.vsBuildAction) Handles _ 
         BuildEvents.OnBuildDone 
  
         
' Create a tool window handle for the Output window. 
         Dim win As Window = 
           DTE.Windows.Item(EnvDTE.Constants.vsWindowKindOutput) 
         
' Create handles to the Output window and its panes. 
         Dim OW As OutputWindow = win.Object 
         
Dim OWp As OutputWindowPane 
         
Dim Loc As Integer 
  
         OWp 
= OW.OutputWindowPanes.Item(1
         OWp.TextDocument.Selection.SelectAll() 
         
Dim Context As String = OWp.TextDocument.Selection.Text 
         OWp.TextDocument.Selection.CharLeft() 
  
         Loc 
= InStr(Context, "---------- Done -----------"
  
         OWp 
= OW.OutputWindowPanes.Item(2
         OWp.Activate() 
         OWp.Clear() 
         OWp.OutputString(
Mid(Context, 1, Loc - 7)) 
         OWp.TextDocument.Selection.GotoLine_
                 (OWp.TextDocument.EndPoint().Line()) 
  
         
'Play sounds 
         If InStr(Context, "0 error(s)"= 0 Then 
             sndPlaySound(
"Error.wav", SND_SYNC) ' Edit
         ElseIf InStr(Context, "0 warning(s)"= 0 Then 
             sndPlaySound(
"Warning.wav", SND_SYNC) ' Edit
         Else 
             sndPlaySound(
"Fine.wav", SND_SYNC) ' Edit
         End If 
  
     
End Sub
Don
't forget to edit the wav file names to suit it to your needs. After that go back to your project and work as usual.

source code to HTML

 

Sub Src2Html()
        DTE.UndoContext.Open(
"ToHTML"
)
        Try
            DTE.Find.Target 
=
 vsFindTarget.vsFindTargetCurrentDocumentSelection
            DTE.Find.MatchCase 
= True

            DTE.Find.MatchWholeWord 
= False
            DTE.Find.MatchInHiddenText 
= False
            DTE.Find.PatternSyntax 
= vsFindPatternSyntax.vsFindPatternSyntaxLiteral
            DTE.Find.ResultsLocation 
=
 vsFindResultsLocation.vsFindResultsNone
            DTE.Find.Action 
=
 vsFindAction.vsFindActionReplaceAll

            DTE.Find.FindWhat 
= "&"

            DTE.Find.ReplaceWith 
= "&"
            DTE.Find.Execute()

            DTE.Find.FindWhat 
= "<"
            DTE.Find.ReplaceWith 
= "<"
            DTE.Find.Execute()

            DTE.Find.FindWhat 
= ">"
            DTE.Find.ReplaceWith 
= ">"
            DTE.Find.Execute()

            DTE.ActiveDocument.Selection.Untabify()
            DTE.ActiveDocument.Selection.Copy()
        Finally
            DTE.UndoContext.Close()
            DTE.ActiveDocument.Undo()
        
End Try

    
End Sub

Upper case -> Lower case -> Capitalized case

Sub MakeCaseUpperLower()
Dim doc
set doc = ActiveDocument 

' Be sure active document is a text document
if doc Is Nothing Then
Exit Sub
elseif doc.Type <> "Text" Then
Exit Sub
End If 

strSelected 
= doc.Selection
strNewUCase 
= ""
strNewLCase 
= ""

strNewUCase 
= UCase(strSelected)
strNewLCase 
= LCase(strSelected)
' Upper case -> Lower case
if( strNewUCase = strSelected ) then
doc.Selection 
= LCase(strSelected)
' Lower case -> Capitalized Case
elseif strNewLCase = strSelected Then
doc.Selection 
= Left(strNewUCase,1+ Right(strNewLCase, Len(strNewLCase)-1)
' Capitalized Case
else
doc.Selection 
= strNewUCase
End if
End Sub 
怎么会这样?delete [] 了,还能用!!!:【上一篇】
这是我们可以改写一下刚才那个程序,运行结果同刚才一样:【下一篇】
【相关文章】
  • MSVCRT.lib(MSVCRT.dll) : error LNK2005问题
  • 【随机文章】
  • 利用C++Builder在Windows“开始”按钮上绘图
  • Oracle 8i 到 9i 升级之路
  • VS2005中的Project Templates
  • linux心得(redhat 9)
  • RUP中的几种Iteration pattern(二):Evolutionary Lifecycle
  • dateformate 小技巧
  • Mersenne Primes:History, Theorems and Lists
  • .Net下实现复杂的水晶报表
  • 隐士的C#编码规范草稿
  • 常见Datagrid错误
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.