Creating a Windows application

C

For creating an application we use AppWizzard. First of all here we are working with projects. A project can contain several applications.
To create a project we will use the File-> New-> Projects commands. From the list presented on the Projects tab (tab) we select the MFC AppWizard (EXE), select the location where it will be stored on the HDD, and then fill in the project name. After this we will have to complete a series of information grouped in stages.

Step 1. Application type

In step 1 we will select the type of application (choose the user interface). We have the following possibilities:

A single document interface (SDI) application has only one document open at a time. When you select File-> Open, the existing and open file will be closed before the new document is opened.
A multiple document interface (MDI) application, such as Excel or Word, can open multiple documents at once. If we want multiple views for a document we will have to build an MDI application.
A dialog-based application, such as the Character Map utility. Applications have no menu.

NOTE: Dialog-based applications are different from those of SDI or MDI. They will be treated separately.

There is also a checkbox that allows us to indicate if we want support for the Document / View architecture. The option is used especially for porting applications from another development system. We will not use it.

Step 2. Databases

At this stage we will choose the level for database support.
There are four possibilities:
For applications without databases we will select None.
If we want to have access to databases but do not want to derive the view from CFormView or do not have a Record menu we will select Header Files Only.
If we want to derive the view from CFormView and have the Record menu but we do not want to serialize the document, we will select Database View Without File Support.
If we want database support and we also want to save the document we will select Database View With File Support.

If we select the last option, we will also need to indicate the data source – the Data Source button.

Step 3. Support for composite documents

ActiveX and OLE technology is referred to as compound document technology.
There are five possibilities at this stage:

If we do not write an ActiveX application, we choose None.

If we want an application that contains embedded or linked ActiveX objects, such as the Word application, we choose Container.

If we want our application to provide objects that can be embedded for other applications, but the application cannot be run separately (stand alone), we will choose Mini Server.

If we want our application to provide objects that can be embedded for other applications, and the application can be run separately (stand alone), we will choose Full Server.

If we want the application to incorporate options 3 and 4 we will select Both Container and Server.

If we choose support for composite documents we will also have support for compound files. Composite files contain one or more ActiveX objects and are saved in a special way so that an object can be modified without rewriting the entire file. For this we make a selection on one of the radio buttons Yes, Please, or No, Thank You.

Also on this page we decide if the application supports automation or will use ActiveX controls.

NOTE: If you want the application to be an ActiveX control, you do not have to create a regular .exe application. ActiveX control creation is done by selecting another option from Projects.

Step 4. Interface options. Other options

The following options affect how the interface is displayed:
Docking Toolbar. AppWizard prepares a toolbar. It can be edited (add, edit, delete).
Initial Status Bar. AppWizard creates a status bar that displays messages attached to menu commands or other application-specific messages.
Printing and Print Preview. The application will have the Print and Print Preview options in the File menu, and some of the required code will be generated by the AppWizard.
Context-Sensitive Help. The Help menu will have Index and Using Help options, and some of the code required to implement Help will be generated by the AppWizard. This decision is difficult to make later because parts of the code are generated in various places within the application.
3D Controls. The application will look like a regular Windows 95 application. If you do not select this option, the dialogs will have a white background and will not be shaded around editing boxes, checkboxes and other controls.
MAPI (Messaging API). The application will be able to send faxes, emails and other messages.
Windows Sockets. The application will be able to access the Internet directly, using protocols such as FTP and HTTP (World Wide Web protocol).

We can also set the number of files in the MRU list. By default this number is 4.
The Advanced button activates two tabs (Document Template Strings, Window Styles) where we can change the name of the application, the title of the frame window, the file extension used in File-> Open, etc.

Properties that can be set for frame windows:

Thick Frame. If not selected, resizing is prevented.
Minimize Box.
Maximize Box.
System Menu.
Minimized. The frame is minimized when the application is launched. For SDI applications, this option will be ignored when the application runs under Windows 95.
Maximized. The frame is maximized when the application starts. For SDI applications, this option will be ignored when the application is running under Windows 95.

Other options

Do we want the MFC library to be “linked” as a shared or static DLL? A DLL is a collection of functions used by different applications. Using DLLs makes the program smaller but harder to install. If the connection is static, the size of the program increases but there are no special problems with the installation.

Step 6. File and class names

The last step determines the names of the classes and files created by the AppWizard. We can change these names. If the application includes a view class, which is usually derived from CView, we can change the base class, for example CScollView or CEditView, which offers increased visualization functionality.

We will press the Finish button to finish generating the application.

Recent Posts

Archives

Categories