note.dsm

来自「MFC程序开发参考大全 【明日科技】宋坤 刘锐宁 李伟明 【丛 书 名】」· DSM 代码 · 共 64 行

DSM
64
字号
'------------------------------------------------------------------------------
'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(SelBock)
				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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?