⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chxb.htm

📁 VC使用大全。里面集合了VC使用的各种使用技巧。非常有用。
💻 HTM
📖 第 1 页 / 共 5 页
字号:
displayed, right-click the menu bar and check Controls to display </I><I>it.) Each small icon on the palette represents a control (edit box, list </I><I>box, button, and so on) that can be inserted onto your dialog box. By </I><I>choosing 
</I><I><U>V</U></I><I>iew, </I><I><U>P</U></I><I>roperties, the Properties box shown in Figure B.6 is </I><I>displayed. Here the behavior of a control or of the whole dialog box can </I><I>be controlled.</I></P>

<blockquote><p><img src="tip.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/tip.gif">

<P>Click the pushpin at the top left of the Properties box to keep it displayed even when a different item is highlighted. The box displays the properties of each item you click.</P>

<p><img src="bottom.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/bottom.gif"></blockquote>

<P>This method of editing dialog boxes is one of the reasons for the name Visual C++. In this product, if you want a button to be a little lower on a dialog box, you click it with the mouse, drag it to the new position, and release the mouse button. 
Similarly, if you want the dialog box larger or smaller, grab a corner or edge and drag it to the new size just like any other sizable window. Before Visual C++ was released, the process would have involved coding and pixel counting, and taken many minutes 
rather than just a few seconds. This visual approach to dialog box building made Windows programming accessible to many more programmers.</P>

<A HREF="FFfig06.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig06.gif"><b>Fig. B.6</b></A>

<P><I>Dialog boxes get information from the user.</I></P>

<P><A ID="I8" NAME="I8"><B>Icons</B></A></P>

<P>Icons<I> are small bitmaps that represent your program or its documents. </I><I>For example, when a program is minimized, an icon is used to represent </I><I>it. A larger version of that icon is used to represent both the program </I><I>and its 
documents within an Explorer window. And when an MDI window is </I><I>minimized within your application, the minimized window is represented </I><I>by an icon. Figure B.7 shows the default icon provided by AppWizard for </I><I>minimized MDI windows. One of 
your first tasks after building any </I><I>application is to replace this with an icon that more clearly represents </I><I>the work your program performs.</I></P>

<P><I>An icon is a 32X32 pixel bitmap that can be edited with any number of </I><I>drawing tools, including the simple bitmap editor included in Developer </I><I>Studio. The interface is very similar to Microsoft Paint or Microsoft </I><I>Paintbrush in 
Zoom mode. You can draw one pixel at a time by clicking, </I><I>or freehand lines by clicking and dragging. You can work on the small or </I><I>zoomed versions of the icon and see the effects at once in both places.</I></P>

<A HREF="FFfig07.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig07.gif"><b>Fig. B.7</b></A>

<P><I>Icons represent your application and its documents.</I></P>

<P><A ID="I9" NAME="I9"><B>Menus</B></A></P>

<P>Menus<I> are the way that users tell your program what to do. </I><I>Keyboard </I><I>shortcuts</I> (accelerators) are linked to menu items, as are toolbar buttons. AppWizard creates the standard menus for a new application, and you edit those and 
create new ones in this view. Later, you'll use ClassWizard to connect menu items to functions within your code. Figure B.8 shows a menu displayed in the resource view. Choose <U>V</U>iew, Pr<U>o</U>perties to display the properties box for the menu item. 
Every menu item has the following three components:</P>

<ul>

<li> <I>Resource ID</I>. This uniquely identifies this menu item. Accelerators and toolbar buttons are linked to resource IDs. The convention is to build the ID from the menu choices that lead to the item. In Figure B.8, the resource ID is <font 
color="#008000">ID_FILE_OPEN</font>.</P>

<li> <I>Caption</I>. This is the text that appears for a menu choice. In Figure B.8, the caption is <font color="#008000">&amp;Open...\tCtrl+O</font>. The <font color="#008000">&amp;</font> means that the <font color="#008000">O</font> will appear 
underlined, and the menu item can be selected by typing <B><U>O</U></B><B> </B>when the menu is displayed. The <font color="#008000">\t</font> is a tab, and the <font color="#008000">Ctrl+O</font> is the accelerator for this menu item, as defined in Figure 
B.5.</P>

<li> <I>Prompt</I>. A prompt appears in the status bar when the highlight is on the menu item or the cursor is over the associated toolbar button. In Figure B.8, the prompt is <font color="#008000">Open an existing </font><font 
color="#008000">document\nOpen</font>. Only the portion before the newline (<font color="#008000">\n</font>) is displayed in the status bar. The second part of the prompt, <font color="#008000">Open</font>, is the text for the tool tip that appears if the 
user pauses the mouse over a toolbar button with this resource ID. All of this functionality is provided for you automatically by the framework of Visual C++ and MFC.</P>

</ul>

<A HREF="FFfig08.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig08.gif"><b>Fig. B.8</b></A>

<P><I>Menus are the way your application receives commands.</I></P>

<P><A ID="I10" NAME="I10"><B>The String Table</B></A></P>

<P>The <I>string table</I> is a list of strings within your application. Many strings, such as the static text on dialog boxes or the prompts for menu items, can be accessed in far simpler ways than through the string table, but some are reached only 
through it. For example, a default name or value can be kept in the string table, and changed without recompiling any code, though the resources will have to be compiled and the project linked. Each of these could be hard coded into the program, but then 
changes would require a full recompile. </P>

<P>Figure B.9 shows the string table for a sample application. To change a string, bring up the Properties dialog box and change the caption. Strings cannot be changed within the main working area.</P>

<A HREF="FFfig09.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig09.gif"><b>Fig. B.9</b></A>

<P><I>The string table stores all the prompts and text in your application.</I></P>

<P><A ID="I11" NAME="I11"><B>Toolbars</B></A></P>

<P>Toolbars<I> are the lines of small buttons typically located directly </I><I>underneath the menus of an application. Each button is linked to a menu </I><I>item, and its appearance depends on the state of the menu item. If a </I><I>menu item is grayed, 
the corresponding toolbar button is grayed as well. </I><I>If a menu item is checked, the corresponding toolbar button is typically </I><I>drawn as a pushed-in button. In this way, toolbar buttons serve as </I><I>indicators as well as mechanisms for giving 
commands to the application.</I></P>

<P><I>A toolbar button has two parts: a bitmap of the button and a resource </I><I>ID. When a user clicks the button, it is just as though the menu item </I><I>with the same resource ID was chosen. Figure B.10 shows a typical </I><I>toolbar and the 
properties of the </I><I><U>F</U></I><I>ile, </I><I><U>O</U></I><I>pen button on that toolbar. In </I><I>this view, you can change the resource ID of any button, and edit the </I><I>bitmap with the same tools used to edit icons.</I></P>

<A HREF="FFfig10.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig10.gif"><b>Fig. B.10</b></A>

<P><I>Toolbar buttons are associated with menu items through a resource ID.</I></P>

<P><A ID="I12" NAME="I12"><B>Version Information</B></A></P>

<P>Good installation programs use the version information resource when installing your application on a user's machine. For example, if a user is installing an application that has already been installed, the installation program may not have to copy as 
many files. It may alert the user if an old version is being installed over a new version, and so on.</P>

<P>When you create an application with AppWizard, version information like that in Figure B.11 is generated for you automatically. Before attempting to change any of it, make sure you understand how installation programs use it.</P>

<A HREF="FFfig11.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig11.gif"><b>Fig. B.11</b></A>

<P><I>Version information is used by install programs.</I></P>

<H3><A ID="I13" NAME="I13"><B>Looking at Your Code, Arranged by Class</B></A></H3>

<P>The ClassView shows the classes in your application. Under each class, the member variables and functions are shown, as demonstrated in Figure B.12. Member functions are shown first with a purple icon next to them, followed by member variables with a 
turquoise icon. Protected members have a key next to the icon, while private members have a padlock.</P>

<A HREF="FFfig12.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig12.gif"><b>Fig. B.12</b></A>

<P><I>The ClassView shows the functions and variables in each class in your application.</I></P>

<P>Double-clicking a function name brings up the source for that function in the main working area, as shown in Figure B.12. Double-clicking a variable name brings up the header file in which the variable is declared.</P>

<P>Right-clicking a class name brings up a shortcut menu, shown in Figure B.13, with these items:</P>

<A HREF="FFfig13.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig13.gif"><b>Fig. B.13</b></A>

<P><I>Common commands related to classes are on the ClassView shorcut menu for a class.</I></P>

<ul>

<li> <I><U>G</U></I><I>o to Definition</I>. Opens the header (.h) file at the definition of this class.</P>

<li> <I>Add </I><I><U>M</U></I><I>ember Function</I>. Opens the Add Member Function dialog box shown in Figure B.14. This adds a declaration of the function to the header file, and the stub of a definition to the source file.</P>

</ul>

<A HREF="FFfig14.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig14.gif"><b>Fig. B.14</b></A>

<P><I>Never again forget to add part of a function declaration or definition when you use the Add Member </I><I>Function shortcut.</I></P>

<ul>

<li> <I>Add Member </I><I><U>V</U></I><I>ariable</I>. Opens the Add Member Variable dialog box shown in Figure B.15. This adds a declaration of the variable to the header file.</P>

</ul>

<A HREF="FFfig15.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig15.gif"><b>Fig. B.15</b></A>

<P><I>Simplify adding member variables with this shortcut.</I></P>

<ul>

<li> <I>Add Virtual </I><I><U>F</U></I><I>unction</I>. Opens the New Virtual Override dialog, discussed in <A HREF="index04.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index04.htm" target="text">Chapter 4</A>, &#147;Messages and Commands.&#148;</P>

<li> <I>Add Windows Message </I><I><U>H</U></I><I>andler</I>. Opens the New Windows Message Handler dialog box, discussed in <A HREF="index04.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index04.htm" target="text">Chapter 4</A>, &#147;Messages and Commands.&#148;</P>

<li> <I>R</I><I><U>e</U></I><I>ferences</I>. Brings up a list of the places where the class name is mentioned within your application. Typically the class name occurs in declarations of instances of the class, but this will also find places where the 
class name is passed as a parameter to a function or macro.</P>

<li> <I>Der</I><I><U>i</U></I><I>ved Classes</I>. Brings up a list of all the member functions and member variables of this class, a list of other classes that use this class as a base class, and the references information.</P>

<li><I> </I><I><U>B</U></I><I>ase Classes</I>. Brings up a list of all the member functions and member variables of this class, a list of the base classes of this class, and the references information.</P>

<li> <I>Add to Galler</I><I><U>y</U></I>. Adds this class to the Component Gallery, discussed in <A HREF="index25.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/index25.htm" target="text">Chapter 25</A>, &#147;Achieving Reuse with the Gallery and your own AppWizards.&#148;</P>

<li> <I>Ne</I><I><U>w</U></I><I> Folder</I>. Creates a folder you can drag classes into. This helps to organize projects with large numbers of classes.</P>

<li> <I>Group by A</I><I><U>c</U></I><I>cess</I>. Rearranges the order of the list. By default, functions are listed in alphabetical order, followed by data members in alphabetical order. With this option toggled on, functions come first (public, then 
protected, then private functions, alphabetically in each section) followed by data members (again public, then protected, then private data members, alphabetically in each section).</P>

<li> <I>Docking View</I>. Keeps the project workspace window docked at the side of the main working area.</P>

<li> <I><U>H</U></I><I>ide</I>. Hides the project workspace window. To redisplay it, choose <U>V</U>iew, Wor<U>k</U>space.</P>

<li> <I>Properties</I>. Displays the properties of the class (name, base class).</P>

</ul>

<blockquote><p><img src="tip.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/tip.gif">

<P>Menu items that appear on a toolbar have their toolbar icon next to them on the menu. Make note of the icon; the next time you want to choose that item, perhaps you can use a toolbar instead.</P>

<p><img src="bottom.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/bottom.gif"></blockquote>

<P>Right-clicking the name of a member function brings up a substantial shortcut menu, with the following menu items:</P>

<ul>

<li> <I><U>G</U></I><I>o To Definition</I>. Opens the source (.cpp) file at the code for this function.</P>

<li> <I>Go To Dec</I><I><U>l</U></I><I>aration</I>. Opens the header (.h) file at the declaration of this function.</P>

<li> <I>Set </I><I><U>B</U></I><I>reakpoint</I>. Sets a breakpoint. Breakpoints are discussed in <A HREF="indexc.htm" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/indexc.htm" target="text">Reference C</A>, &quot;Debugging.&quot;</P>

<li> <I>R</I><I><U>e</U></I><I>ferences</I>. Brings up a list of the places where the function is called within your application.</P>

<li> <I>Ca</I><I><U>l</U></I><I>ls</I>. Displays a collapsible and expandable outline of all the functions that this function calls. Figure B.16 shows a sample Call Graph window.</P>

</ul>

<A HREF="FFfig16.gif" tppabs="http://www.mcp.com/814147200/0-7897/0-7897-1145-1/figs/chxb/FFfig16.gif"><b>Fig. B.16</b></A>

<P><I>The Call Graph window lists all the functions that your function calls, and all the functions they call, and so </I><I>on.</I></P>

<ul>

<li> <I>Called By</I>. Displays a Callers Graph listing the functions this function is called by.</P>

<li> <I>Ne</I><I><U>w</U></I><I> Folder</I>. Creates a folder you can drag classes into. This helps to organize projects with large numbers of classes.</P>

<li> <I>Group by Access</I>. Rearranges the order of the list. By default, functions are listed in alphabetical order, followed by data members in alphabetical order. With this option toggled on, functions come first (public, then protected, then private 
functions, alphabetically in each section) followed by data members (again public, then protected, then private data members, alphabetically in each section).</P>

<li> <I>Docking View</I>. Keeps the project workspace window docked at the side of the main working area.</P>

<li> <I>Hide</I>. Hides the project workspace window. To redisplay it, choose <U>V</U>iew, <U>P</U>roject Workspace.</P>

<li> <I>Properties</I>. Displays the properties of the function (name, return type, parameters).</P>

</ul>

<P>Right-clicking the name of a member variable brings up a shortcut menu with less menu items. The items are as follows:</P>

<ul>

<li> <I><U>G</U></I><I>o To Definition</I>. Opens the header (.h) file at the declaration of this variable.</P>

<li> <I>R</I><I><U>e</U></I><I>ferences</I>. Brings up a list of the places where the variable is used within your application.</P>

<li> <I>Ne</I><I><U>w</U></I><I> Folder</I>. Creates a folder you can drag classes into. This helps to organize projects with large numbers of classes.</P>

<li> <I>Group by Access</I>. Rearranges the order of the list. By default, functions are listed in alphabetical order, followed by data members in alphabetical order. With this option toggled on, functions come first (public, then protected, then private 
functions, alphabetically in each section) followed by data members (again public, then protected, then private data members, alphabetically in each section).</P>

<li> <I>Docking View</I>. Keeps the project workspace window docked at the side of the main working area.</P>

<li> <I>Hide</I>. Hides the project workspace window. To redisplay it, choose <U>V</U>iew, <U>P</U>roject Workspace.</P>

<li> <I>Properties</I>. Displays the properties of the variable (name and type).</P>

</ul>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -