When I attempt to display a Dialog box from a DLL, CDialog::DoModal cannot
find the dialog resource. I suspect that the resource is being looked for in
the EXE file and not the dll file. Can anyone tell me how I can pont the S/W
to the correct resource using CDialog?

Re: Displaying Dialog from DLL by Suvrat

Suvrat
Wed Aug 20 06:48:53 CDT 2003

Call AFX_MANAGE_STATE(AfxGetStaticModuleState( )) in the beginning of the
method where you want to invoke the new dialog.

hth,
Suvrat

"Brian Westcott" <bwestcott@home.com> wrote in message
news:uSiQU2pZDHA.1872@TK2MSFTNGP12.phx.gbl...
> When I attempt to display a Dialog box from a DLL, CDialog::DoModal cannot
> find the dialog resource. I suspect that the resource is being looked for
in
> the EXE file and not the dll file. Can anyone tell me how I can pont the
S/W
> to the correct resource using CDialog?
>
>



Re: Displaying Dialog from DLL by Brian

Brian
Wed Aug 20 08:49:18 CDT 2003

I'm already doing that. Can you think of another cause for my problem?

"Suvrat" <nobody@nomail.com> wrote in message
news:uOnGOFxZDHA.2580@TK2MSFTNGP09.phx.gbl...
> Call AFX_MANAGE_STATE(AfxGetStaticModuleState( )) in the beginning of the
> method where you want to invoke the new dialog.
>
> hth,
> Suvrat
>
> "Brian Westcott" <bwestcott@home.com> wrote in message
> news:uSiQU2pZDHA.1872@TK2MSFTNGP12.phx.gbl...
> > When I attempt to display a Dialog box from a DLL, CDialog::DoModal
cannot
> > find the dialog resource. I suspect that the resource is being looked
for
> in
> > the EXE file and not the dll file. Can anyone tell me how I can pont the
> S/W
> > to the correct resource using CDialog?
> >
> >
>
>



Re: Displaying Dialog from DLL by Mike

Mike
Wed Aug 20 08:56:37 CDT 2003


>>Call AFX_MANAGE_STATE(AfxGetStaticModuleState( )) in the beginning of the
>>method where you want to invoke the new dialog.

I vaguely remember a problem like this b4 so I checked in some old code.

I've got this line for constructing my dialog:
CConfigDlg Dlg(AfxGetMainWnd());//NULL should be sufficient but there is
an ASSERT issue in MFC
//see "FIX: Asserts When Creating a Dialog Box in an MFC Regular
DLL"
//Microsoft Knowledge Base Article - 194300


Re: Displaying Dialog from DLL by r_z_aret

r_z_aret
Thu Aug 21 13:15:50 CDT 2003

I don't use MFC, so I was hoping someone would give you an
MFC-specific solution. No one has, so I'll offer something that might
help.

In straight Win32, the functions that load resources need an HINST
that points to the location of the resource. If the resource is in the
executable, then NULL works. If the resource is in a DLL, then the
functions need the HINST for that DLL. This value is passed as an
argument to DllMain (sorry, that is a common name for the function,
but I can't remember its more general name). It can also be obtained
by calling LoadLibrary and casting the return value from HMODULE to
HINST. I've seen a recent thread discussing the relative merits of
these two.

You might try looking through the MFC source code. Not something I
like to do, but sometimes worth the effort. And all Visual Studio
users have access to it.

On Tue, 19 Aug 2003 16:08:22 -0600, "Brian Westcott"
<bwestcott@home.com> wrote:

>When I attempt to display a Dialog box from a DLL, CDialog::DoModal cannot
>find the dialog resource. I suspect that the resource is being looked for in
>the EXE file and not the dll file. Can anyone tell me how I can pont the S/W
>to the correct resource using CDialog?
>
>

-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret
PenFact, Inc.
500 Harrison Ave., Suite 3R
Boston, MA 02118
www.penfact.com

Re: Displaying Dialog from DLL by Brian

Brian
Tue Aug 26 11:37:02 CDT 2003

I discovered the solution to my problem Whenever I load the DLL using the
LoadLibrary command, I call AfxSetResourceHandle with the resource handle
returned by the LoadLibrary command.
Sample code:
ResourceHandle = LoadLibrary(_T("mydll.dll"));
if(!ResourceHandle)
{
AfxMessageBox("No resource");
return false;
}
AfxSetResourceHandle(ResourceHandle);

Thanks to those who gave me pointers on where to look for a solution.

"Brian Westcott" <bwestcott@home.com> wrote in message
news:uSiQU2pZDHA.1872@TK2MSFTNGP12.phx.gbl...
> When I attempt to display a Dialog box from a DLL, CDialog::DoModal cannot
> find the dialog resource. I suspect that the resource is being looked for
in
> the EXE file and not the dll file. Can anyone tell me how I can pont the
S/W
> to the correct resource using CDialog?
>
>