开发者

Using string-type resource identifiers in Windows .rc files / dlls

We have a number of MFC extension dlls in our code base, many of which have embedded Windows resources defined in the projects .rc files (IDS_..., IDD_..., IDB_... etc). We use numerical identifiers to define our resources, taking special care that our resource ids don't clash a开发者_如何学JAVAcross dlls, which requires some management to ensure our developers don't use the same numberings.

I've realised that string-type resource identifiers might be an easy way to go, meaning that we can define unique identifiers for each resource in each different dll.

My question is, are there any technical problems with doing this, for example:

  • Will the MFC dll / resource chain still function correctly?
  • Will the Visual Studio resource editor still work?

I haven't found anything in the MS Technical Notes to say this would be a problem - I'd just wondering if people have had experience with this.


Note however that IDs of strings in the string table (IDS_) MUST be numeric (16 bits IIRC). The difference between a string and another resource is due to strings not being individual resources. Actually, the string table consists in a set of resources, each containing up to 16 strings with consecutive IDs.

Same goes for Control IDs within dialogs. But you most likely know that.

In the resource editor, you can specify a string resource id in the property grid by simply putting quotes around the resource names.

Regarding dialogs and the resource editor: You'll have a minor problem: Whenever you create a class for the dialog, the generated code contains enum { IDD = resourceid }. Needless to say that it won't work for a string id. But you can easily get rid of this IDD enum and replace it by a string.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜