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]