HINSTANCE question
-
How do I get the HINSTANCE of my dialog based application? I want to pass the HINSTANCE value in LoadStringW function as the first parameter. :rose:
-
How do I get the HINSTANCE of my dialog based application? I want to pass the HINSTANCE value in LoadStringW function as the first parameter. :rose:
-
How do I get the HINSTANCE of my dialog based application? I want to pass the HINSTANCE value in LoadStringW function as the first parameter. :rose:
I found it myself.
AfxGetInstanceHandle()
will get the HINSTANCE of the app. But nowLoadStringW(HINSTANCE hInstance, UINT nID, WORD wLanguageID);
is returning zero. Why is this function failing? I am passing the correct language ID (1097).:rose:
-
Thanks I actually found it. Please see if you can help me with the other question.
:rose:
-
I found it myself.
AfxGetInstanceHandle()
will get the HINSTANCE of the app. But nowLoadStringW(HINSTANCE hInstance, UINT nID, WORD wLanguageID);
is returning zero. Why is this function failing? I am passing the correct language ID (1097).:rose:
Aljechin wrote:
But now LoadStringW(HINSTANCE hInstance, UINT nID, WORD wLanguageID); is returning zero.
You need to pass value returned by
AfxGetResourceHandle
as first parameter.Prasad Notifier using ATL | Operator new[],delete[][^]
-
Aljechin wrote:
But now LoadStringW(HINSTANCE hInstance, UINT nID, WORD wLanguageID); is returning zero.
You need to pass value returned by
AfxGetResourceHandle
as first parameter.Prasad Notifier using ATL | Operator new[],delete[][^]
That also didn't work. Here's what I am doing.
CString str; int ret; ret = str.LoadStringW((HINSTANCE)AfxGetInstanceHandle(),IDS_STRING102,(WORD)1097); if(ret) MessageBox(str,L"Welcome",MB_ICONINFORMATION); else { DWORD dwErr= GetLastError(); }
GetLastError is returning 1815. But i can't find such an error in msdn. Why is this resource loading failing? IDS_STRING102 is an entry in a string table resource. It has the unicode value that must be loaded. If i directly use the unicode string in c++ file, it gets loaded.:rose:
-
That also didn't work. Here's what I am doing.
CString str; int ret; ret = str.LoadStringW((HINSTANCE)AfxGetInstanceHandle(),IDS_STRING102,(WORD)1097); if(ret) MessageBox(str,L"Welcome",MB_ICONINFORMATION); else { DWORD dwErr= GetLastError(); }
GetLastError is returning 1815. But i can't find such an error in msdn. Why is this resource loading failing? IDS_STRING102 is an entry in a string table resource. It has the unicode value that must be loaded. If i directly use the unicode string in c++ file, it gets loaded.:rose:
dear, dear. I mentioned
AfxGetResourceHandle
in my previous post. Update you code like this,CString str;
int ret;
ret = str.LoadStringW((HINSTANCE)AfxGetResourceHandle(),IDS_STRING102,(WORD)1097);
if(ret)
MessageBox(str,L"Welcome",MB_ICONINFORMATION);
else
{
DWORD dwErr= GetLastError();
}And dont know why I was voted 1 for my previous post.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
dear, dear. I mentioned
AfxGetResourceHandle
in my previous post. Update you code like this,CString str;
int ret;
ret = str.LoadStringW((HINSTANCE)AfxGetResourceHandle(),IDS_STRING102,(WORD)1097);
if(ret)
MessageBox(str,L"Welcome",MB_ICONINFORMATION);
else
{
DWORD dwErr= GetLastError();
}And dont know why I was voted 1 for my previous post.
Prasad Notifier using ATL | Operator new[],delete[][^]
prasad_som wrote:
AfxGetResourceHandle
Yes, in my previous post I told that also didn't work. Actually I edited it two minutes after posting. What could be the problem?
:rose:
-
That also didn't work. Here's what I am doing.
CString str; int ret; ret = str.LoadStringW((HINSTANCE)AfxGetInstanceHandle(),IDS_STRING102,(WORD)1097); if(ret) MessageBox(str,L"Welcome",MB_ICONINFORMATION); else { DWORD dwErr= GetLastError(); }
GetLastError is returning 1815. But i can't find such an error in msdn. Why is this resource loading failing? IDS_STRING102 is an entry in a string table resource. It has the unicode value that must be loaded. If i directly use the unicode string in c++ file, it gets loaded.:rose:
Aljechin wrote:
GetLastError is returning 1815
This error code states, "The specified resource language ID cannot be found in the image file." See if you are going wrong there.
Prasad Notifier using ATL | Operator new[],delete[][^]
-
Aljechin wrote:
GetLastError is returning 1815
This error code states, "The specified resource language ID cannot be found in the image file." See if you are going wrong there.
Prasad Notifier using ATL | Operator new[],delete[][^]
Actually this is the first time I am using Unicode in a string table. It works fine with non unicode strings. There is no error. Is there some special setting that I need to do in that string table or my project for loading the string successfully in runtime? I thank you very much for your time.
:rose:
-
Actually this is the first time I am using Unicode in a string table. It works fine with non unicode strings. There is no error. Is there some special setting that I need to do in that string table or my project for loading the string successfully in runtime? I thank you very much for your time.
:rose:
I'm not sure. How you are sending last parameter ? i.e. language Id. From error it seems, its not defined in resource file. Is it different from English ? If yes, is it defined in .rc?
Prasad Notifier using ATL | Operator new[],delete[][^]
-
That also didn't work. Here's what I am doing.
CString str; int ret; ret = str.LoadStringW((HINSTANCE)AfxGetInstanceHandle(),IDS_STRING102,(WORD)1097); if(ret) MessageBox(str,L"Welcome",MB_ICONINFORMATION); else { DWORD dwErr= GetLastError(); }
GetLastError is returning 1815. But i can't find such an error in msdn. Why is this resource loading failing? IDS_STRING102 is an entry in a string table resource. It has the unicode value that must be loaded. If i directly use the unicode string in c++ file, it gets loaded.:rose:
Are you sure a stringtable entry exists for id "IDS_STRING102" in the language section "1097"? The error indicates it doesn't exist.
-
I'm not sure. How you are sending last parameter ? i.e. language Id. From error it seems, its not defined in resource file. Is it different from English ? If yes, is it defined in .rc?
Prasad Notifier using ATL | Operator new[],delete[][^]
prasad_som wrote:
How you are sending last parameter ? i.e. language Id.
ret = str.LoadStringW((HINSTANCE)AfxGetInstanceHandle(),IDS_STRING102,(WORD)1097);
It is unicode and of course different from english. I don't know if its defined in .rc file. How do I do that?:rose:
-
I'm not sure. How you are sending last parameter ? i.e. language Id. From error it seems, its not defined in resource file. Is it different from English ? If yes, is it defined in .rc?
Prasad Notifier using ATL | Operator new[],delete[][^]
prasad_som wrote:
How you are sending last parameter ? i.e. language Id.
ret = str.LoadStringW((HINSTANCE)AfxGetInstanceHandle(),IDS_STRING102,(WORD)1097);
It's of course not english. I don't know if its defined in .rc. How do I do that?:rose:
-
Are you sure a stringtable entry exists for id "IDS_STRING102" in the language section "1097"? The error indicates it doesn't exist.
Mark Salsbery wrote:
in the language section "1097"?
I think I need to check out that. What is the language section? the string IDS_STRING102 does exist in stringtable and the value of that is a unicode string. If i put a non unicode string, it gets loaded.
:rose:
-
Mark Salsbery wrote:
in the language section "1097"?
I think I need to check out that. What is the language section? the string IDS_STRING102 does exist in stringtable and the value of that is a unicode string. If i put a non unicode string, it gets loaded.
:rose:
The STRINGTABLE resource has a LANGUAGE option but apparently tha's not the problem if it works for a non-unicode string table entry.