Re: ERROR_RESOURCE_TYPE_NOT_FOUND error comes

Tech-Archive recommends: Speed Up your PC by fixing your registry



AfxGetResourceHandle gives you the current resource handle. So you could simply get the
resource handle, save it, set it to the desired resource handle, load the resource, then
restore the resource handle that you saved.

But in the case of loading a bitmap, you don't need to worry about this, because you
should not be using LoadBitmap; you should be using LoadImage, which is more robust and
reliable.

HBITMAP bmp = ::LoadImage(dllhandle, ...parameters here...)

will do the job.
joe

On Thu, 14 Feb 2008 06:48:43 -0800, "Eddie Pazz" <drpazz@xxxxxxxxxxx> wrote:

kkagarwal2002@xxxxxxxxx> wrote in message
news:27c62fd1-015c-466b-be44-c1ff11ead814@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On 14 Feb, 16:28, "David Ching" <d...@xxxxxxxxxxxxxxxxxxxxxx> wrote:
<kkagarwal2...@xxxxxxxxx> wrote in message

news:1e81f75d-c129-4b3f-890c-bb537bda24e4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx





Hello Everybody,

I am unable to load the bitmap image in CListCtrl control. I made
application as follows:

1. Made DLL which contains resources like dialog, bitmap etc. by
having the multiple .rc files in a project.
2. Made a static lib project which contains classes for resources
which are in DLL. This lib is also having a dependency of DLL.
3. Made a 2 Exes which load that lib. It has a dialog which contains
CListCtrl. This control is populated by lib classes.

I am using VS2003. I am getting surprised result when i run two exes.
one exe shows bitmap in CListCtrl but other does not. I am loading the
bitmap in one of the class of static lib using LoadBitmap but it
returns 0 and when i tried to get error code, it gives 1813.

Can anybody help me on this issue?

Thanks in advance.

Kamal

Error 1813 is, "The specified resource type cannot be found in the image
file. "

It sounds like the wrong resource handle is being used. This is
controlled
somewhat by MFC at startup, which looks for a DLL named with the current
locale ID, and if not found, is defaulted to the app .exe itself. If you
want to control it yourself, call AfxSetResourceHandle() at a convenient
place, normally CWinApp::InitInstance() (actually, this method in your
derived class).

-- David- Hide quoted text -

- Show quoted text -

Hello David,

Thanks for prompt reply. Actually My exe also has resources and my DLL
also has resources so when i will do AfxSetResourceHandle from Exe to
DLL then my exe resource will not be used. I want to escape from that
situation.

Do you have any other alternative approach?


Is your DLL a resource-only DLL? If so, you have to use
AfxSetResourceHandle. If you also want to use the resources in your exe, you
have to add the DLL to the MFC resource chain. To solve this, I added a
function to the dll that I explicitly call from my exe so MFC loads it and
adds it to the chain.

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: ERROR_RESOURCE_TYPE_NOT_FOUND error comes
    ... resource handle, save it, set it to the desired resource handle, load the resource, then ... This lib is also having a dependency of DLL. ... bitmap in one of the class of static lib using LoadBitmap but it ... locale ID, and if not found, is defaulted to the app .exe itself. ...
    (microsoft.public.vc.mfc)
  • Re: ERROR_RESOURCE_TYPE_NOT_FOUND error comes
    ... resource handle, save it, set it to the desired resource handle, load the resource, then ... This lib is also having a dependency of DLL. ... locale ID, and if not found, is defaulted to the app .exe itself. ...
    (microsoft.public.vc.mfc)
  • Re: ERROR_RESOURCE_TYPE_NOT_FOUND error comes
    ... resource handle, save it, set it to the desired resource handle, load the resource, then ... This lib is also having a dependency of DLL. ... locale ID, and if not found, is defaulted to the app .exe itself. ...
    (microsoft.public.vc.mfc)
  • Re: ERROR_RESOURCE_TYPE_NOT_FOUND error comes
    ... from the DLL just to take a guess. ... resource handle, save it, set it to the desired resource handle, load the resource, then ... This lib is also having a dependency of DLL. ... locale ID, and if not found, is defaulted to the app .exe itself. ...
    (microsoft.public.vc.mfc)
  • Re: Dll function with STL obj. as parameter call crach
    ... If you are using static libraries ... You can't start strtokin an EXE and then expect to continue strtokin an DLL with the same pointer ... Link with the static library but make sure that any resource that is allocated is changed in only one place. ...
    (microsoft.public.vc.stl)