473,385 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to load resource strings?

I am writing my first managed project and I am a bit confused in loading
resource strings. In old unmanaged C++ if I had a resource string in my
rc file called GX_ERR_DEVICE_ALREADY_OPEN. I would simply call:

int LoadString(HINSTANCE hInstance,
UINT uID,
LPTSTR lpBuffer,
int nBufferMax
);
inserting GX_ERR_DEVICE_ALREADY_OPEN for uID.
I understand that I now use to ResourceManager?

I tried:
String *GetErrMsg ()
{

ResourceManager *rm = new
ResourceManager("app",this->GetType()->Assembly);
return rm->GetString("GX_ERR_DEVICE_ALREADY_OPEN");
}

where app is the name of my rc file. But this does not seem to work.
Actually it doesn't make sense to me that I would pass a String in
GetString so I must be doing something wrong.

Where did I go wrong?
Nov 21 '06 #1
4 4428
You have to use "YourProjectName.app" instead of "app" for the first
argument.

If you look at the project properties of app.resx in your project, you will
see that the default setting for the resource file name is
$(IntDir)\$(RootNamespace).$(InputName).resources.

Marcus Heege

"msnews.microsoft.com" <Br***@nospma.comwrote in message
news:Oe**************@TK2MSFTNGP04.phx.gbl...
>I am writing my first managed project and I am a bit confused in loading
resource strings. In old unmanaged C++ if I had a resource string in my rc
file called GX_ERR_DEVICE_ALREADY_OPEN. I would simply call:

int LoadString(HINSTANCE hInstance,
UINT uID,
LPTSTR lpBuffer,
int nBufferMax
);
inserting GX_ERR_DEVICE_ALREADY_OPEN for uID.
I understand that I now use to ResourceManager?

I tried:
String *GetErrMsg ()
{

ResourceManager *rm = new
ResourceManager("app",this->GetType()->Assembly); return
rm->GetString("GX_ERR_DEVICE_ALREADY_OPEN");
}

where app is the name of my rc file. But this does not seem to work.
Actually it doesn't make sense to me that I would pass a String in
GetString so I must be doing something wrong.

Where did I go wrong?

Nov 21 '06 #2
Marcus Heege wrote:
You have to use "YourProjectName.app" instead of "app" for the first
argument.

If you look at the project properties of app.resx in your project, you will
see that the default setting for the resource file name is
$(IntDir)\$(RootNamespace).$(InputName).resources.

Marcus Heege
Thanks!

I don't have an app.resx. How is one created? I do have a resx file
for each one of the classes in my project. How do I create an app.resx?

Bruce
Nov 21 '06 #3
Marcus Heege wrote:
You have to use "YourProjectName.app" instead of "app" for the first
argument.

If you look at the project properties of app.resx in your project, you will
see that the default setting for the resource file name is
$(IntDir)\$(RootNamespace).$(InputName).resources.

Marcus Heege

And how do I read strings out of my .rc file? Can I no longer do that?

I created a generic class. It has no resx file. Can one be created
for it? If so how? I don't see any way to create one.

Nov 21 '06 #4
"Bruce" <Br***@nospam.comwrote in message
news:u7**************@TK2MSFTNGP06.phx.gbl...
Marcus Heege wrote:
>You have to use "YourProjectName.app" instead of "app" for the first
argument.

If you look at the project properties of app.resx in your project, you
will see that the default setting for the resource file name is
$(IntDir)\$(RootNamespace).$(InputName).resources .

Marcus Heege

Thanks!

I don't have an app.resx. How is one created? I do have a resx file for
each one of the classes in my project. How do I create an app.resx?

Bruce
To create this file, choose the project's context menu, then Add Item, them
Assembly Resurce (resx).

Marcus
Nov 22 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Scott Smith | last post by:
Several attributes and interface methods I'm using refer to resources (such as strings or icons) by a numeric ID. This was the only way to refer to resources in unmanaged code (C++, for example),...
1
by: Ed Sutton | last post by:
How can I load a resource from any namespace in my project? I have all my icons located under the following namespace: ..\resources\images\ For example, I can not figure out how to load them...
1
by: John Stemper | last post by:
Getting resource files to work with VS2002 and ASP.Net seems to be a little flaky. I've added a resource file "strings.resx" to the project. The properties of the files say Build action = ...
0
by: PontiMax | last post by:
Hi, when we used VB 6 to build all kinds of applications we applied the following technique to automatically assign resource strings to ui controls: Each control has a unique resource id (which...
2
by: Fredrik Rodin | last post by:
All, I'm having problems with my resource manager in ASP.NET 2.0 after conversion from ASP.NET 1.1. Here is a background: In ASP.NET 1.1 All my user controls and aspx pages inherit from...
1
by: Fredrik Melin | last post by:
Hi, How can I load a localized resource file without changing the UI culture? Sample: System is running in English (default) but I want to create a System.Resource.ResourceManager and...
0
by: Achim Domma | last post by:
Hi, I try to develop a localized Asp.Net 1.1 application. I have added two resource files to my app, which are called 'Labels.resx' and 'Labels.de.resx'. If I compile the app, I see a 'de'...
4
by: dwyer.bill | last post by:
My boss insists that whenever we use a string we place it in a resource file every single time. This goes for error string that are displayed through a message box, constants, ect. He claims that...
1
by: TisMe | last post by:
Hi All, I am trying to use resource files to globalize my website application. I had this working fine, working through the API for setting page titles programatically, with the resource files...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.