• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 202
  • Last Modified:

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
0
gshivag
Asked:
gshivag
  • 3
  • 2
1 Solution
 
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
 
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

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now