65.9K
CodeProject 正在变化。 阅读更多。
Home

重新排序资源 ID 宏

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (2投票s)

2001年8月11日

CPOL
viewsIcon

49869

这个简单的宏可以帮助重新排序 resource.h 中的资源ID。

引言

Visual C++ 项目包含一个符号定义文件 - 命名为“resource.h”,其中包含项目使用的每个符号的 #define 指令。 当你从另一个项目复制一些资源到你的工作项目中时,你可能会得到重复的资源ID定义 - 两个符号具有相同的值。

我编写了这个简单的宏,在5分钟内重新排序资源ID,它对我有用。 希望你也会觉得它有用。

宏代码

Sub ReorderResource()
	Dim objTheDocument
	Dim sSelectedText
	set objTheDocument = ActiveDocument
	Dim nNumber
	Dim nCount
	nCount=1
	if objTheDocument.Name <> "resource.h" then
		MsgBox "This macro only working for resource.h"
		exit sub
	end if
	objTheDocument.Selection.StartOfDocument
	objTheDocument.Selection.FindText ("#define")
	Do
		objTheDocument.Selection.StartOfLine
		objTheDocument.Selection.WordRight dsExtend
		objTheDocument.Selection.WordRight dsExtend
		if objTheDocument.Selection.Text <> "#define " then
			exit do
		end if
		objTheDocument.Selection.EndOfLine
		objTheDocument.Selection.WordLeft dsExtend
		nNumber = int(objTheDocument.Selection.Text)
		if nCount < nNumber then
			nCount = nNumber
		end if
		objTheDocument.Selection.Text = "" & nCount
		nCount = nCount + 1
		objTheDocument.Selection.LineDown
	Loop
End Sub

历史

  • 2001年8月10日:初始发布
© . All rights reserved.