Click here to Skip to main content
15,885,435 members
Articles / Desktop Programming / MFC

Hosting Windows Forms User Control in MFC Dialogs

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
7 May 2013CPOL2 min read 48.2K   662   12  
This tip/trick discusses about hosting a Windows Form user control in an MFC dialog box and View windows.
��// Microsoft Visual C++ generated resource script.

//

#include "resource.h"



#define APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 2 resource.

//

#ifndef APSTUDIO_INVOKED

#include "targetver.h"

#endif

#include "afxres.h"

#include "verrsrc.h"



/////////////////////////////////////////////////////////////////////////////

#undef APSTUDIO_READONLY_SYMBOLS



#ifdef APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

// TEXTINCLUDE

//



1 TEXTINCLUDE

BEGIN

    "resource.h\0"

END



2 TEXTINCLUDE

BEGIN

    "#ifndef APSTUDIO_INVOKED\r\n"

    "#include ""targetver.h""\r\n"

    "#endif\r\n"

    "#include ""afxres.h""\r\n"

    "#include ""verrsrc.h""\r\n"

    "\0"

END



3 TEXTINCLUDE

BEGIN

    "#define _AFX_NO_SPLITTER_RESOURCES\r\n"

    "#define _AFX_NO_OLE_RESOURCES\r\n"

    "#define _AFX_NO_TRACKER_RESOURCES\r\n"

    "#define _AFX_NO_PROPERTY_RESOURCES\r\n"

    "\r\n"

    "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"

    "LANGUAGE 9, 1\r\n"    

    "#include ""res\\MFCApplication1.rc2""  // non-Microsoft Visual C++ edited resources\r\n"

    "#include ""afxres.rc""      // Standard components\r\n"

    "#if !defined(_AFXDLL)\r\n"

    "#include ""afxribbon.rc""   // MFC ribbon and control bar resources\r\n"

    "#endif\r\n"

    "#endif\r\n"

    "\0"

END



/////////////////////////////////////////////////////////////////////////////

#endif    // APSTUDIO_INVOKED





/////////////////////////////////////////////////////////////////////////////

//

// Icon

//



// Icon with lowest ID value placed first to ensure application icon

// remains consistent on all systems.

IDR_MAINFRAME           ICON         "res\\MFCApplication1.ico"





#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)

LANGUAGE 9, 1



/////////////////////////////////////////////////////////////////////////////

//

// Dialog

//



IDD_ABOUTBOX DIALOGEX 0, 0, 170, 62

STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU

CAPTION "About MFCApplication1"

FONT 8, "MS Shell Dlg"

BEGIN

    ICON            IDR_MAINFRAME,IDC_STATIC,14,14,21,20

    LTEXT           "MFCApplication1, Version 1.0",IDC_STATIC,42,14,114,8,SS_NOPREFIX

    LTEXT           "Copyright (C) 2013",IDC_STATIC,42,26,114,8

    DEFPUSHBUTTON   "OK",IDOK,113,41,50,14,WS_GROUP

END



IDD_MFCAPPLICATION1_DIALOG DIALOGEX  0, 0, 320, 200

STYLE DS_SHELLFONT | WS_POPUP | WS_VISIBLE | WS_CAPTION

 | WS_THICKFRAME

 | WS_SYSMENU

EXSTYLE WS_EX_APPWINDOW

CAPTION "MFCApplication1"

FONT 8, "MS Shell Dlg"

BEGIN

    DEFPUSHBUTTON   "OK",IDOK,209,179,50,14

    PUSHBUTTON      "Cancel",IDCANCEL,263,179,50,14

    CTEXT           "TODO: Place dialog controls here.",IDC_STATIC,10,96,300,8

END



/////////////////////////////////////////////////////////////////////////////

//

// Version

//



VS_VERSION_INFO     VERSIONINFO

  FILEVERSION       1,0,0,1

  PRODUCTVERSION    1,0,0,1

 FILEFLAGSMASK VS_FFI_FILEFLAGSMASK

#ifdef _DEBUG

 FILEFLAGS VS_FF_DEBUG

#else

 FILEFLAGS 0x0L

#endif

 FILEOS VOS_NT_WINDOWS32

 FILETYPE VFT_APP

 FILESUBTYPE VFT2_UNKNOWN

BEGIN

    BLOCK "StringFileInfo"

    BEGIN

        BLOCK "040904B0"

        BEGIN

            VALUE "CompanyName", "TODO: <Company name>"

            VALUE "FileDescription", "MFCApplication1"

            VALUE "FileVersion",     "1.0.0.1"

            VALUE "InternalName",    "MFCApplication1.exe"

            VALUE "LegalCopyright", "TODO: (c) <Company name>.  All rights reserved."

            VALUE "OriginalFilename","MFCApplication1.exe"

            VALUE "ProductName", "TODO: <Product name>"

            VALUE "ProductVersion",  "1.0.0.1"

        END

    END

    BLOCK "VarFileInfo"

    BEGIN

        VALUE "Translation", 0x0409, 1200

    END

END



/////////////////////////////////////////////////////////////////////////////

//

// DESIGNINFO

//



#ifdef APSTUDIO_INVOKED

GUIDELINES DESIGNINFO

BEGIN

    IDD_ABOUTBOX, DIALOG

    BEGIN

        LEFTMARGIN, 7

        RIGHTMARGIN, 163

        TOPMARGIN, 7

        BOTTOMMARGIN, 55

    END

    IDD_MFCAPPLICATION1_DIALOG, DIALOG

    BEGIN

        LEFTMARGIN, 7

        RIGHTMARGIN, 313

        TOPMARGIN, 7

        BOTTOMMARGIN, 193

    END

END

#endif    // APSTUDIO_INVOKED







/////////////////////////////////////////////////////////////////////////////

//

// String Table

//



STRINGTABLE

BEGIN

    IDS_ABOUTBOX            "&About MFCApplication1..."

END





#endif



#ifndef APSTUDIO_INVOKED

/////////////////////////////////////////////////////////////////////////////

//

// Generated from the TEXTINCLUDE 3 resource.

//

#define _AFX_NO_SPLITTER_RESOURCES

#define _AFX_NO_OLE_RESOURCES

#define _AFX_NO_TRACKER_RESOURCES

#define _AFX_NO_PROPERTY_RESOURCES



#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)

LANGUAGE 9, 1

#include "res\\MFCApplication1.rc2"  // non-Microsoft Visual C++ edited resources

#include "afxres.rc"      // Standard components

#if !defined(_AFXDLL)

#include "afxribbon.rc"   // MFC ribbon and control bar resources

#endif

#endif

/////////////////////////////////////////////////////////////////////////////

#endif    // not APSTUDIO_INVOKED



By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer (Senior) BHGE
Germany Germany
I worked as a software engineer and researcher in different countries with a wide range of related projects and engineers from all around the world. I was involved in Oil&Gas, Telecommunication, Transportation, and Semiconductor projects and played various roles such as junior, senior, and lead engineer both in embedded and non-embedded devices and technologies.

During my professional carrier, I was directly involved in designing and maintaining editor, compiler, and interpreter for IEC 611131-3 (PLC programming standard) and fault-tolerant communication layer for distributed automation standard IEC 61499, and many other projects such as DCS (Distributed Control Systems), (SCADA) Supervisory Control and Data Acquisition System, Oilfield (CMS) Computerised Maintenance Systems, Oil&Gas Laboratory Automaton Systems, and Semiconductor Equipment Connectivity Solutions.

Currently, I pursue a Ph.D. degree in Computer Science in the Technical University of Dresden and works as a software engineer in Germany. Beside, I am a certified specialist in Microsoft technologies since 2011.

My main research and work areas are Industrial Communication and Automation Systems, Real-Time Systems, Service-Oriented Systems, IEC 61131-3, IEC 61499, and Distributed Embedded Systems.

Comments and Discussions