The resource editors in the Developer Studio environment share techniques and interfaces to create, copy, modify, and delete application resources quickly and easily.
When you create or open a resource that can be modified, the appropriate editor opens automatically. For example, graphical resources such as toolbar buttons, screen cursors, and icons, which are modifiable bitmaps, cause the Graphics editor to open. Other resources that can be modified include accelerator tables, string tables, and version information; dialog boxes (a combination of graphical components and text strings); and menus (text strings that appear in the menu bar).
The resource editors have many commands and procedures in common. For example, once you learn how to create and open a dialog box, you can use the same steps to create and open any of the other resources. In addition to creating, copying, editing, and deleting, you can use resource editors to:
® View resources.
® Implement resource templates.
® Import or export resources.
® View or modify the property page values.
To quickly access commands that are commonly associated with a particular type of resource, right-click the
resource in the editor window to display its shortcut menu.
This section includes the following topics:
You can use the Dialog editor to create or edit a dialog box template or resource.
To see an illustration that shows the initial screen of the Dialog editor in ResourceView, click this icon.
With the Dialog editor, you can:
® Add, arrange, and edit controls.
® Change the tab order.
® Assign accelerator keys.
® Use guides in the dialog box layout.
® Create a form-view dialog box.
® Import a Visual Basic form to a dialog box resource.
® Test a dialog box.
® Add and edit ActiveX control (.ocx) files.
® Configure custom controls.
Menus enable you to arrange commands in a logical, 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 see an illustration that shows the initial screen of the Menu editor in ResourceView, click this icon.
With the Menu editor, you can:
® Create standard menus and commands.
® Create pop-up menus.
® Assign shortcut keys, accelerator keys, and status bar messages to menus and commands.
® Move menus or commands from one place to another.
After creating a menu, you can use ClassWizard to attach code to menu items.
For more information about the Menu editor, see Building Menus in Chapter 8: Adding User Interface Features.
An accelerator table is a Windows resource that contains a list of accelerator keys and the command identifiers associated with them. Normally, accelerators are used as keyboard shortcuts for program commands that also are available on a menu or toolbar.
To see an illustration that shows the initial screen of the Accelerator editor in ResourceView, click this icon.
You can use ClassWizard to attach accelerator key commands to code.
With the Accelerator editor, you can:
® Add, delete, change, and browse the accelerator key assignments in your project.
® View and change the resource identifier associated with each entry in the accelerator table. The identifier is used to reference each accelerator table entry in program code.
® Associate an accelerator key with a menu item.
For more information about the Accelerator editor, see Adding an Accelerator Key to a Menu in Chapter 8: Adding User Interface Features.
The Toolbar editor helps you create toolbar resources and convert bitmaps into toolbar resources. The Toolbar editor uses a graphical display to show a sample toolbar and selected buttons that closely resemble the toolbar and buttons in a finished application. You can use ClassWizard to link toolbar buttons to code.
The Toolbar editor is functionally similar to the Graphics editor. The menu items, graphics tools, and bitmap grid are the same as those in the Graphics editor.
To see an illustration that shows the initial screen of the Toolbar editor in ResourceView, click this icon.
With the Toolbar editor, you can:
® Create toolbars and buttons.
® Convert bitmaps to toolbar resources.
® Create, move, and edit toolbar buttons.
The Toolbar Editor window shows the full toolbar in the top horizontal pane, and two views of a button image in two panes below. The lower-left pane displays an actual-size version of the image that appears on the selected button. The lower-right pane displays an enlarged version of the button image that is easier to edit. A split bar separates the two lower panes; you can drag the split bar to change the relative sizes of the panes. The active pane displays a selection border.
For more information about the Toolbar editor, see Modifying the Toolbar in Chapter 8: Adding User Interface Features.
Version information consists of company and product identification, a product release number, and copyright and trademark notifications. The Version Information editor helps create and maintain this data.
To see an illustration that shows the initial screen of the Version Information editor in ResourceView, click this icon.
Although the version information resource is not required by an application, it is a useful place to keep information that identifies the application. More important, version information is the data that setup tools and applications use to determine whether a file within an application is current.
With the Version Information editor, you can add or delete string blocks, and you can modify individual string values.
To change the company name in an application
1. In the ResourceView pane, double-click the version information resource (VS_VERSION_INFO).
2. Locate the company name item in the object list.
3. Left-click the entry for the company name, and insert appropriate text.
A string table is a Windows resource that contains a list of IDs, values, and captions for all the strings of an application. For example, status-bar prompts are located in the string table. With the String editor, you can edit an application's string table resource.
To see an illustration that shows the initial screen of the String editor in ResourceView, click this icon.
With the String editor, you can:
® Find a string in the string table.
® Add a string table entry.
® Delete a string.
® Move a string from one segment to another.
® Move a string from one resource script (.rc) file to another.
® Change a string or its identifier.
® Add formatting or special characters to a string.
To add a string to the string table
1. In ResourceView, double-click the string table resource you want to modify.
2. Right-click anywhere in the editing pane (the right side of the Project Workspace window), and then click New String.
3. Type in the appropriate information.
The Graphics editor has an extensive set of tools for drawing bitmaps, icons, and cursors, as well as features to support the creation of toolbar bitmaps and the management of icon and cursor images.
To see an illustration that shows the initial screen of the Graphics editor in ResourceView, click this icon.
With the Graphics editor, you can:
® Use the Image Editor window and docking toolbars.
® Customize and adjust the Graphics editor workspace.
® Edit a graphical resource and draw new graphics.
® Customize colors, change palettes, and select colors.
® Edit icons and cursors, including 48 x 48 icons.
To create a standard 32 x 32 icon
1. In the ResourceView pane, right-click Icon.
2. On the shortcut menu, click Insert Icon.
To create icons of other sizes
1. Select one of the two lower panes in the Image Editor window and, on the Image menu, click New Device Image.
2. In the New Icon Image dialog box, select the type of icon you wish to create, or click Custom to customize the image settings.
Most editing procedures are the same for bitmaps, icons, and cursors.
The Developer Studio Gallery contains reusable code, such as components created by Microsoft, ActiveX controls, and components created by third-party vendors. Third-party components range from reusable code to tools such as a code analyzer.
To see an illustration that shows some of the objects available through the Gallery, click this icon.
This section includes the following topics:
When you insert components into your project, associated header (.h) and implementation (.cpp) files are added to the currently selected default project, and the information in the Project Workspace window is updated. The amount of work required after inserting a component varies. For more information about how to implement a specific component in your application, see the Visual C++ online documentation for that component.
To view the documentation for Gallery components, select the component name in the Gallery dialog box and click More Info, or refer to any additional printed or online documentation supplied by the component vendor. Third-party components usually include documentation as well, but the methods for accessing the documentation may vary.
To see a demonstration that shows how to add a Developer Studio component to an application, click this icon.
The Gallery organizes components in folders by category. You can easily create and add components to the Gallery in an existing category, create new categories, and move components from one category to another.
To add one of your classes to the Gallery, in the ClassView pane, right-click the class name and on the shortcut menu, click Add to Gallery.
To see an illustration that shows the shortcut menu that is displayed when you right-click a class name, click this icon.
Information Resources
Developer Studio provides several methods for learning about the development environment and the supporting software. The online documentation contains the entire Visual C++ and MFC documentation set as well as reference information from a number of software development kits (SDKs). Tutorials contains a series of tutorials to familiarize you with Developer Studio, and with the development of C++ applications using Visual C++ and MFC.
From your source code in an editor window, you can readily get information about a class from MFC, a function name from the C Run-Time Library, or a language element. If you select a name in an editor window, and press F1 or CTRL+F1, Developer Studio displays reference information for that name.
This section gives a brief overview of the information resources available in Developer Studio and explains how to access these resources. This section includes the following topics:
Developer Studio provides two main features for accessing reference information: the Help menu and the InfoViewer. In this topic, you will learn how to use these features to get Help and access reference information quickly from almost anywhere in your project workspace.
To see a complete table of contents for the online documentation, click Contents on the Help menu in Developer Studio, or select the InfoView tab in the Project Workspace window. Once the table of contents is displayed, you can browse through the topics or you can use the InfoViewer to search for reference information on keywords and phrases.
The fastest way to get help from InfoViewer is with the F1 key. Simply position the insertion point on the word about which you want information, and press F1. This method works in source windows, so you can get information about a keyword or an API function, and in the output window, so you can get information about error messages. F1 Help also is available from InfoViewer topic windows if you select a word with the mouse.
To search for reference information on a topic or word not shown in the Project Workspace window, click Search on the Help menu and enter the keyword or phrase.
To display the full InfoViewer toolbar in your workspace environment
1. On the Tools menu, click Customize, and then click the Toolbars tab.
2. Select the InfoViewer check box, and then click Close.
To see a demonstration that shows how to use InfoViewer and get Help, click this icon.
To get Help on a word in a text window
1. In the text window, position the insertion point on the word about which you want Help, and press F1.
If multiple topics exist for the word that you requested, the Results list displays all the topics found. If only one topic exists, that topic appears immediately.
2. Double-click the topic you want to see.
A topic window appears and displays information about the keyword for which you wanted Help.
3. If there are too many topics associated with the keyword, you can instruct InfoViewer to use only part of the keyword topics, or a "subset," when you respond to F1requests. For more information on subsets, see the article "Defining an Information Subset" in the Visual C++ online documentation.
If you have multiple information titles installed, the word for which you asked for Help may have entries in two or more titles, so InfoViewer will list the titles and let you choose which ones you want to view.
Developer Studio comes with extensive documentation that you can use to learn about the development environment and the supporting software. This topic briefly describes the categories of online documentation available for Developer Studio, Visual C++, and MFC.
Developer Studio
The three main categories of the Developer Studio online documentation are:
® Developer Products
® Tools and Technologies
® Platform, SDK, and DDK Documentation
The types of information included in these categories depends on which products you have installed.
Visual C++
The main categories for Visual C++ online documentation are:
® Welcome to Visual C++
® Visual C++ Tutorials
® Visual C++ Programmer's Guide
® Microsoft Foundation Class Reference
® C/C++ Language and C++ Libraries
® Visual C++ Samples
® Developer Studio Environment User's Guide
® Glossary
® Getting Help
MFC
The MFC documentation provides invaluable information to MFC developers. To see an illustration that shows the categories of documentation available within the InfoView pane, click this icon.
Each of these categories provides you with a specific type of documentation and information on MFC and how it works. This topic describes some of the most useful documentation.
Microsoft Foundation Class Reference
This section contains information about programming with the MFC Library. The class library is a set of C++ classes that encapsulate the functionality of applications written for Microsoft Windows.
The Microsoft Foundation Class Reference includes the following:
® A chart of the MFC class hierarchy that graphically details the relationships among classes in the library
® An overview of the class library, designed to help you understand the major components of an MFC application and how they work together
® Detailed descriptions of the classes, global functions, global variables, and macros that make up the Microsoft Foundation Class Library version 4.2
MFC Technical Notes
A technical note is a document written for developers, by developers.
Each technical note describes a problem or feature that is beyond the scope of the published MFC documentation. The technical notes reflect requests for information from users, as well as specialized information that the MFC developers anticipate that advanced users will want.
Additional MFC Information
You also can find much useful information regarding MFC programming in the Visual C++ Tutorials, Visual C++ Programmer's Guide, and Visual C++ Samples areas of the Visual C++ online documentation.
The Microsoft Developer Network (MSDN) is an information resource for developers. MSDN produces the Microsoft Development Library, a comprehensive collection of documentation, books, technical articles and Knowledge Base articles on Microsoft Visual C++ and the Microsoft Developer Studio. Access to MSDN is built into the Developer Studio.
Self-Check Questions
1. What tool do you normally use to start a new MFC-based application?
A. AppWizard
B. The Project Workspace
C. ClassWizard
D. Developer Studio Gallery
2. Which of the panes in the Project Workspace are not specific to the currently loaded project?
A. ClassView
B. ResourceView
C. FileView
D. InfoView
3. Which one of the following operations does the WizardBar have in common with ClassWizard?
A. Jump to the header file that is associated with the current source file.
B. Add an OLE control to the current project.
C. Create new classes that are derived from MFC framework classes.
D. Create and modify message-handling functions.
4. Which resource editor enables you to visually add an ActiveX control to your application?
A. The ActiveX control editor
B. The Dialog editor
C. ClassWizard
D. The shortcut menus within ClassView
5. If also installed on the computer, which other information source is automatically integrated into Developer Studio?
A. The Microsoft Developer Network (MSDN) library CD
B. The Microsoft TechNet CD
C. Microsoft Visual Basic
D. Microsoft Access
Lab 3.1: Creating an SDI Application
In this lab, you will create, build, and run a simple single document interface (SDI) application in the Developer Studio development environment.
To see a demonstration that shows what you will accomplish during the lab, click this icon.
Estimated time to complete this lab: 25 minutes
To complete the exercises in this lab, you must have the required software. For detailed information about the labs and setup for the labs, see Labs in this course.
Objectives
After completing this lab, you will be able to:
® Use AppWizard to create a simple SDI application.
® Use Microsoft Developer Studio and Microsoft Visual C++ to build and run the application.
Prerequisites
There are no prerequisites for this lab.
Exercise
The following exercise provides practice with the concepts and techniques covered in this chapter:
® Exercise 1: Using AppWizard to Create an SDI Application
In this exercise, you will use Microsoft Developer Studio, MFC AppWizard, and Microsoft Visual C++ to create, build, and run a simple SDI application.
® Exercise 1: Using AppWizard to Create an SDI Application
In this exercise, you will use Developer Studio, AppWizard, and Visual C++ 5.0 to create, build, and run a simple MFC single document interface (SDI) application.
All of the functionality in this application is provided in the classes automatically generated by AppWizard.
u Use AppWizard to create a new MFC (.exe) application
1. In Developer Studio, on the File menu, click New.
2. In the New File dialog box, click the Projects tab, and then do the following:
a. Select MFC AppWizard (exe) for the project type.
b. Set the project name to Lab3_1.
c. Set the location for your project.
d. Accept the default platform Win32.
e. Click OK to create the new project workspace.
3. In MFC AppWizard, Step 1, select Single document application and English language support. Click Next to go to Step 2.
This table briefly describes the three application types offered as choices in Step 1.
Application type Description
Single document –
Single Document Interface (SDI) Only one document window can be displayed at a time. Creating SDI applications is the focus of this course.
Multiple documents –
Multiple Document Interface (MDI) Multiple document windows can be displayed at a time.
Dialog-based The application runs as a stand-alone dialog box.
4. In Step 2, accept the default "None" for database support, and then click Next to go to Step 3.
5. In Step 3, clear the check box for support for ActiveX Controls, and then click Next to go to Step 4.
Note Creating applications that use ActiveX controls is beyond the scope of this course. For more information, see Mastering MFC Development Using Visual C++ 5, listed in the Library.
6. In Step 4, accept the default settings (Docking toolbar, Initial status bar, Printing and print preview, 3D controls, and four files in the recent list). There are no changes in the Advanced options; click Next to go to Step 5.
7. In Step 5, select the option to generate source file comments. Choose either static or shared DLL for MFC support, and then click Next to go to Step 6.
Note Choosing to support MFC in a statically linked library includes the relevant code from the MFC libraries, making the executable file larger. Choosing to support MFC as a shared DLL makes the executable file smaller, but you will need to include Mfc42.dll and Msvcrt.dll as part of your application distribution files. For more information about these DLLs, see the article "Naming Conventions for MFC DLLs" in the Visual C++ Programmer's Guide in the Visual C++ online documentation.
For the purposes of this course, you can use shared DLLs to keep the file size smaller.
8. Accept the files and classes proposed in Step 6, and then click Finish.
AppWizard displays the New Project Information dialog box, which summarizes your choices.
9. Click OK; AppWizard creates the application files for you.
After AppWizard creates the starter files for the application, you will be returned to the Developer Studio environment.
Note If you click Cancel, you will return to AppWizard so you can modify your choices.
10. Use the ClassView, ResourceView, and FileView panes of the Project Workspace window to explore the MFC application that AppWizard just created for you.
Note In FileView, you will see a Readme file in the list of files that are automatically generated by AppWizard. Double-click this file to see a summary of what you will find in each of the files that make up your application.
u Build and run the project
1. On the Build menu, click Build Lab3_1.exe, or press F7. Developer Studio displays the status of the build process in the Output window.
2. After the build is complete, on the Build menu, click Execute Lab3_1.exe, or press CTRL+F5, to start the Lab3_1 application.
At this point, the Lab3_1 application has little custom functionality. However, many of the application basics are in place: menus, toolbar, status bar, and window frame. In other chapters in this course, you will learn to extend a starter application such as this one.
The completed code for this exercise is in \Labs\Ch03\Lab01\Ex01.
No comments:
Post a Comment