Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 5: The Document/View Architecture



  1. Close it using its System Close button and return to MSVC


5.3 SDI Improvements.......................................................................................


5.3.1 SDI Improvements: The Application...............................................


To make your programming experience a little faster and efficient, the framework
provides many other features for each class used in an application.

The Application: The programs we will create in this book use classes of the Microsoft
Foundation Classes (MFC) library. MFC classes are created is various libraries called
DLLs. In order to use MFC objects in your application as opposed to non-MFC objects,
you must let the compiler know. This is done by specifying that you want to Use MFC In
A Shared DLL, as we have done so far. Additionally, if you want your windows to have a
3 - D appearance, call the Enable3dControls() method. If you do not want the 3-D
appearance, call the Enable3dControlsStatic() method. The best way to deal with this is
to ask the compiler to check if you had allowed using MFC in a shared DLL or not, and
then tell the compiler which of these two functions to execute. This is done using a #ifdef
preprocessor in your InitInstance() method. Here is an example:

#include <afxwin.h>

class CSimpleFrame : public CFrameWnd
{
public:
CSimpleFrame()
{
// Create the window's frame
Create(NULL, "Windows Application");
}
};

class CSimpleApp : public CWinApp
{
public:
BOOL InitInstance();
Free download pdf