Click here to Skip to main content
11,926,429 members (57,256 online)
Click here to Skip to main content
Add your own
alternative version


105 bookmarked

Screen Designer Classes

, 7 Mar 2004
Rate this:
Please Sign up or sign in to vote.
Screen Designer Classes for MFC applications


The dynamic screen classes allow you to incorporate advanced screen functionality into your MFC applications.

The fundamental difference of these classes are that they work with the actual resource in your executable - this means that users of your applications can alter screens that have been designed by you using the MFC resource editor - they can make changes at run time.

These classes are ideal if you develop/are developing applications that require the ability to have additional fields that can be defined by users to store data that is unique to them, or perhaps to remove some of the fields which you have anticipated they may need.

The classes are designed so they are easily incorporated into your existing applications; this allows your existing programs to be modified quite quickly to incorporate the functionality. The classes based on templates and will work with dialogs, views and property pages.

Using the code

The classes are supplied with source code. Unfortunately like most V1.00 products, I have not spent an awful amount of time on the documentation, however I have explained the pertinent points – which are you will see when you run through building a sample program.

This version also has a lot of functionality that I am currently perfecting. For example:

  • I am doing some work so the screen designer works with any type of derived window classes, Dialog, Property Pages, etc.
  • I am working on storing the actual definition in a database or XML file so that changes that are made to the screens are permanent and returned when the application is next run.
  • Controls can be configured to retrieve and save data from database field so users can decide at runtime where the data for a newly created control should be loaded and saved from.
  • Make it work in Visual Studio .NET environment.

I know these are key features – but I thought that you might appreciate the code even if it was not fully “polished” – and it gives me an opportunity to get some feedback so I can improve the classes in line with demand.

If you do want to be notified when the “polished” version is finished or you have some useful comments for me then please drop me an e-mail at

Getting Started

There are a number of ways you can use the screen designer classes, I have written a small application that shows how you would use it in a CFormView application. The sample is called FV and has been compiled with VC6.

The FV application is provided pre-built in EXE format. To use the program:

  • Run it
  • Choose screen designer from the view menu. Once you have re-arranged the screen or added new controls swap back to normal mode by choosing screen designer from the view menu again.

Build a new Application

The steps below re-create the functionality in the FV application; it takes about 10 minutes to run through and is worth it if you want to see what could be possible in your own applications. The example is also provided in full in the samples directory – so you can just follow the instructions below if you prefer.

Step 1 – MFC AppWizard

  • Within VC6 create a new MFC AppWizard (exe). Call the project NewExample.

  • On step 1 of the wizard, change the application to a single document.
  • Leaver the other steps as default, but change step 6 so the base class for CNewExampleView is CFormView.

Step 2 – Modify The Resource

  • After the application has been created modify the resource for IDD_NEWEXAMPLE_FORM – add some additional controls, so it resembles the screen below.
  • Build and make sure the application runs.

Step 3 – Add Screen Designer Application to the sample program

  • Copy all the files from AddToYourProject into your application's directory.
  • Add the files to your project, use the menu option: Project, Add To Project, Files and choose all the files which match Dyn*.*.
  • Open dynscreen.rc in the directory UseInYourProject and copy across the resource from this resource file into your own. If you have never done this before then switch to the resource tab on the left hand side, and drag and drop the resources from the right hand side a folder at a time.
  • Close the dynscreen.rc window, be careful not to save the changes.
  • In the file CnewExampleApp.cpp modify the InitInstance() member function add the line AfxOleInit(); as the first line.
  • In stdafx.h add the following lines at the bottom:
    #include <afxole.h>
    #include "dynscreen.h"
  • Build your project: it should build with no errors. If it errors check the previous steps have been completed in full.
  • Add a new menu option called Screen Designer to the ID_MAINFRAME menu.

  • Add a command handler for ID_SCREEN_DESIGNER to the CMainFrame class. You can do this by holding the CTRL key and double clicking on the Screen Designer menu option when in the resource editor.
  • In the command handler for ID_SCREEN_DESIGNER add the following code:
    void CMainFrame::OnScreenDesigner() 
        // TODO: Add your command handler code here
        CPoint x(500,100);
        BOOL bVisible = ((m_wndDynControlBar.GetStyle() & WS_VISIBLE) != 0);
        m_wndDynControlBar.m_bMakingVisible = TRUE;
        ShowControlBar(&m_wndDynControlBar, !bVisible, FALSE);
        m_wndDynControlBar.m_bMakingVisible = FALSE;
        SendMessageToDescendants(WM_SCREENDESIGNER, !bVisible, 0, TRUE, 
  • In MainFrm.h add the following include:
    #include "DynControlBar.h"
  • In MainFrm.h add the following line in the declaration, you can do it after the line which defines m_wndToolBar.
    CDynControlBar    m_wndDynControlBar;
  • Change the MainFrm.cpp class so the OnCreate function looks like the one shown below. The complete function is shown but only the sections marked "// Screen designer control bar" need to be inserted.
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
            return -1;
        if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE 
            | CBRS_SIZE_DYNAMIC) ||
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create
        if (!m_wndStatusBar.Create(this) ||
            TRACE0("Failed to create status bar\n");
            return -1;      // fail to create
        // Screen designer control bar
        if (!m_wndDynControlBar.CreateEx(this) ||
            TRACE0("Failed to create toolbar\n");
            return -1;      // fail to create
        // TODO: Delete these three lines if you don't want the toolbar to
        //  be dockable
        // screen Designer control bar
        m_wndDynControlBar.SetBarStyle(m_wndDynControlBar.GetBarStyle() |
        CString strText("Screen Designer");
        ShowControlBar(&m_wndDynControlBar, FALSE, FALSE);
        return 0;
  • In CNewExampleView.h include the header file
    #include "DynWnd.h"
  • In CNewExampleView.h change the class declaration line to:
    class CNewExampleView : public CDynWnd<CFormView>
  • In CNewExampleView.cpp change the BEGIN_MESSAGE_MAP line to
    BEGIN_MESSAGE_MAP(CNewExampleView, CDynWnd<CFormView>)
  • In CNewExampleView.cpp change the constructor to read

Rebuild the project. Once you have done this run the application. You will be able to toggle between normal mode and screen designer mode by choosing the screen designer option from the menu.

If you want to know when the next version is available and what’s planned or have some useful suggestions please post a message below.


  • 8 Mar 2004 - udpated sourcecode.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

John Indigo
Web Developer
United Kingdom United Kingdom
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
sylvia_zs25-Jun-13 19:06
membersylvia_zs25-Jun-13 19:06 
GeneralI can't compile it with VS2005 Pin
cnhnyu9-Nov-09 1:02
membercnhnyu9-Nov-09 1:02 
Generalstatic linked mfc Pin
grandmasta19-Sep-07 3:14
membergrandmasta19-Sep-07 3:14 
QuestionHow can I control the object created by drag and drop? Pin
sadlion4-Jan-05 15:19
membersadlion4-Jan-05 15:19 
Questionany mirrors of it? Pin
tuldok23-May-04 12:25
membertuldok23-May-04 12:25 
GeneralUpgrade 8th March 2004 Pin
John Indigo9-Mar-04 8:39
memberJohn Indigo9-Mar-04 8:39 
Generaldoesn't work with 2003 - please help me! Pin
alex-t.de15-Feb-04 5:07
memberalex-t.de15-Feb-04 5:07 
GeneralRe: doesn't work with 2003 - please help me! Pin
John Indigo5-Mar-04 21:37
memberJohn Indigo5-Mar-04 21:37 
Generalvery good!cool! Pin
libinbj27-Jul-03 23:29
memberlibinbj27-Jul-03 23:29 
Generalgood and powerful Pin
psusong28-Mar-03 7:00
memberpsusong28-Mar-03 7:00 
Your artical is very good,and it give me many help in my project when I design my Application's print preview with the ability of interviewing with the client
thank you very much;P
GeneralA heavy version. Pin
TW13-Jan-03 21:52
memberTW13-Jan-03 21:52 
GeneralRe: A heavy version. Pin
psusong28-Mar-03 7:17
memberpsusong28-Mar-03 7:17 
GeneralRe: A heavy version. Pin
Anonymous29-Mar-03 2:24
sussAnonymous29-Mar-03 2:24 
GeneralGood job! Pin
billhao9-Jan-03 2:20
memberbillhao9-Jan-03 2:20 
GeneralRe: Good job! Pin
.S.Rod.9-Jan-03 3:47
member.S.Rod.9-Jan-03 3:47 
General#import "msado15.dll" Pin
.S.Rod.9-Jan-03 0:04
member.S.Rod.9-Jan-03 0:04 
General#import "msado15.dll" Pin
Ralph9-Jan-03 0:22
memberRalph9-Jan-03 0:22 
GeneralRe: #import "msado15.dll" Pin
Hans VL14-Jan-03 4:43
memberHans VL14-Jan-03 4:43 
GeneralRe: #import &quot;msado15.dll&quot; Pin
cheong0012-May-05 23:57
membercheong0012-May-05 23:57 
GeneralActiveX support Pin
A. Riazi8-Jan-03 23:58
memberA. Riazi8-Jan-03 23:58 
GeneralNice! Pin
A. Riazi8-Jan-03 23:54
memberA. Riazi8-Jan-03 23:54 
GeneralExcellent work Pin
Brian D8-Jan-03 23:15
memberBrian D8-Jan-03 23:15 
GeneralRe: Excellent work Pin
Obliterator9-Jan-03 8:10
memberObliterator9-Jan-03 8:10 
GeneralError... Help Pin
Darren Schroeder8-Jan-03 16:52
memberDarren Schroeder8-Jan-03 16:52 
GeneralRe: Error... Help Pin
John Indigo8-Jan-03 21:40
memberJohn Indigo8-Jan-03 21:40 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 8 Mar 2004
Article Copyright 2003 by John Indigo
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid