|
-
May 23rd, 2002, 09:10 AM
#1
String resource
Hi,
I was wondering if there's a way to create a string resource using a manual Win32 command. I don't want to use an .rc file in my project, and I need to get an identified for a string, that can be loaded through LoadString. Normally, I would define such a string in the string table, but I haven't found a way to do it manually.
Thanks
-
May 23rd, 2002, 09:39 AM
#2
How about this: I usually put this in StdAfx.h, but you can put this below your include statements
Code:
#define MY_STRING "This is my constant string"
#define PING_SERVER "\\\\MyFileserver"
You won't be able to do LoadString, but you won't need to, just use MY_STRING wherever you need the string.
I hope this helps,
-
May 23rd, 2002, 10:30 AM
#3
No, I have to use LoadString. I have to get an identifier for my string. Any ideas on how to do this?
-
May 23rd, 2002, 10:44 AM
#4
Why don't you just use a simple array of structs containing int id nad char* string pairs?
regards,
MiMec
-
June 1st, 2002, 08:40 AM
#5
Because a simple array won't enable Win32 to load the string from memory according to its ID. There should be some Win32 command to do this.
-
June 1st, 2002, 09:14 AM
#6
Hi,
I think I need to ask the question : why don't you want to use a resource script? (OR) why do you have to use LoadString.
I only ask because LoadString is designed specifically to get strings out of your resource area. Since you don't want to use the resource area why use LoadString?
-
June 1st, 2002, 10:33 AM
#7
Because I'm trying to code a portable wrapper for some features in MFC, and therefore I can't use an .rc file. Since CSingleDocTemplate takes a string ID in its constructor, and I don't use a resource file, I have to create that string table manually.
-
June 1st, 2002, 10:53 AM
#8
Aahhh, I see. Well, I think trying to "fool" MFC into loading a string will probably be the hardest route for you to take.
Hows about this : instead of using CSingleDocTemplate, build your own by subclassing CDocTemplate. This way you can have your own constructor that doesn't take a resource ID. I've only had a quick look but it seems possible at first glance.
Hope this helps,
swg
p.s. what happens if you pass 0 as a resource ID? Does it fall over? If not you're OK because all of the string related member variables of CDocTemplate are public so you can just set them to whatever you like.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|