Invoking Dailogs from DLLs(Not Using MFC)

Hi,

I have a DLL(on Win32 Platform) where I have to invoke a Dialog(resource is part of this DLL project). This DLL will be used and loaded(interchangebly) by multiple EXEs. I am using "DialogBox()" for invoking this dialog. I am getting this error "The specified resource name can not be found in the image file." Before I create this dialog I pass "hInstance" to this call.
Now my question is..
Can anybody guide me where I am committing the mistake ? What are the steps to take to fix this ? I would appreciate if I get the code itself.

Thanx in anticipation.
Shivkumar
gshivagAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nietodCommented:
Where is the resouce for the dialog? Is it in the DLL or in the EXE that uses the DLL?   What module handle are you passing to DialogBox()?  It must be the handle to the module EXE/DLL that has the dialog resource.  If you pass the handle to the other module, it will not work.
0
wyllikerCommented:
The DllMain entry point function of your DLL receives as it's first parameter - hinstDLL.  This is the instance handle for the DLL.

Since the resource you want (dialog) is part of the DLL you need to pass this handle in the DialogBox call.

You can save the value from inside the DllMain call to a global variable:

HINSTANCE hinstThisDLL;

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason,LPVOID lpvReserved)
{
    hinstThisDLL = hinstDLL;
}



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nietodCommented:
I sort of thought that was my answer.....
0
wyllikerCommented:
Nietod,

I just went out and embellished where you were going with a code snippet as a comment.

If gshivag had offered up, I would have suggested the points to you.  Second Q today that I have been involved with that the asker has popped points to the wrong expert (other one actually went to someone who's answer had been rejected and was completely wrong!).

The askers need to get it right when accepting answers or accepting comments as answers, but in fairness it seems that most do.
0
nietodCommented:
I didn't realize that was a comment.  Unfortuantly when a comment is accepted as an answer, there is no indication it was a comment.  That can make an expoert look sort of "greedy" when they are not, like in this case.   That will be changed, hopefully soon.  Sorry.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.