I've been using Visual C++ V6.0 for some years now. I believe it's not possible to reuse the code for a dialog box created in one app in another. Is this true? If not, how do I do it? If it is true, is there a more recent version of C++ that permits reuse? Many thanks, David George
The requirement I have is simply to copy the code (both resource and management class) from a prototype program and paste it into another different program, so it can be used with little or no modification. I have no specific program in mind at the moment. But I would like to build a library of dialog resources for future programs I write if this is possible. I have no idea how it could be done. Once again, many thanks, DG
As other speedy people already pointed out, you can reuse dialog resources and classes, unless they are not written to be reusable. I used an .rc2 file, giving a "string ID" to the dialog resource instead of a numeric one, placing the control/commond IDs into a "custom resource.h" and of course the .h and .cpp for the class of the dialog to move commonly used things around projects and this works fine, you just have to remember that you have to explicitly set the .rc2 to be compiled by the resource compiler tool otherwise the resource won't be added to your executable and then you can scratch your head why your dialog does not get displayed when it should.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Life: great graphics, but the gameplay sux. <
As I recall, you can copy a dialog box from the resources of one VC6 project to another. You open them both with the dialog resources visible, hold down Ctrl, click on the resource for the dialog you want to copy, and drag it to the resources window of the other project.
I've reused dialogs where I made a .h and .cpp file that defined the class and a .rc file to define the dialog layout. I based the class on ATL::CDialogImpl<...>. Though I couldn't use a .rc file straight from one project in another, I had to do some work to make sure the .rc file for the dialog contained nothing but information on the actual dialog. I then #include'd the .h and added the .rc as a resource to a new project.