Discussion:
DoModal throws error 1812 ERROR_RESOURCE_DATA_NOT_FOUND
(too old to reply)
Sug
2006-03-26 17:23:42 UTC
Permalink
Hello,

I have written an app and derived a calls from CDialog. This class is
associated with a dialog from the RC file.
I compile all my resources into a resource DLL. And my code loads the
resource DLL.

When I call DoModal on my dialog, sometimes it succeeds and sometimes
DoModal() returns -1 and GetLastError() gives me error 1812
(ERROR_RESOURCE_DATA_NOT_FOUND)

As I said, sometimes I am able to successfully do a DoModal and it fails
sometimes. I opened my resource DLL and varified that it does contain the
dialog I want to load.

Can anyone point me to possible cause of this? I am using VC 7.1 on Windows
XP.

Thanks much

Sug
Ajay Kalra
2006-03-26 17:30:29 UTC
Permalink
Post by Sug
I have written an app and derived a calls from CDialog. This class is
associated with a dialog from the RC file.
I compile all my resources into a resource DLL. And my code loads the
resource DLL.
Did you add this DLL to resource chain so that these resources can be
found when you are loading a resource from this DLL. (See
CDynLinkLibrary).

----
Ajay Kalra
***@yahoo.com
VSP
2006-03-27 06:51:18 UTC
Permalink
Loading the resource dll is not sufficient.
You have to call AfxSetResourceHandle(handle to the resource dll)

HANDLE hPrevRes = AfxGetResourceHandle()
AfxSetResourceHandle(hRes);
...
Use the resource(Create dialog, load strings...)

AfxSetResourceHandle(hPrevRes);

-VSP
Post by Sug
Hello,
I have written an app and derived a calls from CDialog. This class is
associated with a dialog from the RC file.
I compile all my resources into a resource DLL. And my code loads the
resource DLL.
When I call DoModal on my dialog, sometimes it succeeds and sometimes
DoModal() returns -1 and GetLastError() gives me error 1812
(ERROR_RESOURCE_DATA_NOT_FOUND)
As I said, sometimes I am able to successfully do a DoModal and it fails
sometimes. I opened my resource DLL and varified that it does contain the
dialog I want to load.
Can anyone point me to possible cause of this? I am using VC 7.1 on Windows
XP.
Thanks much
Sug
Sug
2006-04-03 16:12:53 UTC
Permalink
Post by VSP
Loading the resource dll is not sufficient.
You have to call AfxSetResourceHandle(handle to the resource dll)
HANDLE hPrevRes = AfxGetResourceHandle()
AfxSetResourceHandle(hRes);
...
Use the resource(Create dialog, load strings...)
AfxSetResourceHandle(hPrevRes);
-VSP
Hi VSP,

Thanks for your responce. Yes I found out that this is what was required.
That solves the problem.

Sug
Ajay Kalra
2006-04-03 16:43:48 UTC
Permalink
And if you add the dll to resource chain, you dont have to do anything
like this.

---
Ajay

Loading...