In the previous chapter, you met the Developer Studio interface and saw what information it presents you. In this chapter, the focus is how you tell Developer Studio what to do-with menus, toolbars, and keyboard shortcuts. This chapter offers a thorough overview of the Developer Studio and how to customize it to suit your development style.
Developer Studio has many menus. Some commands are three or four levels deep under the menu structure. In most cases, there are far quicker ways to accomplish the same thing, but for a new user, the menus are an easier way to learn because you can rely on reading the menu items as opposed to memorizing shortcuts. The following lists the menus across the top of Developer Studio and what they do:
The following section presents each Developer Studio menu in turn and mentions keyboard shortcuts and toolbar buttons where they exist.
The File menu, shown in figure 2.1, collects most of the commands that affect entire files or the entire project.
Figure 2.1 : The File menu has actions for files like Open, Close, and Print.
The following are the commands located under the File menu:
File New (Ctrl+N) Choosing this menu item brings up the New dialog box, shown in figure 2.2. You can create one of eight different new items from this dialog box.
Figure 2.2 : The New dialog box is used to create new files or workspaces.
Some of the items in the New dialog box have equivalent menu items. Placing the mouse cursor over a button will display a DataTip, which tells you the buttons function. The following are the eight different new items found in this dialog box:
- Text File-An ordinary source, header, or plain text file. This file is named Text1 (the naming convention is Text and a numerical prefix starting with 1 for the first file and so on) and can be renamed with File, Save As. (New Source File is on the Standard toolbar.)
- Project Workspace-An entire new project. Choosing this item brings up AppWizard, discussed in Chapter 3 "AppWizard and ClassWizard."
- Resource Script-A file with an .rc extension that describes all the resources for your project. Generally your resource scripts are generated by AppWizard.
- Resource Template-A list of the resources you want included in a new script.
- Binary File-Any binary file. You edit it with the rudimentary hexadecimal editor provided by Developer Studio.
- Bitmap File-A bitmap image, 48´48 pixels by default.
- Icon File-A bitmap that will be used as an icon, 32´32 pixels with no ability to change the size.
- Cursor File-A bitmap, 32´32 pixels, with a hot spot that defines the location of a click with that cursor. (For example, the standard arrow cursor has its hot spot at the tip of the arrow.)
Though you can create resources like bitmaps and icons with the File, New menu item and then add those resources into the project, most people go to the Resource View and choose Insert Resource instead. The first two items, Accelerator and Bitmap, are the ones most people choose from this dialog box.
File Open (Ctrl+O) Choosing this item brings up the Open dialog box, as shown in figure 2.3. (It's the standard Windows File Open dialog box, so it should be pretty familiar.) The file type defaults to Common Files with .c, .cpp, .cxx, .h, or .rc extensions. By clicking the drop-down box you can open almost any kind of file, including executables and workspaces.
Figure 2.3 : The familiar File Open dialog box is used to open a variety of file types.
TIP |
Don't forget the list of recently opened files further down the File menu. That can save a lot of typing or clicking. |
File Close Choosing the File, Close item closes the file that has current focus; if no file has focus, the item is grayed. You can also close a file by clicking the cancel button, depicted by an X, in the top-right corner. You may also close the focus window by double-clicking the icon in the upper right-hand corner. (The icon used to be the system menu, denoted by a minus on a button.)
NOTE |
As a sidebar, it is important to remember the various ways in which Windows programs may be closed by users. The previous paragraph mentioned three of them. It will be beneficial to remember this when you are writing applications, so you write programs where any close activity converges on the same code and thus the same activity. |
File Open Workspace Use this item to open a workspace. (You can use File, Open and change the file type to Project Workspace, but using File, Open Workspace is quicker.) The standard Windows 95 and Windows NT open file dialogs enable you to select from almost any file type related to C++ development. The Open Workspace dialog defers to files that are related to projects, like makefiles and project files (refer to fig. 2.4).
Figure 2.4 : The Open Workspace dialog box is slightly different from the usual Open dialog box; there are less file types and a different starting directory.
File Close Workspace Software development is project centric. There are too many files, and it would be aggravating to manually keep track of all of the files of which even a single executable or DLL were comprised. Selecting File, Close Workspace closes all of the views associated with the current project.
File Save (Ctrl+S) Use this item to save the file that has focus at the moment; if no file has focus the item is grayed. There is a Save button on the Standard toolbar as well.
File Save As Use this item to save a file and change its name at the same time. It saves the file that has focus at the moment; if no file has focus, the item is grayed.
File Save All This item saves all the files that are currently open. All files are saved just before a compile and when the application is closed, but if you aren't compiling very often and are making a lot of changes, it's a good idea to save all your files every 15 minutes or so. (You can do it less often if the idea of losing that amount of work doesn't bother you.) (The Save All button is on the Standard toolbar.)
Saving Files You will be creating many kinds of files during the course of developing a single project. You may use the File, Save, File, Save As, and File, Save All options during project development. I would suggest saving frequently. If you haven't developed a consistent habit, consider saving at the end of every logical transition-perhaps the completion of a function or a particularly challenging stretch of code.
NOTE Like almost all other Windows programs, selecting File, Save defaults to File, Save As if you are saving the file for the first time.
Further, you may discover that using just these file saving items is not completely satisfactory. Windows is still capable of losing chains and clusters, which means even if you save frequently the data in your files could become disassociated with the file names. I would suggest acquiring a habit of saving to a diskette every half hour to hour, or based on the importance and complexity of the code under construction.
Combining frequent project saving, backups, and a version control system is going to alleviate at least one problem of software development, that of lost work in progress.
File Find In Files There was a utility developed on UNIX, called grep. Later grep.com for DOS based systems was developed and is still distributed with some developers tools. Grep-some of you may remember-enables you to perform searches across many files.
NOTE I mentioned grep because it is still a viable tool for find text in program source files. And, you may not always want to load the Developer Studio to find some text in files. A down and dirty grep-like tool can be contrived from a DOS commandfor %%f in (*.cpp *.h *.c) do find "some code" %%fIt is often many times cheaper to scrounge for existing code than it is to write new code. You will need as many tools as possible to assist in this endeavor.
File, Find In Files is like an integrated grep-tool. This useful command searches for a word or phrase within a large number of files at once. In its simplest form, shown in figure 2.5, you enter a word or phrase into the Find What edit box, restrict the search to certain types of files in the In Files of Type box, and choose the folder to conduct the search within in the In Folder edit box. The following checkboxes in the bottom half of the dialog box set the options for the search:
- Look in subfolders-Work through all the subfolders of the chosen folder if this is checked.
- Regular expression-The Find What box is treated as a regular expression (see the following sidebar "Regular Expressions") if this box is checked.
- Match case-If this is checked, Chapter in the Find What box matches only Chapter, not chapter or CHAPTER. Upper- and lowercase must match.
- Match whole word only-If this is checked, table in the Find What box matches only table, not suitable or tables.
Using Regular Expressions with Find In Files Many of the Find and Replace operations within Developer Studio can use regular expressions to create a more powerful tool. For example, if you want to search for a string only at the end of a line, or one of several similar strings, you can do so by constructing an appropriate regular expression, entering it in the search dialog box, and instructing Developer Studio to use regular expressions for the search.
When regular expressions are being used, some characters give up their usual meaning and instead stand in for one or more other characters. Regular expressions in Developer Studio are built from ordinary characters mixed in with these special entries. See Table 2.1 for expressions.
Table 2.1 Regular Expressions That Can Be Used with Find In Files
Entry Matches ^ Start of the line. $ End of the line. . Any single character. [] Any one of the characters within the brackets (use - for a range, ^ for "except"). \~ Anything except the character that follows next. * Zero or more of the next character. + One or more of the next character. \( \) Doesn't match specially, but saves part of the match string to be used in the replacement string. Up to nine portions can be tagged like this. \{\!\} Either of the characters within the {}. {\\} Just like []. \:a A single letter or number. \:b Whitespace (tabs or spaces). \:c A single letter. \:d A single numerical digit. \:n An unsigned number. \:z An unsigned integer \:h A hexadecimal number \:i A string of characters that meets the rules for C++ identifiers (starts with a letter, number, or underscore) \:w A string of letters only \:q A quoted string surrounded by double or single quotes \ Removes the special meaning from the character that follows
You don't have to type these in if you have trouble remembering them. Next to the Find What box is an arrowhead pointing to the right. Click there to bring up a shortcut menu of all these fields, and click any one of them to insert it into the Find What box. (You need to be able to read these symbols to understand what expression you are building, and there's no arrowhead on the toolbar Find box.) Remember to check the Regular Expressions box so that these regular expressions are evaluated properly.
The bulleted list below exemplifies some of the many possible variations of text and code you can use with Find In Files:
- ^test$ matches only test alone on a line.
- doc[1234] matches doc1, doc2, doc3, or doc4 but not doc5.
- doc[1-4] matches the same strings as above but requires less typing.
- doc[^56] matches doca, doc1, and anything else that starts with doc and is not doc5 or doc6.
- If the Find What box contains (\Good\) morning and the replace box is \1 afternoon, then Good morning is changed to Good afternoon.
- H\~ello matches Hillo and Hxllo (and lots more) but not Hello.
- \{x\!y\}z matches xz and yz.
- New *York matches New York but also NewYork and New York.
- New +York matches New York and New York but not NewYork.
- New.*k matches Newk, Newark, and New York, plus lots more.
- \:n matches 0.123, 234, and 23.45 (among others) but not -12.
- World$ matches World at the end of a line but World\$ matches only World$ anywhere on a line.
It is also possible to use the regular expressions you may have learned for two other popular editors: Brief and Epsilon. This is discussed under "Tools Options" later in this chapter.
Using Advanced Text Finding Features At the bottom right of the Find in Files dialog box is the Advanced button. Clicking it expands the dialog box to that shown in Figure 2.6 and allows you to search several different folders at once.
Figure 2.6 : Advanced Find in Files searches for a string within several folders and their subfolders.
TIP If you highlight a block of text before selecting Find In Files, that text is put into the Find What box for you. If no text is highlighted, the word or identifier under the cursor is put into the Find What box.The results of the Find in Files command appear in the Find in Files tab of the output window; the output window will be visible after this operation if it was not already. You can resize this window like any other window, by holding the mouse over the border until it becomes a sizing cursor, and you can scroll around within the window in the usual way. Double-clicking a filename in the output list opens that file, with the cursor on the line where the match was found.
File Page Setup This item brings up the Page Setup dialog box, shown in Figure 2.7. Here you specify the header, footer, and margins-left, right, top, and bottom. The header and footer can contain any text including one or more special fields, which you add by clicking the arrow next to the edit box or entering the codes yourself.
Figure 2.7 : The Page Setup dialog box lays out your printed pages the way you want.
The File, Page Setup dialog is enabled when a text view has the focus. The Page Setup enables you to format the printed code page output. The options are as follows:
- Filename-The name of the file being printed (&f)
- Page Number-The current page number (&p)
- Current Time-The time the page was printed (&t)
- Current Date-The date the page was printed (&d)
- Left Align-Align this portion to the left (&l)
- Right Align-Align this portion to the right (&r)
- Center-Center this portion (this is the default alignment) (&c)
Headers are placed a quarter of an inch from the top of the page and footers are one-half inch from the bottom.
File Print (Ctrl+P) Choosing this item prints the file with focus according to your Page Setup settings. (The item is grayed if no file has focus.) The Print dialog box, shown in Figure 2.8, has you confirm the printer you want to print on. If you have some text highlighted, the Selection radio button is enabled. Choosing it lets you print just the selected text; otherwise only the All radio button is enabled, which prints the entire file. If you forget to set the headers, footers, and margins before choosing File, Print, the Setup button brings up the Page Setup dialog box discussed in the previous section. There is no way to print only certain pages, or to cancel printing once it has started.
Figure 2.8 : The Print dialog box confirms your choice to print a file.
Recent Files and Workspaces The recent files and workspaces groups of items are between Print and Exit. The items are the names of files and workspaces which have been opened most recently, up to the last four of each. The menu entries are real timesavers if you work on several projects at once. Developer Studio adds the names of up to four files and four projects onto the menu as you open them. Whenever you want to open a file, before you click that toolbar button and prepare to point and click your way to the file, think first if it might be on the File menu. Menus aren't always the slower way to go!
File Exit Probably the most familiar Windows menu item of all, this closes Developer Studio. You can also click the X in the top-right corner, or double-click what used to be the system menu in the top left. If you have made changes without saving, you get a chance to save each file on your way out.
The Edit menu, shown in Figure 2.9, collects actions related to changing text in a source file.
Figure 2.9 : The Edit menu holds items that change the text in a file.
The following items are on this menu:
Edit Undo (Ctrl+Z) The Undo items is the oops menu item. Selecting Edit, Undo has saved me from having to re-open a saved file a few dozen times. If you are saving often, then you have a backup plan if you are unable to undo. Most operations, like text edits and deleting text, can be undone. There are some things that can not be undone however, making frequent saves a good contingency plan. When Undo is disabled, it is an indication that nothing needs to be undone or that you can not undo the last operation.There is an Undo button on the Standard toolbar. Clicking the button displays a stack (reverse order list from most recent to least recent) of operations that can be undone. You must select a contiguous range of undo items including the first, second, and so on. You can not pick and choose.
Edit Redo (Ctrl+Y) As you undo actions, the name given to the operations moves from the Undo to the Redo list (Redo is next to Undo on the toolbar). If you undo a little too much, choose Edit, Redo to un-undo them (if that makes sense.) Selecting Undo or Redo from the menu works backwards performing the operation from the most recent to the least recent operations that can be undone or redone. Using the toolbar combobox enables you to perform several of each in one step.
Edit Cut (Ctrl+X) This item cuts the currently highlighted text to the Clipboard. That means a copy of it goes to the Clipboard and the text itself is deleted from your file. The Cut (represented as shears) button is on the Standard toolbar.
Edit Copy (Ctrl+C) Editing buttons on the toolbar are grouped next to the scissors (Cut). Edit, Copy copies the currently selected text or item to the Windows Clipboard.
Edit Paste (Ctrl+V) Choosing this item copies the Clipboard contents at the cursor, or replaces the highlighted text with the Clipboard contents if any text is highlighted. The Paste item and button are disabled if there are no datum in the Clipboard in a format appropriate for pasting to the focus window. In addition to text, you can copy and paste menu items, dialog box items, and other resources. The Paste button is on the Standard toolbar.
TIP |
Did you know that you can use the Cut and Paste steps and the clipboard to grab icons and text from any Windows program to another? (Something Jonathan Wild would appreciate.) |
Edit Delete (Del) Edit, Del clears the selected text or item. If what you deleted is undeletable, then the Undo button will be enabled and the last operation added to the Undo button combobox. Deleted material does not go to the Clipboard and cannot be retrieved except by Undo-ing the delete.
Edit Select All (Ctrl+A) Euphemistically the snatch and grab button, selecting Edit, Select All highlights everything in the file with focus that can be selected. For example, if a text file has focus, the entire file is selected. If a dialog box has focus, every control on it is selected.To select many items on a dialog box, click the first item and then Ctrl+click each of the remaining items. It is often faster to use Edit Select All to select everything, and then Ctrl+click to unselect the few items you do not want highlighted.
Edit Find (Ctrl+F) The Find dialog box shown in figure 2.10 enables you to search for text within the file that currently has the focus. Enter a word or phrase into the Find What edit box. The following checkboxes set the options for the search:
Figure 2.10 : The Find dialog box is used to find a string within the file that has focus.
- Regular expression-The Find What box is treated as a regular expression (see previous sidebar "Regular Expressions") if this box is checked.
- Match case-If this is checked, Chapter in the Find What box matches only Chapter, not chapter or CHAPTER. Upper- and lowercase must match.
- Match whole word only-If this is checked, table in the Find What box matches only table, not suitable or tables.
- Direction-Choose the Up radio button to search backwards, and the Down radio button to search forwards through the file.
TIP If you highlight a block of text before selecting Edit Find, that text is put into the Find What box for you. If no text is highlighted, the word or identifier under the cursor is put into the Find What box.A typical use for the Find dialog is to enter some text and in conjunction use the Find Next button until you find the precise occurrence of the text for which you are searching. But you may want to combine the Find feature with bookmarks (discussed a little later in this section), and put a bookmark on each line that has an occurrence of the string. Click the Mark All button in the Find dialog box to add temporary, unnamed bookmarks on match lines; they are indicated with a blue oval in the margin.
There is a Find edit box on the Standard toolbar. Enter the text you want to search for in the box and press Enter to search forward. Regular expressions are used if you have turned them on using the Find dialog box. To repeat a search, click the Find Next or Find Previous-icons with binoculars with clockwise and counter-clockwise arrows, respectively-buttons on the Standard toolbar.
Edit Replace (Ctrl+H) This item brings up the Replace dialog box, shown in Figure 2.11. It is very similar to the Find dialog box but is used to replace the found text with new text. Enter one string into the Find What edit box and the replacement string into the Replace With edit box. The three checkboxes, Regular Expression, Match Case, and Match Whole Word Only, have the same meaning as on the Find dialog box (discussed in the previous section). The Replace In radio buttons allow you to restrict the search-and-replace operation to a block of highlighted text, if you prefer.Figure 2.11 : The Replace dialog box is used to replace one string with another.
To see the next match before you agree to replace it, click Find Next. To replace the next match, or the match you have just found, click Replace. If you are confident that there won't be any false matches, you can click Replace All to do the rest of the file all at once. (If you realize after you click Replace All that you were wrong, there is always Edit, Undo.)
Edit Go To (Ctrl+G) The Edit, Go To item (see fig. 2.12) is a central navigation point. It enables you to go to a particular line number (the default), address, reference, or bookmark, among other things. To use the Go To dialog, select what it is you are going to from the list (shown in fig. 2.12) and enter the value: if the Line is selected, enter a line number; if a bookmark is selected, pick the particular bookmark from the combobox, and so on.Figure 2.12 : The Go To dialog box moves you around within your project.
The following are examples of bookmarks, line numbers, or addresses in the file to which you can move the cursor:
- Address-In the Memory or Disassembly windows, as explained in Chapter 20, "Debugging," you can go to an address given by a debugger expression.
- Bookmark-In a text file you can go to a bookmark, though you are more likely to use Edit, Bookmarks or the bookmark-related buttons on the Edit toolbar.
- Definition-If the cursor is over the name of a function, this opens the source (.cpp) file at its definition. If the cursor is over a variable, it opens the include (.h) file.
- Error/Tag-After a compile you can move from error to error by double-clicking them within the output window by using this dialog box, or (most likely) by pressing f4.
- InfoViewer Annotation-If you have added many of your own notes to InfoViewer topics, you can review them through this selection.
- InfoViewer Bookmark-This is one way to cycle through your InfoViewer bookmarks, but most of the time the InfoViewer toolbar or Edit, Infoviewer Bookmarks is a better way.
- Line-This is the default selection. The line number that is filled in for you is your current line.
- Offset-Offset refers to an Offset address. In a segmented architecture absolute addresses were contrived by adding the segment and offset address. Referring to memory by its offset is a throwback to segmented addressing; you may enter the offset address as a hexadecimal or decimal number.
- Reference-Enter a name, like a function or object name, and the cursor will be placed on the line of code where the name is defined. The Reference Go To even works if it is a name you did not define. (For example, given the line of code cout << "Greetings from mars!" << endl;, entering operator<< will focus the cursor in the ostream.h file on an overloaded operator<< line of code. A very useful item indeed.)
Edit InfoViewer Bookmarks This item brings up a list of your InfoViewer bookmarks, as shown in Figure 2.13. When you first bring up the dialog box, the Name box is filled in with the name of the InfoViewer topic you most recently displayed. Clicking Add adds a bookmark to that topic; Close closes the dialog box; Delete deletes the bookmark; Display shows a list of the topics in InfoViewer; and, Help gives you regular help (not InfoViewer) about the dialog box. When the Book button heading is down, the bookmarks are sorted by book; click the Name button heading to sort them by name instead.
The InfoViewer toolbar (not the toolbar at the top of each InfoViewer topic window) has a number of buttons related to InfoViewer bookmarks. Help Bookmark List brings up the dialog box; Previous Bookmark in List goes back to the previous bookmark; and Next Bookmark in List moves forward to the next bookmark.
Edit Bookmark (Alt+f2) This item is used to manage the bookmarks within your text files, which are completely independent of any InfoViewer bookmarks you may have set. The bookmark list is shown in Figure 2.14. Note that temporary bookmarks set by the Find command are not included on this list.Figure 2.14 : The Bookmarks dialog box manages the bookmarks you have set in text files.
To add a named bookmark for the line you are on and have it saved with the file, type a name in the Name box and click Add. To go to a named bookmark, choose it from the list box and click Go To. There are buttons on the Edit toolbar to add or delete a bookmark at the cursor, move to the next or previous bookmark, and clear all bookmarks in the file.
Edit Breakpoints (Alt+f9) A breakpoint pauses program execution. (A break is sometimes more colorfully referred to as soft-ice.) At the lowest level (the ROM BIOS) there is support for breakpoints, the interrupt 3 function. In fact, adding an int 0x03, assembler instruction still works. Luckily we have more powerful ways to break program execution.The Edit, Breakpoints item displays the Breakpoints dialog box, shown in Figure 2.15 and discussed in Chapter 20, "Debugging." It enables you to set simple as well as conditional breakpoint, based on iterations over a line of code and logical conditional tests.
Figure 2.15 : The Breakpoints dialog box is used in debugging your application.
Edit Properties (Alt+Enter) Choosing this item brings up a property sheet. The property sheets for different items vary widely, as shown in Figures 2.16, 2.17, and 2.18, which illustrate the property sheet for an entire source file, an accelerator table selected in the project workspace window, and one key in that accelerator table, respectively.Property sheets are a powerful way of editing non-source file entities such as resources. For functions and variables, however, it's usually easier to make the changes in the source file. Some rather obscure effects can only be achieved through property sheets. For example, to turn off syntax coloring for a file, use the property sheet to set the language to None. (The effect will be observed after the window is repainted by Windows.)
TIP The property normally disappears as soon as you click something else. If you click the pushpin button in the top-left corner, it stays "pinned" to the screen as you work, displaying the properties of all the entities you are working with.
The View menu, shown in figure 2.19, collects actions that are related to the appearance of Developer Studio-which windows are open, what toolbars are visible, and so on.
Figure 2.19 : The View menu controls the appearance of Developer Studio.
View ClassWizard (Ctrl+W) ClassWizard is probably the most-used tool in the Developer Studio. Whenever you add a resource (menu, dialog box, control, and so on), you connect it to your code with ClassWizard. When you are working with OLE, you use ClassWizard to set up properties, methods, and events. If you use custom messages, you use ClassWizard to arrange for them to be caught. Some of the functionality of ClassWizard has been captured in the WizardBar on the top of source (.cpp) file windows, but much more is reached through this menu item or the ClassWizard button on the Standard toolbar.ClassWizard and the Wizard bar are discussed in Chapter 3 "AppWizard and ClassWizard."
CAUTION All changed files are saved when you bring up ClassWizard, just as they are saved before a compile. If you've been making changes that you may not want saved, don't bring up ClassWizard.
View Resource Symbols This item brings up the Resource Symbols dialog box, shown in Figure 2.20. It displays the resource IDs, such as ID_EDIT_COPY, used in your application. The large list box at the top of the dialog box lists resource IDs, and the smaller box below it reminds you where this resource is used-on a menu, in an accelerator, in the string table, and so on. The buttons along the right side are used to make changes. Click New to create a new resource ID; Delete to delete this resource ID (if it is not in use); Change to change the ID (if it is in use by only one resource); and View Use to open the resource (menu, string table, and so on) that is highlighted in the lower list.Figure 2.20 : The Resource Symbols dialog box displays resource IDs.
There is a Resource Symbols button on the Resource toolbar that brings up the same dialog box.
View Resource Includes Choosing this item brings up the Resource Includes dialog box, as shown in Figure 2.21. It is unusual for you to need to change this generated material. In the rare cases where the resource.h generated for you is not quite what you need, you can add extra lines with this dialog box.
Figure 2.21 : The Resource Includes dialog box lets you insert extra directives into the file that describes the resources of your project.
View Full Screen This item hides all the toolbars, the menus, the output window, and the project workspace window, giving you your entire screen as the main working area. One small toolbar appears whose only button is Toggle Full Screen. Click that button to restore the menus, toolbars, and windows.
View Toolbars Choosing this item brings up the Toolbar dialog box, as shown in Figure 2.22. Toolbars are discussed in a section of their own later in this chapter.
Figure 2.22 : The Toolbars dialog box is used to display or suppress any of the eight toolbars in Developer Studio.
View Info Viewer Query Results Selecting View, InfoViewer Query Results returns the results of a previous InfoViewer Query. These Query lists are generated when you choose the Query tab of the Search dialog box, reached from Help, Search, and are discussed in the "Help" menu section of this chapter.The pushpin in the top-left corner keeps the dialog box open (even when you move focus elsewhere), and the tab along the bottom makes it easy to switch between query results and the history list.
View Info Viewer History List Choosing this item brings up a history of the InfoViewer topics you have displayed recently, like the one in Figure 2.23. Double-click any topic to display it again. Use the tab at the bottom to switch to query results, if you want. There is no InfoViewer History toolbar button, but you can use the Query Results button on the InfoViewer toolbar and then use the tabs to switch to the history list.
Figure 2.23 : The InfoViewer history list simplifies revisting Help topics.
View Project Workspace (Alt+0) Choosing this item brings up the Project Workspace window, if it is hidden. It does not take away the Project Workspace window. To hide it, right-click the window and choose Hide, or press Shift+Esc while the window has focus. There is a Project Workspace button on the Standard toolbar which hides or displays the window.
Figure 2.24 : The Insert menu collects actions related to inserting something into your project or one of its files.
View Info Viewer Topic (Alt+1) This item reopens your most recently viewed InfoViewer topic.
View Output (Alt+2) This item brings up the output window, if it is hidden. To hide the output window, right-click in it and choose Hide, or press Shift+Esc while the window has focus. The output window opens automatically when you build your project or use Find in Files.
Debugging Views The remainder of the View menu deals with windows used while debugging, which are discussed in Chapter 20, "Debugging." The remaining View menu items are the following:
- View Watch (Alt+3)
- View Variables (Alt+4)
- View Registers (Alt+5)
- View Memory (Alt+6)
- View Call Stack (Alt+7)
- View Disassembly (Alt+8)
The Insert menu is one way to add items to a project or a file. The items in the Insert are:
Insert File Use this item to insert, at the cursor, an entire file into the file with focus.
Insert Resource (Ctrl+R) Use this item to add a new resource to your project. The Insert Resource dialog box, as shown in Figure 2.25, appears. Choose the type of resource to be added and click OK.Figure 2.25 : The Insert Resource dialog box is one way to add resources to your project.
There are buttons on the Resource toolbar to add a new dialog box, menu, cursor, icon, bitmap, toolbar, accelerator, string table, or version.
Insert Resource Copy Use this item to copy an existing resource, changing only the language (for example, from US English to Canadian French) or the condition (for example, building a debug version of a dialog box). Your project will have different language versions of the resource, allowing you to use compiler directives to determine which resource is compiled into the executable.
Insert Files into Project When you create a new workspace with File, New, Project Workspace the resultant project will be empty. To add modules (.CPP and .H) files into your project select Insert, Files Into Project. If you use the ClassWizard or AppWizard, they will each generate several files automatically.
Insert Project While you usually have only one project in a project workspace, you can insert another. Choose this item to generate another top-level project or a subproject within this project workspace. The Insert Project dialog box, shown in figure 2.26, looks very much like the New Project Workspace dialog box, discussed with AppWizard in Chapter 3 "AppWizard and ClassWizard." Subprojects are discussed later in this chapter, under the menu item Build Subprojects.
Figure 2.26 : The Insert Project dialog box creates new projects within this project workspace.
Insert Component This menu item brings up the component gallery, which allows you to use tools and controls created for another project or by a third party. The component gallery is discussed in Chapter 29, "Power-User Features in Developer Studio."
The Build menu, shown in figure 2.27, holds all the actions associated with compiling, running, and debugging your application.
Build Compile (Ctrl+f7) Choosing this item compiles the file with focus. This is a very useful thing to do when you are expecting to find errors or warnings, such as the first time you compile after a lot of changes. For example, if there is an error in a header file that is included in many source files, a typical build produces error messages related to that header file over and over again as each source file is compiled. If there are warnings in one of your source files, a typical build links the project, but you might prefer to stop and correct the warnings. There is a Compile button on the Project toolbar, represented by a stack of papers with an arrow pointing downward.
Build Build (f7) This item compiles all the changed files in the project and then links them. There is a Build button on the Project toolbar.
Build Rebuild All This item compiles all files in the project, even those that have not been changed since the last build, and then links them. There are times when a typical build misses a file that should be recompiled, and using this item corrects the problem.
Build Batch Build Typically a project contains at least two configurations: Debug and Release. Usually you work with the Debug configuration, changing, building, testing, and changing again until it is ready to be released, and then build a Release version. If you ever need to build several configurations at once, use this menu item to bring up the Batch Build dialog box shown in Figure 2.28. Choose Build to compile only changed files, and Rebuild All to compile all files. If the compiles are successful, links follow.
Figure 2.28 : The Batch Build dialog box builds several configurations of your project at once.
Build Stop Build (Ctrl+Break) This item stops an ongoing build. The typical situation is when you spot an error in the output window that you know will cascade throughout the build so you stop it early to fix the error. There is a Stop Build button on the Project toolbar.
NOTE |
Microsoft has done something interesting with the Build and Stop Build menu items: They both have B as a mnemonic. So many Windows programmers have learned the importance of using unique mnemonics that many don't know what happens when two items use the same letter. When you press Alt+B+B the first non-grayed item is chosen. If you are not building at the moment, Build is enabled and Stop Build is grayed, so Build is chosen. During a build, Build is grayed and Stop Build is enabled, so Stop Build is chosen. Alt+B, B is a nice convenient set of keystrokes to start or stop a build, and you don't need to remember two sets. Keep this in mind for menus you create, as long as you, too, can be sure that only one of the pair of items will ever be enabled at any time. |
Build Update All Dependencies Just as situations sometimes arise when only a full rebuild can clear up confusion about which files have changed recently, sometimes it is necessary to rebuild the list of dependencies. If a header file changes, all the source files that include that header file must be compiled during a build. When header files include other header files, or when files are added to a project, the list of dependencies can get messed up. This item regenerates the list and gets everything running smoothly again.
Build Debug Debugging is a lengthy topic, discussed in Chapter 20, "Debugging."
Build Execute (Ctrl+f5) Choosing the Build, Execute item is about the fastest way to run your program from the Developer Studio. If the executable file is up-to-date, then the program is executed immediately; otherwise, the code is compiled and linked. As a reminder, being up-to-date refers to a comparison between the date stamps of the current executable and all of the project files; if the executable date stamp is greater than or equal to that of the source files, then it is considered up-to-date.
Build Settings (Alt+f7) This item brings up the Project Settings dialog box, which has the following eight tabs:
- General-Change the static versus shared DLL decision you made when AppWizard built this project; change the directory where intermediate (source and object) or output (EXE, DLL, OCX) files are kept (see fig. 2.29).
Figure 2.29 : The General tab of the Project Settings dialog box governs where files are kept.
- Debug-These settings are discussed in Chapter 20, "Debugging."
- Custom Build-These settings are discussed in Chapter 29, "Power-User Features in Developer Studio."
- C/C++-These are your compiler settings. The Category combobox has General selected by default. To change the settings category, select a category from the combobox. Figure 2.30 shows the General category. You can change the optimization criteria (your choices are Maximize Speed, Minimize Size, Customize, or Disable if your debugging is being thrown off by the optimizer) or the warning level. The higher you set the warning level, the more warning messages you get. Most users don't change any other compiler settings.
Figure 2.30 : The C/C++ tab of the Project Settings dialog box governs compiler settings in eight categories, starting with General.
- Link-This tab controls linker options, which you are unlikely to need to change. The settings are divided into five categories; the General category is shown in Figure 2.31.
Figure 2.31 : The Link tab of the Project Settings dialog box governs linker settings in five categories starting with General.
- Resources-This tab, shown in Figure 2.32, is used to change the language you are working in. This changes which resources are compiled into your application and changes other resource settings.
Figure 2.32 : The Resources tab of the Project Settings dialog box governs resources settings including language.
- OLE Types-This tab is used by programmers who are building a type library (TLB) from a object description (ODL) file. This is discussed in Chapter 25, "ActiveX Automation."
- Browse Info-This tab, shown in Figure 2.33, controls the Browse Info (.bsc) file used for the Go To Definition, Go To Declaration, and similar menu items. If you never use these, your links will be quicker if you don't generate browse information. If you want browse information, in addition to checking Build Browse info file on this tab, check Generate Browse info in the General category of the C/C++ tab.
Figure 2.33 : The Browse Info tab of the Project Settings dialog box turns on or off the powerful browse feature.
To see the last few tabs, click the right-pointing arrow at the end of the list of tabs. You can adjust the settings for each configuration (Debug, Release, and so on) separately or all at once. Many of the panes have a Reset button that restores the settings to those you chose when you first created the project.
Build Configurations Choosing this item brings up the Configurations dialog box, shown in Figure 2.34. Here you can add or remove configurations. Use Project Settings to change the settings for the new configuration.
Figure 2.34 : The Configurations dialog box lets you add to the standard Debug and Release configurations.
Build Subprojects This item controls the subprojects within your project using the Subproject dialog box, shown in Figure 2.35. If you have several applications that use the same group of objects and resources, you may want to gather those objects and resources together into a subproject and then insert that subproject into each project that uses them. This transfers the responsibility for keeping those subprojects up-to-date onto Developer Studio instead of you. For example, if you add a file to the subproject, you do not need to add that file to each project that uses it.
Figure 2.35 : The Subprojects dialog box is used to manage subprojects within a project.
Build Set Default Configuration The Default Project Configuration dialog box, shown in Figure 2.36, sets which of your configurations (typically Debug and Release) is the default. The default configuration is displayed in the Project Workspace window and is the configuration built by the Build commands.
Figure 2.36 : The Default Project Configuration dialog box sets the default configuration.
The Tools menu, shown in Figure 2.37, holds the odds-and-ends leftover commands that don't fit on any other menu.
Figure 2.37 : The Tools menu has a variety of commands that don't belong anywhere else.
The Tools menu commands are:
Tools Browse (Alt+f12) The browser is a very powerful addition to Developer Studio; you use it whenever you go to a definition or reference, check a call graph, or otherwise explore the relationships among the classes, functions, and variables in your project. However, it's unusual to access the browser through this menu item, which brings up the Browse dialog box shown in Figure 2.38. You are more likely to use Edit, Go To, a Go To item from the right-click menu, or one of the 11 buttons on the Browse toolbar.
Figure 2.38 : The Browse dialog box is a less-common way to browse your objects, functions, and variables.
Tools Close Browse Info File Whenever you rebuild your project, your browse file is rebuilt, too. If you rebuild your project outside Developer Studio with a tool like NMAKE, you should close the browse file first, using the menu choice, so that it can be updated.
Tools Profile Profilers in general are tools designed to help you find the proverbial 20% of the code where 80% of the execution time is spent. Profiling in general is an exercise in timing algorithms. Those algorithms where much time is consumed by the processor are candidates for algorithm optimization. Profiling is discussed in Chapter 29, "Power-User Features in De-veloper Studio."
Tools Remote Connection It is possible to run a program on one computer and debug it on another. As part of that process you use this menu item to connect the two computers. This is discussed in Chapter 20, "Debugging."
Tools Customize Choosing this option brings up the Customize dialog box. The Toolbars pane of that dialog box is shown in Figure 2.39 with the File buttons showing. The nine buttons correspond to items on the File menu, and if you would like one of those items on any toolbar, simply drag it from the dialog box to the appropriate place on the toolbar and release it. The list box on the left side of the Toolbar tab lets you choose other menus, each with a collection of toolbar buttons you can drag to any toolbar.Figure 2.39 : The Toolbar pane of the Customize dialog box lets you build you own toolbars.
The Tools tab lets you add programs to the Tools menu, and the Keyboard tab lets you change the keyboard shortcuts for commands, or add shortcuts for commands without them.
Tools Options This item gathers up a great number of settings and options that relate to Developer Studio itself. For example, Figure 2.40 shows the Editor tab of the Options dialog box. If there is a feature of Developer Studio you don't like, you can almost certainly change it within this large dialog box.Figure 2.40 : The Editor tab of the Options dialog box is where you change editor settings.
The tabs are as follows:
- Editor-Choose scroll bars, enable drag and drop, cover automatic saving and loading
- Tabs-Sets options related to tabs (inserted when you press the Tab key) and indents (inserted by the editor on new lines after language elements such as braces)
- Debug-Determines what information is displayed during debugging
- Compatibility-Lets you choose to emulate another editor (Brief or Epsilon) or just one portion of that editor's interface
- Directories-Sets directories in which to look for include, executable, library, and source files
- Workspace-Shown in Figure 2.41, sets docking windows, status bar, and project reloading
Figure 2.41 : The Workspace tab of the Options dialog box sets which views dock and which float as well as reload options.
- Format-Sets the color scheme, including syntax coloring, for source, InfoViewer, and other windows
- InfoViewer-Determines the behavior and appearance of InfoViewer
TIP If you are working on the same project all the time, check the Reload Last Project At Startup box on the Workspace tab of the Option dialog box. Then loading the Developer Studio and the last project is a one step process; simply loading the Developer Studio will load the last project too. If you work on a variety of different projects, uncheck this box so that Developer Studio comes up more quickly.
Tools Record Keystrokes (Ctrl+Q) Choose this menu item to record a sequence of keystrokes you want to enter into the file with focus a number of times. A small toolbar appears with Stop and Pause buttons.
Tools Playback Recording (Ctrl+Shift+Q) Choose this menu item to play the keystrokes recorded with Tools, Record Keystrokes. Keystrokes can only be played into the file they were recorded for.
The Window menu, shown in Figure 2.42, controls the windows in the main working area of Developer Studio.
Figure 2.42 : The Window menu controls the windows in the main working area.
The Window, Hide menu is a personal favorite for managing the well of information presented to the developer in the Developer Studio. The Window menu items in their entirety are:
Window New Window Choosing this item opens another window containing the same source file as the window with focus. The first window's title bar is changed, with :1 added after the file name; in the new window :2 is added after the file name. Changes made in one window are immediately reflected in the other. The windows can be scrolled, sized, and closed independently.
Window Split Choosing this window puts crosshairs over the file with focus; when you click the mouse, the window is split into four panes along the lines of these crosshairs. You can drag these boundaries about in the usual way if they are not in the right place. Scrolling one pane scrolls its companion pane as well, so that the views stay in sync. To unsplit a window, drag a boundary right to the edge of the window and it disappears. Drag away both the horizontal and vertical boundaries and the window is no longer split.
Window Hide (Shift+Esc) Enabled only when the Project Workspace, output, or other docked window has focus; this option hides the window.
Window Cascade This item arranges all the windows in the main working area in the familiar cascade pattern, like the one shown in figure 2.43. Minimized windows are not restored and cascaded.
Figure 2.43 : Arranging windows in a cascade makes it easy to switch between them.
Window Tile Horizontally This item arranges all the windows in the main working area so that each is the full width of the working area, as shown in figure 2.44. The file that had focus when you chose this item is at the top.
Figure 2.44 : When windows are tiled horizontally, each is the full width of the main working area.
Window Tile Vertically This item arranges all the windows in the main working area so that each is the full height of the working area, as shown in Figure 2.45. The file that had focus when you chose this item is at the left.
Figure 2.45 : When windows are tiled vertically, each is the full height of the main working area.
Window Close All Choosing this item closes all the windows in the main working area. If you have any unsaved changes, you are asked whether to save them or not.
Open Windows The bottom section of this menu lists the windows in the main working area so that you can move among them even when they are maximized. If there are more than nine open windows, only the first nine are listed. The rest can be reached by choosing Window, Windows.
Window Windows This item brings up the Windows dialog box, shown in Figure 2.46. From here you can close, save, or activate any window.
Figure 2.46 : The Windows dialog box allows access to any window in the main working area.
There are two Help systems for Developer Studio. One is InfoViewer, the other the standard Windows Help system. Clicking Help in most dialog boxes brings up the standard Help, but choosing items on this menu activates InfoViewer. The items are as follows:
Help Contents This item opens the Project Workspace window if it is hidden, switches to the InfoViewer tab, and displays the table of contents.
Help Search This item brings up the Search dialog box, which can be used as an index or for queries. With the Index tab, shown in Figure 2.47, you type all or part of an index term, and, as you type, the list of index terms scrolls. To open the InfoViewer topic, select a term, click List Books, then select a book from the lower list box and click Display.Figure 2.47 : The Index tab of the Search dialog box uses the index to find InfoViewer topics.
With the Query tab, shown in Figure 2.48, you enter one or more keywords, then submit the query. Results are gathered into a query results list like that shown in Figure 2.49. Double-click any topic to display it. The pushpin in the top-left corner holds this list open, or you can recall it at any time by choosing View, InfoViewer Query Results, as discussed earlier. There is a Search button on the Standard and InfoViewer toolbars.
Figure 2.49 : The Query results list shows the topics that match your query.
Help Keyboard This item does not involve InfoViewer. Choosing it brings up the Help Keyboard dialog box, shown in Figure 2.50. Use the drop-down box at the top to choose the commands for which you want to see keystrokes: Bound commands (those with keystrokes assigned), All commands, or commands from the File, Edit, View, Insert, Build, Debug, Tools, Window, or Help menus. Commands related to Images and Layout are also available.
Figure 2.50 : The Help Keyboard dialog box displays the keystrokes associated with commands.
Click the title bars across the top of the table to sort the display by that column. Keystrokes cannot be changed here; choose Tools, Customize and use the Keyboard tab to change keystrokes.
Help Use Extension Help Extension Help is when you add your own help files to Developer Studio, or use files supported by a third party. This menu item toggles its use.
Help Define Subset Searches through the entire InfoViewer text can be slow, and can produce too many false hits. You can restrict your use of InfoViewer to selected books within InfoViewer, called a subset. Choosing this item brings up the Define Subset dialog box, shown in Figure 2.51.
Figure 2.51 : The Define Subset dialog box is used to narrow the topics used within InfoViewer.
Help Set Default Subsets Once one or more subsets of InfoViewer have been defined, choose this item to set one of them to the default used in query and index searches and the table of contents display.
Help Tip of the Day Choosing this item brings up the Tip of the Day, like that in Figure 2.52. Some are Windows tips, others are specific to Developer Studio. If you can't wait to see a new tip each time you open Developer Studio, click Next Tip to scroll through the list. If you are annoyed by these tips on startup, uncheck the Show Tips At Startup box.
Figure 2.52 : The Tip of the Day is a great way to learn more about Developer Studio.
Help Technical Support If you think you need technical support, start here. Not only do you learn how to get that support, but you may find the answer to your question.
Help Web Favorites One of the ways Microsoft supplies information about Developer Studio and other products is through the World Wide Web. Choosing this item brings up a list of Web sites as shown in Figure 2.53 (you can remove entries or add your own). When you click Go To, Internet Explorer is launched to load the site. If you do not have Internet Explorer, you can configure another Web browser after clicking Go To.
Figure 2.53 : The Web Favorites dialog box makes it easy to view World Wide Web pages relevant to Visual C++.
Help About Developer Studio Choosing this item brings up the About box for Developer Studio, which includes, among other information, your Product ID.
After you are familiar with the sorts of actions you are likely to request of Developer Studio, the toolbars save you a lot of time. Instead of choosing File, Open, which takes two clicks and a mouse move, it is simpler to just click the Open button on the toolbar. There are, however, eight toolbars in this product, and that means a lot of little icons to learn. In this section, you will see each toolbar and which menu items the buttons correspond to.
Figure 2.54 shows all the toolbars that are available in Developer Studio and the Toolbars dialog box, which you use to set the toolbars that are displayed. You can turn ToolTips on or off here and set whether the tips include the shortcut keys for the command. Any of these toolbars can dock against any of the four edges of the working area, as shown in Figure 2.55.
Figure 2.54 : Developer Studio has eight toolbars, shown here, floating.
Figure 2.55 : Developer Studio toolbars can dock against any edge.
Each toolbar is discussed in turn in the sections that follow. For a full description of what each button does, refer to the section earlier in this chapter for the corresponding menu item.
Standard Toolbar The Standard Toolbar refers to those buttons in the toolbar area on the topmost row by default. These buttons help you maintain and edit text and files in your Workspace as opposed to the Project Toolbar which contains buttons related to compiling and debugging applications. Toolbars are much easier to use since the advent of fly-by hints, or DataTips. Table 2.2 names each Standard tool button and its equivalent menu operation.
Button Name | Menu Equivalent |
New Source File | File, New |
Open | File, Open |
Save | File, Save |
Save All | File, Save All |
Cut | Edit, Cut |
Copy | Edit, Copy |
Paste | Edit, Paste |
Undo | Edit, Undo |
Redo | Edit, Redo |
Find | Edit, Find |
Find Previous | Edit, Find |
Find in Files | File, Find in Files |
Search | Help, Search |
Class Wizard | View, ClassWizard |
Project Workspace | View, Project Workspace |
Project Toolbar The Project Toolbar is directly below the Standard Toolbar. The names of each of these toolbars are easily verifiable by placing the mouse cursor over the toolbar and pressing the right mouse button. The names for the Project Toolbar buttons, which are related to compiling and debugging, are defined in Table 2.3.
Button Name | Menu Equivalent |
Compile | Build, Compile |
Build | Build, Build |
Stop Build | Build, Stop Build |
Set Default Project Configuration | Build, Set Default Project Configuration |
Go | Build, Debug, Go |
Insert/Remove Breakpoint | Insert/Remove Breakpoint (Speed Menu) |
Remove All Breakpoints | (None) |
New Dialog | Insert, Resource |
New Menu | Insert, Resource |
New Cursor | Insert, Resource |
New Icon | Insert, Resource |
New Bitmap | Insert, Resource |
New Toolbar | Insert, Toolbar |
New Accelerator | Insert, Resource |
New String Table | Insert, Resource |
New Version | Insert, Resource |
Component Gallery | Insert, Component |
Using Other Toolbars The default configuration displays the Standard Toolbar and the Project Toolbar. There are several other toolbars which you can open. To access these toolbars place the mouse pointer over the toolbar area and press the right mouse button.
The names of the available toolbars are Resource, Edit, Debug, Browse, InfoViewer, and InfoViewer Contents. Checked toolbar names (by default Standard and Project) indicate visible bars. Each of these toolbars is worth investigating. When you display any of the toolbars, like all toolbars there are fly-by hints which tell you the name of the action the button performs. The toolbars are each customizable and perform an action found in the menus. As an exercise experiment with the toolbars and determine for yourself how much each might facilitate your development habits.
Chapter 2 completes our introduction to the revised Microsoft Developer Studio. Developed at Microsoft with developers in mind, this tool is highly configurable and offers a wealth of fit and finish management options.
In this chapter, you learned how to use the powerful menu features, customize toolbars, and how to find your way around the vast resources available. For more information on programming with the Microsoft Developer Studio refer to: