Passing MFC dialog resource to Win32 dialog function 
Author Message
 Passing MFC dialog resource to Win32 dialog function

Hi all,

I created a dialog template resource in a MFC DLL
using the VC6 Resource Editor. I'm passing the resource
ID into a Win32 dialog box construction function.
Is this asking for trouble?

Specifically I'm calling WlxDialogBoxParam(), a relative of
DialogBoxParam(). The DLL builds w/o errors or warnings,
but I get a runtime error indicating the resource name
wasn't found. Should I stick to pure Win32 (or pure MFC)
when it comes to windowing?

Thanks
-lewism



Fri, 26 Nov 2004 19:01:28 GMT  
 Passing MFC dialog resource to Win32 dialog function
The resources created in the resource editor have nothing to do with
MFC.  They are usable by any Windows code that expects resources.  When
calling WlxDialogBoxParam, are you passing the correct HINSTANCE for the
DLL module that contains the resource?  Are you using MAKEINTRESOURCE to
convert your ID to a string pointer?


Sat, 27 Nov 2004 02:56:52 GMT  
 Passing MFC dialog resource to Win32 dialog function
Scot,

You definitely get my vote for MVP!
Considering I've been stalled on this problem since
Wednesday night, I have to say you've made my week. :-)

Previously I was using GetModuleHandle(NULL) as the DLL
instance handle argument to WlxDialogBoxParam.
Prompted by your question, I've just tried saving the
hModule handle in my DLLMain and using that instead.
Now I am rolling. :-) :-)

Thanks again!
-lewism


Quote:
>-----Original Message-----
>The resources created in the resource editor have nothing
to do with
>MFC.  They are usable by any Windows code that expects
resources.  When
>calling WlxDialogBoxParam, are you passing the correct
HINSTANCE for the
>DLL module that contains the resource?  Are you using
MAKEINTRESOURCE to
>convert your ID to a string pointer?



Sat, 27 Nov 2004 03:53:10 GMT  
 Passing MFC dialog resource to Win32 dialog function
Generally, I try to avoid coding anything like this in the main app; what I'll do is code
the dialog box function in the DLL itself, which makes it easy to get the module handle,
which you would have saved in the DLL entry code somewhere. The less you have to export
from a DLL, the easier life becomes.
                                joe

Quote:

>Scot,

>You definitely get my vote for MVP!
>Considering I've been stalled on this problem since
>Wednesday night, I have to say you've made my week. :-)

>Previously I was using GetModuleHandle(NULL) as the DLL
>instance handle argument to WlxDialogBoxParam.
>Prompted by your question, I've just tried saving the
>hModule handle in my DLLMain and using that instead.
>Now I am rolling. :-) :-)

>Thanks again!
>-lewism


>>-----Original Message-----
>>The resources created in the resource editor have nothing
>to do with
>>MFC.  They are usable by any Windows code that expects
>resources.  When
>>calling WlxDialogBoxParam, are you passing the correct
>HINSTANCE for the
>>DLL module that contains the resource?  Are you using
>MAKEINTRESOURCE to
>>convert your ID to a string pointer?

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Sat, 27 Nov 2004 16:37:19 GMT  
 Passing MFC dialog resource to Win32 dialog function
Oh, all my code is in a DLL. Evidently I m
misinterpreted "module" when I read the MSDN page for
GetModuleHandle(). I figured if I requested the handle
for the current module from code in a DLL, I'd get the
handle for that same DLL.
-lewism

Quote:

>-----Original Message-----
>Generally, I try to avoid coding anything like this in

the main app; what I'll do is code
Quote:
>the dialog box function in the DLL itself, which makes it

easy to get the module handle,
Quote:
>which you would have saved in the DLL entry code

somewhere. The less you have to export
Quote:
>from a DLL, the easier life becomes.
>                            joe

>On Mon, 10 Jun 2002 19:53:10 -0700, "Lewis McCarthy"

>>Scot,

>>You definitely get my vote for MVP!
>>Considering I've been stalled on this problem since
>>Wednesday night, I have to say you've made my week. :-)

>>Previously I was using GetModuleHandle(NULL) as the DLL
>>instance handle argument to WlxDialogBoxParam.
>>Prompted by your question, I've just tried saving the
>>hModule handle in my DLLMain and using that instead.
>>Now I am rolling. :-) :-)

>>Thanks again!
>>-lewism



Mon, 29 Nov 2004 00:42:20 GMT  
 Passing MFC dialog resource to Win32 dialog function
The problem is that the kernel hasn't a clue as to what piece of code executed the
GetModuleHandle(NULL); and as it says, it simply returns the handle of the module that
created the process. Typically you declare a static variable in the DLL module and in the
DLL_PROCESS_ATTACH. As such, it becomes a "write-once constant", which I consider a valid
use of statically-allocated variables.
                                joe

Quote:

>Oh, all my code is in a DLL. Evidently I m
>misinterpreted "module" when I read the MSDN page for
>GetModuleHandle(). I figured if I requested the handle
>for the current module from code in a DLL, I'd get the
>handle for that same DLL.
>-lewism


>>-----Original Message-----
>>Generally, I try to avoid coding anything like this in
>the main app; what I'll do is code
>>the dialog box function in the DLL itself, which makes it
>easy to get the module handle,
>>which you would have saved in the DLL entry code
>somewhere. The less you have to export
>>from a DLL, the easier life becomes.
>>                                joe

>>On Mon, 10 Jun 2002 19:53:10 -0700, "Lewis McCarthy"

>>>Scot,

>>>You definitely get my vote for MVP!
>>>Considering I've been stalled on this problem since
>>>Wednesday night, I have to say you've made my week. :-)

>>>Previously I was using GetModuleHandle(NULL) as the DLL
>>>instance handle argument to WlxDialogBoxParam.
>>>Prompted by your question, I've just tried saving the
>>>hModule handle in my DLLMain and using that instead.
>>>Now I am rolling. :-) :-)

>>>Thanks again!
>>>-lewism

Joseph M. Newcomer [MVP]

Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm


Mon, 29 Nov 2004 05:19:40 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Creating a dialog from a resource template in Win32 dll

2. Dialog resources in Win32 static libraries

3. ANNOUNCE: Enable resizable DHTML dialogs in your Win32 application with [B3 Cyber Dialogs]

4. Derive a MFC dialog from an existing MFC Dialog

5. Non MFC modal dialogs in an MFC application - Dialog Message problem

6. in MFC dialog based application call Win32 Dll fail

7. Trouble with modal dialog in Win32 DLL w / MFC

8. Passing values from Child dialog to Calling Dialog

9. Q: making a child dialog and dialog resources

10. Passing data from a modal dialog to the main dialog

11. Passing info from one dialog to another dialog

12. Can a Dialog resource be inherited from another Dialog

 

 
Powered by phpBB® Forum Software