How do I make a Dialog resource (for DialogBoxParam) within a library
available to any calling DLL or EXE?

When I build a DLL that references a library that has an error message
dialog, the DialogBoxParam fails with an error 1812 (dialog resource
unavailable). If I include the .rc for the dialog in the DLL project,
the dialog works. Is there some way, in building the library, that I
can insure that the resource gets included in any calling DLL?

Re: dialog resource in library by Jeff

Jeff
Tue Jul 29 18:35:39 CDT 2003

"Gary Gorbet" <ggorbet@sdicgm.com> wrote in message
news:3f26ecf4.28889030@msnews.microsoft.com...
> How do I make a Dialog resource (for DialogBoxParam) within a library
> available to any calling DLL or EXE?
>
> When I build a DLL that references a library that has an error message
> dialog, the DialogBoxParam fails with an error 1812 (dialog resource
> unavailable). If I include the .rc for the dialog in the DLL project,
> the dialog works. Is there some way, in building the library, that I
> can insure that the resource gets included in any calling DLL?

Gary,

Are you talking about an object library?
--
Jeff [VC++ MVP]



Re: dialog resource in library by Tom

Tom
Tue Jul 29 19:36:06 CDT 2003

If you build a resource DLL (use and MFC Extension DLL) you will have to
load it using LoadLibrary() and AfxSetResourceHandle() in any DLL or
application that wants to use it. I do this most often for language
translations, but it would work for other resources as well. You will need
a good resource.h file with the right numbers for the resources to link into
the application as well. The bottom line is that the resources have to get
loaded somehow. If they are not built into the application or DLL that is
being loaded then those programs will need to load them dynamically.

I use code like this: Note: this is for language DLL's

csName = "MyResource.DLL";
m_hInstResDLL = ::LoadLibrary(csName);
if(m_hInstResDLL != NULL)
AfxSetResourceHandle(m_hInstResDLL);

HTH,

Tom


"Gary Gorbet" <ggorbet@sdicgm.com> wrote in message
news:3f26ecf4.28889030@msnews.microsoft.com...
> How do I make a Dialog resource (for DialogBoxParam) within a library
> available to any calling DLL or EXE?
>
> When I build a DLL that references a library that has an error message
> dialog, the DialogBoxParam fails with an error 1812 (dialog resource
> unavailable). If I include the .rc for the dialog in the DLL project,
> the dialog works. Is there some way, in building the library, that I
> can insure that the resource gets included in any calling DLL?



Re: dialog resource in library by ggorbet

ggorbet
Wed Jul 30 09:01:03 CDT 2003

On Tue, 29 Jul 2003 18:35:39 -0500, "Jeff Partch" <jeffp@mvps.org>
wrote:

>"Gary Gorbet" <ggorbet@sdicgm.com> wrote in message
>news:3f26ecf4.28889030@msnews.microsoft.com...
>> How do I make a Dialog resource (for DialogBoxParam) within a library
>> available to any calling DLL or EXE?
>>
>> When I build a DLL that references a library that has an error message
>> dialog, the DialogBoxParam fails with an error 1812 (dialog resource
>> unavailable). If I include the .rc for the dialog in the DLL project,
>> the dialog works. Is there some way, in building the library, that I
>> can insure that the resource gets included in any calling DLL?
>
>Gary,
>
>Are you talking about an object library?
>--
>Jeff [VC++ MVP]
Yes, I am talking about an object library and want to know how to
build it in such a way that when is it included in the build of any
DLL, a resource in the object library is visible to the DLL code.
- Gary

Re: dialog resource in library by ggorbet

ggorbet
Wed Jul 30 09:03:15 CDT 2003

Tom,

I am talking about building an object library in such a way that when
I include it in the build of a DLL, the library's resource is visible
to the DLL's code.

Gary

On Tue, 29 Jul 2003 17:36:06 -0700, "Tom Serface" <tserface@msn.com>
wrote:

>If you build a resource DLL (use and MFC Extension DLL) you will have to
>load it using LoadLibrary() and AfxSetResourceHandle() in any DLL or
>application that wants to use it. I do this most often for language
>translations, but it would work for other resources as well. You will need
>a good resource.h file with the right numbers for the resources to link into
>the application as well. The bottom line is that the resources have to get
>loaded somehow. If they are not built into the application or DLL that is
>being loaded then those programs will need to load them dynamically.
>
>I use code like this: Note: this is for language DLL's
>
> csName = "MyResource.DLL";
> m_hInstResDLL = ::LoadLibrary(csName);
> if(m_hInstResDLL != NULL)
> AfxSetResourceHandle(m_hInstResDLL);
>
>HTH,
>
>Tom
>
>
>"Gary Gorbet" <ggorbet@sdicgm.com> wrote in message
>news:3f26ecf4.28889030@msnews.microsoft.com...
>> How do I make a Dialog resource (for DialogBoxParam) within a library
>> available to any calling DLL or EXE?
>>
>> When I build a DLL that references a library that has an error message
>> dialog, the DialogBoxParam fails with an error 1812 (dialog resource
>> unavailable). If I include the .rc for the dialog in the DLL project,
>> the dialog works. Is there some way, in building the library, that I
>> can insure that the resource gets included in any calling DLL?
>
>


Re: dialog resource in library by Jeff

Jeff
Thu Jul 31 09:19:53 CDT 2003

"Gary Gorbet" <ggorbet@sdicgm.com> wrote in message
news:3f27cf16.86771100@msnews.microsoft.com...
> On Tue, 29 Jul 2003 18:35:39 -0500, "Jeff Partch" <jeffp@mvps.org>
> wrote:
>
> >"Gary Gorbet" <ggorbet@sdicgm.com> wrote in message
> >news:3f26ecf4.28889030@msnews.microsoft.com...
> >> How do I make a Dialog resource (for DialogBoxParam) within a
library
> >> available to any calling DLL or EXE?
> >>
> >> When I build a DLL that references a library that has an error
message
> >> dialog, the DialogBoxParam fails with an error 1812 (dialog
resource
> >> unavailable). If I include the .rc for the dialog in the DLL
project,
> >> the dialog works. Is there some way, in building the library, that
I
> >> can insure that the resource gets included in any calling DLL?

Gary,

I'm not sure if this is what you're looking for, but the only way I've
ever come up with to do it goes something like this: 1) Once your
DIALOG[EX] is designed and finalized, you can dump it as a CONST array
of BYTE that you can wrap in an inline function that returns a pointer
to it cast as an LPCDLGTEMPLATE...

static
__inline
LPCDLGTEMPLATE
_stdcall
RgnDlg_GetTemplate(
VOID
)
{
// IDD_DIALOG DIALOG DISCARDABLE 0, 0, 320, 166
// STYLE DS_MODALFRAME | WS_POPUP | DS_SETFONT |
// WS_CAPTION | WS_SYSMENU | DS_CENTER
// CAPTION "Dialog"
// FONT 8, "MS Sans Serif"
// BEGIN
// DEFPUSHBUTTON "OK",IDOK,260,7,50,14
// PUSHBUTTON "Cancel",IDCANCEL,260,24,50,14
// END
static CONST BYTE templ[] = {
0xC0, 0x08, 0xC8, 0x80, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01,
0xA6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00,
0x69, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x6F, 0x00,
0x67, 0x00, 0x00, 0x00, 0x08, 0x00, 0x4D, 0x00,
0x53, 0x00, 0x20, 0x00, 0x53, 0x00, 0x61, 0x00,
0x6E, 0x00, 0x73, 0x00, 0x20, 0x00, 0x53, 0x00,
0x65, 0x00, 0x72, 0x00, 0x69, 0x00, 0x66, 0x00,
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x50,
0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x07, 0x00,
0x32, 0x00, 0x0E, 0x00, 0x01, 0x00, 0xFF, 0xFF,
0x80, 0x00, 0x4F, 0x00, 0x4B, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x50,
0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x18, 0x00,
0x32, 0x00, 0x0E, 0x00, 0x02, 0x00, 0xFF, 0xFF,
0x80, 0x00, 0x43, 0x00, 0x61, 0x00, 0x6E, 0x00,
0x63, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x00, 0x00,
0x00, 0x00
};
return (LPCDLGTEMPLATE)templ;
}

...You can then use DialogBoxIndirectParam instead, and pass this as the
'hDialogTemplate' parameter...

INT
WINAPI
_tWinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpszCmdLine,
INT nCmdChow
)
{
return DialogBoxIndirectParam(
hInstance, RgnDlg_GetTemplate(),
NULL, RgnDlg_GetDialogProc(),
(LPARAM)RgnApp_GetAppText());
}

...I have previously posted a dumping helper function...

http://www.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=uU49SGvEAHA.248%40cppssbbsa05&rnum=2

...it's an MFC implementation, but maybe you can adapt it.

--
Jeff Partch [VC++ MVP]