I am trying to use CString's LoadString function but it never retrieves the text from the string table. I ported the application from Visual Studio 6 to visual studio 2003. I looked all over the web but nothing is working. Somebody help me! And if you could be very specific.

Madrice

> And if you could be very specific.
Kinda ironic, given that your post is about as vague as it is possible to get, and still remain comprehensible English.

How about posting some actual code you TRIED?

FWIW, my first thought is you've screwed up over ANSI/UNICODE and your indiscriminate casting to make the compiler STFU has resulted in you trying to manipulate UNICODE strings (where every alternate byte is \0), as an ANSI/ASCII array of bytes, where all those UNICODE \0's make for some very short strings.

This is the code:

DWORD ret = 0;
CString strApplicationTitle =_T("");
strApplicationTitle.LoadString( AfxGetResourceHandle(),IDR_MAINFRAME);
ret = GetLastError();

GetLastError returns 1814. I looked it up and know what it is but I dont know how to solve it. I see my resources and my string table but it will not retrieve the text at all.

Compare your usage with this example perhaps (IANAWP)
http://msdn.microsoft.com/en-us/library/zaewt3xs%28v=vs.80%29.aspx
Note specifically the MAKEINTRESOURCE

You might also check that AfxGetResourceHandle() is actually returning what you think it should (even though the manual page doesn't indicate any error condition).

I tried to use it like the documentation says but it still does not work. The resource handle does not return null, its value is (0x00400000){unused=9460301}, but it does not want to load any strings from the string table. This causes LoadFrame to fail because it cannot find IDR_MAINFRAME. When I try to step into LoadFrame, I am taken to some TrimString or odd function but in between code statements. Any suggestions?

I looked in the documentation and it seems that I am using it right. Any other suggestions?

I suggest posting up the full code of some of the ways you tried using LoadString along with the specific error you get for each.

;)

AfxSetResourceHandle(hInst);

	//The resource handle does not return null, its value is (0x00400000){unused=9460301}, 
	// Standard initialization
	CString strApplicationTitle =_T("");
	strApplicationTitle.LoadString(IDS_KILL);
	strApplicationTitle.LoadString( AfxGetResourceHandle(),IDR_MAINFRAME);

	strApplicationTitle.LoadString(IDS_KILL);
	ret = GetLastError();
         //GetLastError returns 1814

	CComBSTR sTemp;
	sTemp.LoadString(IDS_KILL);

I had to remove the /i Resources command line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.