Large project that I've been working on converting from VC++ 6.0 to VC++ 8.0 (.NET 2005). It has an app (EXE), a main DLL, and 5 component DLLs (formerly COM, but now are MFC Dlls).
One of the DLLs has many dialogs and controls that are used. When I converted over, I just copied most of the resource file (.rc) over to the new one (textually).
Everything looks fine. All dialog boxes and controls appear fine when I look at the resources in the project.
When I get to the point in my code where a dialog box is called, nothing happens. Nothing comes up, it just goes over the line returning a -1.
What is the value of hInst? Is it the handle to the module that contains the dialog resource? If not, that is the reason for the error.
What is m_lpszTemplateName? Is it the name of the dialog resource? If not, again, an error.
When you compiled, did the resource compiler actually compile any resources?
When you open the DLL in a resource editor, do you see the dialog as one of the resources (I believe you can do this with Visual Studio by specifying that you are opening the DLL as a resource).
What is the value of hInst? Is it the handle to the module that contains the dialog resource? If not, that is the reason for the error.
What is m_lpszTemplateName? Is it the name of the dialog resource? If not, again, an error.
When you compiled, did the resource compiler actually compile any resources?
When you open the DLL in a resource editor, do you see the dialog as one of the resources (I believe you can do this with Visual Studio by specifying that you are opening the DLL as a resource).
Regards,
Paul McKenzie
hInst => 0x05C90000 (unused)
I'm not sure the DLL handle, but the 'unused' makes me think it isn't the DLLs handle.
m_lpszTemplateName = 0x000000d0 <Bad Ptr>
Again, "Bad Ptr" doesn't look good.
Ok, looking closer at the copmiler statements and I think I see what you mean;
When you open the DLL in a resource editor, do you see the dialog as one of the resources (I believe you can do this with Visual Studio by specifying that you are opening the DLL as a resource).
If you do a File / Open in Visual Studio, and you open the DLL file you claim has the resource, the DLL file will be loaded, and you will see the resources.
Is there any reason this isn't working now that you can think of?
The code you posted will not help, as all it does is show us that your syntax is OK. It doesn't tell us what is happening at runtime or anything else that would give any indication what the problem is.
If this were a VC 6.0 application, what reasons are there for returning a -1 for DoModal()? Whatever those reasons are, did you investigate whether those are the same reasons with your current application?
One reason is that a control in your dialog is not available or not set up properly. The easiest way to detect this is to remove all controls from the dialog, temporarily comment out any code that might refer to the controls, and see if the empty dialog displays correctly when you run the application. If it does, then add controls one at a time until it breaks.
On a side note, this is suspicious:
Code:
*nSequenceSelection
Did you initialize this pointer? If you didn't, that code where you are setting the return value of DoModal is faulty.
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio: FeinViewer - an integrated GDI objects viewer for Visual C++ Debugger, and more...
All the resource IDs looked numeric. Each dialog had a number associated with it.
And 0xd0 in the FindResource is 208, so the dialog being searched for is correct, in terms of ID.
Therefore the most probable reason is what Vladimir and myself pointed out -- the module where that code is being called from does not have the resources embedded within it -- it needs to go to an "external" library for the resource.
To do that using MFC, the AFX_MANAGE_STATE sets the resource handle (the hInst in the FindResource) to the instance handle of the DLL that contains the resources.
The Windows API way to do this is to call LoadLibrary() and store the HINSTANCE that is returned -- this then becomes the "hInst" in the FindResource function.
Bookmarks