how to create a self contained dialog that can be used in mutiple applications?
-
hi, i am learning mfc, and having a good time doing so. i currently stuck on how to approach a particular problem: i am trying to create a control a color picker control that has four parts for self contained use in multiple projects. the four (rather simple, i know...) parts are: 1) a static box for showing the color selected 2) three separate spin controls that allow you to select the R,G, B components of the color i know that there are several color pickers avail that do this, but i would like to create my own for use in my own projects, partly as an exercise in how to create self contained controls. problems that i am having: 1) it is my understanding that there is no way to save a dialog as a resource by itself... the resource file is for the whole project. no importing/exporting of individual dialog resources. 2) so that's ok - i will just create a dialog class and include all of the elements that i want as memebers therein and init them in the dialog class in OnInitDialog using their individual ::Create() methods. uh, but wait a minute... when it comes time to listening for events, don't i have to give a resource ID for the call to DDX_Control(, , )... ? Uh, I seem to be chasing my tail here... Any help appreciated. - @LRG
-
hi, i am learning mfc, and having a good time doing so. i currently stuck on how to approach a particular problem: i am trying to create a control a color picker control that has four parts for self contained use in multiple projects. the four (rather simple, i know...) parts are: 1) a static box for showing the color selected 2) three separate spin controls that allow you to select the R,G, B components of the color i know that there are several color pickers avail that do this, but i would like to create my own for use in my own projects, partly as an exercise in how to create self contained controls. problems that i am having: 1) it is my understanding that there is no way to save a dialog as a resource by itself... the resource file is for the whole project. no importing/exporting of individual dialog resources. 2) so that's ok - i will just create a dialog class and include all of the elements that i want as memebers therein and init them in the dialog class in OnInitDialog using their individual ::Create() methods. uh, but wait a minute... when it comes time to listening for events, don't i have to give a resource ID for the call to DDX_Control(, , )... ? Uh, I seem to be chasing my tail here... Any help appreciated. - @LRG
Another option would be to save the dialog template in a separate file that could then be
#include
d in either the .rc or .rc2 file."Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
hi, i am learning mfc, and having a good time doing so. i currently stuck on how to approach a particular problem: i am trying to create a control a color picker control that has four parts for self contained use in multiple projects. the four (rather simple, i know...) parts are: 1) a static box for showing the color selected 2) three separate spin controls that allow you to select the R,G, B components of the color i know that there are several color pickers avail that do this, but i would like to create my own for use in my own projects, partly as an exercise in how to create self contained controls. problems that i am having: 1) it is my understanding that there is no way to save a dialog as a resource by itself... the resource file is for the whole project. no importing/exporting of individual dialog resources. 2) so that's ok - i will just create a dialog class and include all of the elements that i want as memebers therein and init them in the dialog class in OnInitDialog using their individual ::Create() methods. uh, but wait a minute... when it comes time to listening for events, don't i have to give a resource ID for the call to DDX_Control(, , )... ? Uh, I seem to be chasing my tail here... Any help appreciated. - @LRG
I suggest that you build a DLL which gives access to, or maybe exports your dialog. You need to export it if you want to be able to derrive from your dialog. The main difficulty in this case is the selection of a resource ID that's not going to be used in any of the apps that use your DLL. Regards,
Bram van Kampen
-
hi, i am learning mfc, and having a good time doing so. i currently stuck on how to approach a particular problem: i am trying to create a control a color picker control that has four parts for self contained use in multiple projects. the four (rather simple, i know...) parts are: 1) a static box for showing the color selected 2) three separate spin controls that allow you to select the R,G, B components of the color i know that there are several color pickers avail that do this, but i would like to create my own for use in my own projects, partly as an exercise in how to create self contained controls. problems that i am having: 1) it is my understanding that there is no way to save a dialog as a resource by itself... the resource file is for the whole project. no importing/exporting of individual dialog resources. 2) so that's ok - i will just create a dialog class and include all of the elements that i want as memebers therein and init them in the dialog class in OnInitDialog using their individual ::Create() methods. uh, but wait a minute... when it comes time to listening for events, don't i have to give a resource ID for the call to DDX_Control(, , )... ? Uh, I seem to be chasing my tail here... Any help appreciated. - @LRG
In addition to the other replies... Whatever method you choose - resource-only DLL, resource includes, etc., the most important thing is to manage IDs so they don't clash. For example, I personally have a solution with several EXEs that share an MFC extension DLL, and also share common code that is compiled/linked directly into several EXEs. From the start, I set aside blocks of resource IDs for each - one block for the shared DLL, one for common code, and one for EXEs. For new projects, I just have to adjust the _APS_NEXT_xxx values in the resource.h file so the Visual Studio auto-generated IDs start in the proper range of IDs. The info in these technical notes explains the details... TN020: ID Naming and Numbering Conventions[^] TN035: Using Multiple Resource Files and Header Files with Visual C++[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ :java: