An Introduction to MFC Programming

 

MFC – Microsoft Foundation Classes

 

CObject - the base class for all classes

CWnd    - base for windows and controls and common window functions

-          e.g. maximize, minimize, move, resize, etc.

 

 


 

 

 


Some of the controls derived from CWnd include:

-          CDialog

-          CFrameWnd

-          CStatic        (static text box)

-          CButton       (command button)

-          CEdit           (edit box)

-          CListBox      (list box)

-          CComboBox (combo box)

 

Some Notation that is commonly used (but it is NOT absolutely required) …

            Cshape  - Class that stores Shape objects

           

            double m_dSomeVariable;

 


                                                Your variable

                                                double data type

 

                                                Member of a class

 

So ---  pCRocket   = pointer to an object from the Rocket class     

                                       Object from the Rocket class

                                       Class notation

                                       Pointer

 

Prefix

Description

ar

Array

b

Boolean

c

Character

c

Class

d

Double

l

Long

lp

Long pointer

m_

Member variable

n or i

Integer

p

Pointer

s

String

sz

String with \0

s_

Static class variable

 

 

Steps to Creating an MFC Application –

File

         New

                    (Projects Tab)

                    Win32 Application

                              Enter a Project Name

                              Click OK to close the dialog window

 

Win32 Application – Step 1 of 1

         Select An Empty Project

         Click FINISH

 

New Project Information

         View the summary of the project

         Click OK to close

 

To Add Files to the Project –

File

         New

                    (Files Tab)

                    select C++ Source File  (.cpp file)

                    check Add to Project

                              Enter Filename & Location

Same for header file –

                    (Files Tab)

                    select C/C++ Header File

                    Enter Filename & Location

                    Click OK

 

** VERY IMPORTANT **

You must set up your project so it uses the MFCC runtime library – IF YOU FORGET, you won’t get any compiler errors, but your program will not be able to react to any events like mouse clicks or Enter key presses!!!

 

Project

         Settings

                    (Project Settings Dialog)

                    click on YOUR PROJECT in the contents window

                    click on the GENERAL tab

                    select Use MFC in a Shared DLL in the

                     combo box for  Microsoft Foundation Classes

 

** To Add Existing Files Of Code To Your Project **

Project

         Add to Project

                    Files

 

Try to set up a project and add the code for Figure 2.8 from the book