Visual Programming Unit I
Visual Programming Unit I
Types:
3D space:
Orientation
Position in 2D
Object 4 bytes on a 32-bit platform, 8 Any type can be stored in a variable of type Object
bytes on a 64-bit platform
User- Depends on Platform Each member of the structure has a range determined
Defined and is independent of the ranges of the other member
Resources:
A resource is a text file that allows the compiler to manage objects
such as pictures, sounds, mouse cursors, dialog boxes, etc. Microsoft
Visual Studio makes creating a resource file particularly easy by
providing the necessary tools in the same environment used to
program.
Identifiers
An identifier is a symbol which is a constant integer whose name
usually starts with ID. It consists of two parts − a text string (symbol
name) mapped to an integer value (symbol value).
Symbols provide a descriptive way of referring to resources and
user-interface objects, both in your source code and while you're
working with them in the resource editors.
When you create a new resource or resource object,
the resource editors provide a default name for the resource,
for example, IDC_DIALOG1, and assign a value to it.
The name-plus-value definition is stored in the Resource.h file.
Step 1 − Let us look into our CMFCDialogDemo example from the
last chapter in which we have created a dialog box and its ID
is IDD_EXAMPLE_DLG.
Step 2 − Go to the Solution Explorer, you will see the resource.h file
under Header Files. Continue by opening this file in editor and you
will see the dialog box identifier and its integer value as well.
Icons
An icon is a small picture used on a window which represents an
application. It is used in two main scenarios.
On a Window's frame, it is displayed on the left side of the
Window name on the title bar.
In Windows Explorer, on the Desktop, in My Computer, or in
the Control Panel window.
If you look at our MFC Modal Demo example, you will see that
Visual studio was using a default icon for the title bar as shown in the
following snapshot.
You can create your own icon by following the steps given below −
Step 1 − Right-click on your project and select Add → Resources,
you will see the Add Resources dialog box.
Step 2 − Select Icon and click New button and you will see the
following icon.
Menus:
Menus allow you to arrange commands in a logical and easy-to-find
fashion. With the Menu editor, you can create and edit menus by
working directly with a menu bar that closely resembles the one in
your finished application. To create a menu, follow the steps given
below −
Step 1 − Right-click on your project and select Add → Resources.
You will see the Add Resources dialog box.
Step 2 − Select Menu and click New. You will see the rectangle that
contains "Type Here" on the menu bar.
Step 3 − Write some menu options like File, Edit, etc. as shown in the
following snapshot.
Step 4 − If you expand the Menu folder in Resource View, you will
see the Menu identifier IDR_MENU1. Right-click on this identifier
and change it to IDM_MAINMENU.
Step 7 − You will see the menu field in the Properties. Select the
Menu identifier from the dropdown as shown above.
Step 8 − Run this application and you will see the following dialog
box which also contains menu options.
Toolbars
A toolbar is a Windows control that allows the user to perform some
actions on a form by clicking a button instead of using a menu.
A toolbar provides a convenient group of buttons that simplifies
the user's job by bringing the most accessible actions as buttons.
A toolbar can bring such common actions closer to the user.
Toolbars usually display under the main menu.
They can be equipped with buttons but sometimes their buttons
or some of their buttons have a caption.
Toolbars can also be equipped with other types of controls.
To create a toolbar, following are the steps.
Step 1 − Right-click on your project and select Add → Resources.
You will see the Add Resources dialog box.
Step 2 − Select Toolbar and click New. You will see the following
screen.
Accelerators
An access key is a letter that allows the user to perform a menu action
faster by using the keyboard instead of the mouse. This is usually
faster because the user would not need to position the mouse
anywhere, which reduces the time it takes to perform the action.
Windows Message:
Mouse messages
Keyboard messages
Clipboard messages
Dialog messages
MDI messages
You create a message loop by using the Get Message and Dispatch
Message functions. If your application must obtain character input
from the user, include the Translate Message function in the loop.
Translate Message translates virtual-key messages into character
messages.
Device Contexts:
Document Interface:
The user can see and work with different documents, such as a
spreadsheet, a text document or a drawing space, by simply moving
the cursor from one space to another. This feature enables users to
work simultaneously on different documents without having to close
out of one application before starting up another.
Dynamic Linking: