Hi,
I am implementing a Win32 DLL project. In this dll I developed a dialogbox.
In order to export the dialogbox, I did the following things.
1. define a function called Test()
int Test() {
return DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG),NULL, DlgProc);
}

2. export this Test() function.

The problem I encountered was the dialogbox did not show up. The DialogBox()
returned a -1 indicating it failed to create the dialogbox. So I called
GetLastError() and got the error code 1812, which indicates "The specified
image file did not contain a resource section.".

I am pretty sure the Test() function was successfully exported because I got
some results if I replace the DialogBox() with other functions.

I stuck there for tens of hours so if you have any clues or ideas, please
drop me a line. I deeply appreciate your help.

THanks,

Hu

Re: Dialogbox did not show up. Please help!!! by Norman

Norman
Sat Jul 10 20:07:46 CDT 2004

Hu Dong wrote:
> Hi,
> I am implementing a Win32 DLL project. In this dll I developed a dialogbox.
> In order to export the dialogbox, I did the following things.
> 1. define a function called Test()
> int Test() {
> return DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG),NULL, DlgProc);
> }
>
> 2. export this Test() function.
>
> The problem I encountered was the dialogbox did not show up. The DialogBox()
> returned a -1 indicating it failed to create the dialogbox. So I called
> GetLastError() and got the error code 1812, which indicates "The specified
> image file did not contain a resource section.".
>
> I am pretty sure the Test() function was successfully exported because I got
> some results if I replace the DialogBox() with other functions.
>
> I stuck there for tens of hours so if you have any clues or ideas, please
> drop me a line. I deeply appreciate your help.
>
> THanks,
>
> Hu
>
>

You must pass the hInstance or your program as the first argument of
DialogBox().

Norm

--
--
To reply, change domain to an adult feline.


Re: Dialogbox did not show up. Please help!!! by Hu

Hu
Sat Jul 10 20:35:29 CDT 2004

Thanks for your reply.
I tried to pass the hInstance in but it still does not work. Actually, it is
OK if I let the first parameter be NULL. At least it works in my previous
projects.
Any comments?

Thanks a lot.

Hu

"Norman Bullen" <norm@BlackKittenAssociates.com.INVALID> wrote in message
news:Cp0Ic.11985$oD3.3393@newsread1.news.pas.earthlink.net...
> Hu Dong wrote:
> > Hi,
> > I am implementing a Win32 DLL project. In this dll I developed a
dialogbox.
> > In order to export the dialogbox, I did the following things.
> > 1. define a function called Test()
> > int Test() {
> > return DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG),NULL, DlgProc);
> > }
> >
> > 2. export this Test() function.
> >
> > The problem I encountered was the dialogbox did not show up. The
DialogBox()
> > returned a -1 indicating it failed to create the dialogbox. So I called
> > GetLastError() and got the error code 1812, which indicates "The
specified
> > image file did not contain a resource section.".
> >
> > I am pretty sure the Test() function was successfully exported because I
got
> > some results if I replace the DialogBox() with other functions.
> >
> > I stuck there for tens of hours so if you have any clues or ideas,
please
> > drop me a line. I deeply appreciate your help.
> >
> > THanks,
> >
> > Hu
> >
> >
>
> You must pass the hInstance or your program as the first argument of
> DialogBox().
>
> Norm
>
> --
> --
> To reply, change domain to an adult feline.
>



Re: Dialogbox did not show up. Please help!!! by Hu

Hu
Sat Jul 10 21:02:46 CDT 2004

I debugged this dll and found the VS6 did not find the value for the symbol
"IDD_DIALOG". But I did include the resource header file! Why?

Thanks!!!
Hu


"Hu Dong" <hdong@ucdavis.edu> wrote in message
news:u0l$23tZEHA.2388@TK2MSFTNGP09.phx.gbl...
> Hi,
> I am implementing a Win32 DLL project. In this dll I developed a
dialogbox.
> In order to export the dialogbox, I did the following things.
> 1. define a function called Test()
> int Test() {
> return DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG),NULL, DlgProc);
> }
>
> 2. export this Test() function.
>
> The problem I encountered was the dialogbox did not show up. The
DialogBox()
> returned a -1 indicating it failed to create the dialogbox. So I called
> GetLastError() and got the error code 1812, which indicates "The specified
> image file did not contain a resource section.".
>
> I am pretty sure the Test() function was successfully exported because I
got
> some results if I replace the DialogBox() with other functions.
>
> I stuck there for tens of hours so if you have any clues or ideas, please
> drop me a line. I deeply appreciate your help.
>
> THanks,
>
> Hu
>
>



Re: Dialogbox did not show up. Please help!!! by David

David
Sat Jul 10 21:05:48 CDT 2004

You should pass the handle of the DLL as the first parameter. I believe if
you pass NULL, Windows searches for the template in the EXE that loaded the
DLL. Use GetModuleHandle to get the handle of the DLL.

David Liebtag



Re: Dialogbox did not show up. Please help!!! by Hu

Hu
Sat Jul 10 21:33:31 CDT 2004

You are right. David. Now it works!
At the first beginning, I tried GetModuleHandle() but I passed NULL to
GetModuleHandle(). So I got the handle to the caller. I did not be aware
that I actually need the handle to the DLL!

Thank you! Also I want to thank Norman because he pointed the problem but I
did not pay attention. You both are great.

Hu


"Hu Dong" <hdong@ucdavis.edu> wrote in message
news:u0l$23tZEHA.2388@TK2MSFTNGP09.phx.gbl...
> Hi,
> I am implementing a Win32 DLL project. In this dll I developed a
dialogbox.
> In order to export the dialogbox, I did the following things.
> 1. define a function called Test()
> int Test() {
> return DialogBox(NULL, MAKEINTRESOURCE(IDD_DIALOG),NULL, DlgProc);
> }
>
> 2. export this Test() function.
>
> The problem I encountered was the dialogbox did not show up. The
DialogBox()
> returned a -1 indicating it failed to create the dialogbox. So I called
> GetLastError() and got the error code 1812, which indicates "The specified
> image file did not contain a resource section.".
>
> I am pretty sure the Test() function was successfully exported because I
got
> some results if I replace the DialogBox() with other functions.
>
> I stuck there for tens of hours so if you have any clues or ideas, please
> drop me a line. I deeply appreciate your help.
>
> THanks,
>
> Hu
>
>



Re: Dialogbox did not show up. Please help!!! by Igor

Igor
Mon Jul 12 12:35:53 CDT 2004

"Hu Dong" <hdong@ucdavis.edu.INVALID> wrote in message
news:u3sa19uZEHA.2908@TK2MSFTNGP10.phx.gbl
> You are right. David. Now it works!
> At the first beginning, I tried GetModuleHandle() but I passed NULL to
> GetModuleHandle(). So I got the handle to the caller. I did not be
> aware that I actually need the handle to the DLL!

It's best to use HINSTANCE value originally passed to your DllMain. If
somebody renames your DLL, GetModuleHandle won't work anymore.
--
With best wishes,
Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken