Click here to Skip to main content
13,090,541 members (63,906 online)
Click here to Skip to main content
Add your own
alternative version


42 bookmarked
Posted 25 Nov 2001

How to include a dialog without copying from .RC

, 26 Nov 2001
Rate this:
Please Sign up or sign in to vote.
This code allows you to include a dialog in your code snippets without requiring a user to copy from your resource file and pasting it into their own.


Have you ever had a wonderful dialog class you wanted to share with someone? You give them the .h and .cpp files and they go on their way. Five minutes later they are back at your door wanting the dialog resource to go with it. Then they have to open your .RC file and copy the dialog into their .RC file. Two days later you make a change, and the cycle begins all over again.

A quick search of the Internet led to several pieces of information related to using the DLGTEMPLATE structure. The downside of them was that I had to create the structure from scratch.

Then I found article Q231591 on MSDN.

What I did was create an automated method of extracting a dialog resource. The file Dialog1.h is my extraction class.

Why extract the dialog

The biggest advantage of using this method is that you can create your dialog and write the class to support it, using the class wizard. Only when you are packaging the class for final release do you need to extract the dialog structure

How to use the class

In order to use this class you should:

  1. Include header file.
    #include "Dialog1.h"
  2. Somewhere in your program add
    CDialog1 Dlg;

    Replace IDD_PROFILE_SELECTION with the ID of the dialog you are exporting.

When your program reaches this code, you will be presented with a dialog box (created using this method). Choose whether you need a modal or modeless dialog and then press "Do It". You will then be presented with further directions to finish the embedding of the dialog in your class file.

You may now remove the dialog1.h file and calls from your program. I would comment them out, but not remove them. (You might want to make changes in the future)

Once you have made the above changes, you need to make a few more changes to remove dependencies on the resource.h file.

  1. In your header file remove the line
    enum { IDD = IDD...};
  2. In your .cpp file look for any #defined values IDC_PROMPT etc. and copy them from your resource.h file to your header file.

The sample

The sample shows a class that I wrote to display a "Working" message during a long process. It will display text that shows progress, as the background work is going on. I have created it using the method above. In order to use it in your own program, you should #include the .h file and add the .cpp to your project.

It is used similar to CWaitCursor.

#include "CWorking.h"
CWorking  Work;
Work.SetPrompt("Getting List Of Scheduled Reports...");


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Brad Bruce
Architect TRAC Intermodal
United States United States
No Biography provided

You may also be interested in...


Comments and Discussions

Generalreverse enginiering Pin
mezik16-Nov-10 22:59
membermezik16-Nov-10 22:59 
GeneralThanks allot Pin
mezik6-Nov-10 23:22
membermezik6-Nov-10 23:22 
GeneralGood Job! Pin
DaneStorm13-Jun-06 18:59
memberDaneStorm13-Jun-06 18:59 
QuestionComplete workspace? Pin
Sibilant5-Sep-04 14:39
memberSibilant5-Sep-04 14:39 
GeneralCould not get it to work. Pin
WREY12-Jul-03 7:36
memberWREY12-Jul-03 7:36 
GeneralAnother approach Pin
Thomas Freudenberg26-Nov-01 8:58
memberThomas Freudenberg26-Nov-01 8:58 
GeneralRe: Another approach Pin
Brad Bruce26-Nov-01 10:03
memberBrad Bruce26-Nov-01 10:03 
GeneralRe: Another approach Pin
Thomas Freudenberg26-Nov-01 11:37
memberThomas Freudenberg26-Nov-01 11:37 
GeneralRe: Another approach Pin
Rex Turnbull3-Feb-06 3:22
memberRex Turnbull3-Feb-06 3:22 
GeneralRe: Another approach Pin
Roberto Rocco3-Dec-01 7:59
memberRoberto Rocco3-Dec-01 7:59 
GeneralRe: Another approach Pin
Brad Bruce3-Dec-01 11:40
memberBrad Bruce3-Dec-01 11:40 
GeneralRe: Another approach Pin
Thomas Freudenberg3-Dec-01 23:52
memberThomas Freudenberg3-Dec-01 23:52 
GeneralRe: Another approach Pin
eFotografo8-Oct-09 3:59
membereFotografo8-Oct-09 3:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170813.1 | Last Updated 27 Nov 2001
Article Copyright 2001 by Brad Bruce
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid