📄 ch11.htm
字号:
AdjustWindowRectEx BeginPaint CallNextHookEx</PRE><H2><A NAME="Heading18"></A>CallWindowProcA</H2><PRE> CharLowerA... (more DLL imports) ... </PRE><P>Typically you run TDUMP from the command line. Because the output from TDUMP isusually long, you are better off if you redirect the output to a text file. The followingillustrates this:</P><P><PRE>tdump MyApp.exe > dump.txt</PRE><P>Now you have an ASCII text file that you can browse with the Delphi Code Editoror any other text editor. Although you might not use TDUMP often, it can be invaluablewhen you need it.</P><BLOCKQUOTE> <P><HR><strong>NOTE:</strong> TDUMP is mostly used for obtaining a list of exported functions and procedures in a DLL. <HR></BLOCKQUOTE><H2><A NAME="Heading19"></A>The Package Collection Editor</H2><P>The Package Collection Editor provides a way of deploying several packages thatare meant to work together. To invoke the Package Collection Editor, choose Tools|PackageCollection Editor from the main menu. The Package Collection Editor has a help menuthat explains more about how to use it.</P><P>This tool is primarily meant for component vendors who ship several packages together.The Package Collection Editor has undergone some change in Delphi 4 and is thereforemore useful than it was in Delphi 3. You'll have to experiment with this tool tosee if it is something that you can use. Still, you might find that it is not robustenough to be used in heavy-duty commercial component deployment.</P><P><H2><A NAME="Heading20"></A>Configuring the Delphi Tools Menu</H2><P>The Delphi Tools menu is configurable. By default, the Delphi Tools menu has itemsfor Database Desktop and Image Editor. You can add your own tools to the Tools menu,add other Delphi tools, or add any other program you use frequently. You can alsochange the order of items on the Tools menu or even delete items.</P><P><H3><A NAME="Heading21"></A>Using the Configure Tools Dialog Box</H3><P>Just about any application you use frequently can be added to the Tools menu.By adding items to the Tools menu, you can quickly load any program you frequentlyuse during program development. Adding a tool to the Tools menu is a trivial taskand takes only a few minutes. Adding, deleting, and moving items on the Tools menuis accomplished through the Tool Options dialog box. To display the Tool Optionsdialog box, choose Tools|Configure Tools from the main menu (see Figure 11.11).</P><P><A HREF="javascript:popUp('28671111.gif')"><B>FIGURE 11.11.</B></A><B> </B><I>TheTool Options dialog box.</I></P><P>The list box labeled Tools shows the tools that currently appear on the Toolsmenu. The tools are listed in the order in which they appear on the Tools menu. Toreorder the list of tools, click the tool you want to move and click either the upor down arrow button. To remove a tool from the Tools menu, select the tool fromthe list box and click the Delete button. The tool will be removed from the menu.</P><P><H3><A NAME="Heading22"></A>Adding Tools to the Menu</H3><P>To add a tool to the Tools menu, click the Add button. The Tool Properties dialogbox is displayed, and you can enter the properties for the tool you are adding. TheTool Properties dialog box is shown in Figure 11.12 with the properties for WindowsExplorer displayed.</P><P><A HREF="javascript:popUp('28671112.gif')"><B>FIGURE 11.12.</B></A><B> </B><I>TheTool Properties dialog box.</I></P><P>The Title field is where you type the tool's title as you want it to appear onthe Tools menu. You can use an ampersand to indicate the shortcut key character.The Program field is where you enter the tool's path and filename. To ensure findingthe program, you should enter the program's full path. If you don't know the exactpath and filename, you can click the Browse button and go hunting for the file. TheWorking dir field is used to set the working directory for the tool. If you browseto find the tool, the working directory will be automatically set to the directorywhere the program resides.</P><P>The Parameters field requires some explanation. In its simplest form, this fieldis used to set the tool's command-line parameters. Type any parameters needed torun the tool. You can, however, use Delphi's predefined macros in the Parametersfield. If you click the Macros button in the Tool Properties dialog box, you geta list of macros from which you can choose.</P><P>To use a macro, you can type it in directly or you can choose it from the listand click the Insert button. Figure 11.13 shows the Tool Properties dialog box withthe list of macros displayed.</P><P><A HREF="javascript:popUp('28671113.gif')"><B>FIGURE 11.13.</B></A><B> </B><I>TheTool Properties dialog box showing macros.</I></P><P>The $EXENAME macro will return the full path of the project's target executable.For example, if you have a project named MyApp in a directory called Projects, the$EXENAME parameter will pass the string c:\Projects\MyApp.exe to the program. Somemacros require parameters. To use only the path from your project's target withoutthe filename, you would specify a parameters string of $PATH($EXENAME). Continuingwith this example, that combination of parameters would yield c:\Projects\. For acomplete list of the macros available, see the Delphi online help.</P><P><BR><B>Editing Tools on the Menu</B></P><P><B><BR></B>Editing a tool on the Tools menu is as easy as clicking the Edit button on theTool Options dialog box. The Tool Properties dialog box is displayed, and you canchange any of the fields as necessary.</P><P>When you are done adding, editing, or rearranging your tools, click the Closebutton. The Delphi Tools menu will reflect your changes.</P><P><H2><A NAME="Heading23"></A>Setting the Environment Options</H2><P>The Delphi Environment Options enable you to make changes to the Delphi IDE atthe global level. (The Project Options dialog box controls settings at the projectlevel.) To display the Environment Options dialog box, choose Tools|Environment Optionsfrom the main menu. This is a tabbed dialog box with nine pages. You learned aboutthe Editor, Display, Color, Code Insight, and Explorer pages when you looked at theCode Editor and Code Explorer on Day 9. You'll look at the Preferences, Library,and Palette pages now.</P><BLOCKQUOTE> <P><HR><strong>NOTE:</strong> The Environment Options dialog box also contains a page for the Browser settings. This requires more explanation than I can provide in this chapter, so I won't attempt to cover the Browser or the Browser options.<HR></BLOCKQUOTE><H3><A NAME="Heading24"></A>The Preferences Page</H3><P>The Preferences page of the Environment Options dialog box is where you set generalDelphi preferences: how the Delphi IDE controls compiling, autosaving, and the appearanceof the Form Designer. You can also set the Form Designer preferences on this page(see Figure 11.14).</P><P><A HREF="javascript:popUp('28671114.gif')"><B>FIGURE 11.14.</B></A><B> </B><I>ThePreferences page of the Environment Options dialog box.</I></P><P>The Desktop contents section determines how much of the desktop layout Delphiwill save when the project is saved.</P><P>The Autosave options section enables you to specify that either the Editor filesor the Desktop be saved automatically every time the program is run. Personally,I do not like to have my editor files saved automatically; I want the ability toabandon current edits if necessary. Still, I know others who really like this featureand wouldn't program without it.</P><P>For one, if your application misbehaves and crashes the Delphi IDE or Windows,you know that your last edits have been saved. The Desktop option saves the currentsize and position of the Code Editor, all forms, the Alignment palette, the ObjectInspector, and so on.</P><P>For the most part, the Form Designer section is self-explanatory. The Displaygrid option turns the visible grid in the Form Designer on and off. This affectsonly the grid's visible display, not whether objects snap to the grid. The Snap togrid option determines whether components placed and moved will snap to the gridpoints. The X and Y grid size fields enable you to set the size of the grid. By default,it is set at eight pixels. The Show component captions option pertains to nonvisualcomponents placed on your forms. When this option is on, the Form Designer displaysthe Name property of nonvisual components below the icon representing the component.</P><P>The Compiling and Running section has four options as follows:</P><P><UL> <LI>The Show compiler progress option controls whether Delphi displays the compiler progress dialog box when compiling projects. Most of the time you will leave this option off because Delphi compiles your programs so quickly you really don't need to watch the progress. <P> <LI>The Warn on package rebuild option warns you before you rebuild a package that is currently loaded in the Component Palette. <P> <LI>The Hide designers on run option hides the Form Designer, Object Inspector, and other Form Designer support windows when the program is run. The Delphi main window and Code Editor are still visible, however. <P> <LI>The Minimize on run option is similar to Hide designers on run. When this option is on, the entire Delphi IDE minimizes whenever the target program is run from the IDE.</UL><BLOCKQUOTE> <P><HR><strong>NOTE:</strong> When the Minimize on run option is on, any action in the program that requires the debugger (exceptions, breakpoints, and so on) results in the Delphi IDE being displayed again. <HR></BLOCKQUOTE><P>The Shared Repository section enables you to specify where the Object Repositoryinformation is saved by specifying the appropriate path in the Directory edit box.This can be very helpful in the case of repository items being used by a group ofpeople working on the same project. You can set the Shared Repository's Directoryto point to a place on the network, and all the items that you add to the ObjectRepository will be saved to the location on the network and can be inherited fromby the other group members.</P><P><H3><A NAME="Heading25"></A>The Library Page</H3><P>The Library page of the Environment Options dialog box has just three fields.The Library Path field is used to specify the path to the library files that Delphiuses for the Component Palette. Normally you don't have to change this path. TheBPL output directory and DCP output directory fields are used to specify directoriesin which package output files will be placed. For example, you might opt to haveyour packages (.bpl files) created in your Windows\System or Winnt\System32 directory(package files need to be on the system path).</P><P><H3><A NAME="Heading26"></A>The Palette Page</H3><P>The Palette page of the Environment Options dialog box enables you to customizethe Component Palette (see Figure 11.15).</P><P><A HREF="javascript:popUp('28671115.gif')"><B>FIGURE 11.15.</B></A><B> </B><I>ThePalette page of the Environment Options dialog box.</I></P><P>This page enables you to change the order in which the pages appear in the ComponentPalette. The Pages list box on the left side of the dialog box shows all the pagescurrently in the Component Palette. Note that depending on the version of Delphiyou own, the palette pages you see listed might differ from those shown in Figure11.15. (The Midas tab, for example, is only available for the Client/Server versionof Delphi.) At the bottom of the list you will see an item labeled [All]. This itemshows all the installed components in all pages of the Component Palette. The Componentslist box shows the components appearing in the page that is selected in the Pageslist box.</P><P>To reorder the pages, drag a page within the Pages list box to the position youwant it to occupy in the Component Palette. If you want the Samples page to appearfirst on the Component Palette, you can drag it to the top of the list in the Pageslist box and drop it. You can also click on a page and use the Move Up or Move Downbuttons to move the page to a new location.</P><P>Pages can be added, deleted, or renamed, and those operations work exactly asyou would expect. To add a page, click the Add button. You will be prompted for aname for the page. After you supply the page name, the new page is created. You mightadd a page, for example, if you have created your own components and want them ontheir own page in the Component Palette. You can also take any of the VCL componentsthat you use a lot and move them to a new page so that you can get to them quickly.</P><BLOCKQUOTE> <P><HR><strong>TIP:</strong> You can move components from page to page, but you cannot copy components from one page to another. You can, however, add any installed component to any page on the Component Palette. First select [All] in the Pages list box. Then drag a component from the Components list box to any of the pages in the Pages list box. <HR></BLOCKQUOTE><P>Deleting and renaming pages is straightforward. As with the Object Repository,you delete a page only after it has been emptied of its components.</P><P>Components on a page can be rearranged just as pages can. To move a component,drag it to its new position in the Components list box or use the Move Up or MoveDown buttons. To move a component to a new page, drag and drop it on the name ofthe page in the Pages list box where you want it to appear. To delete a component,first select the component and then click the Delete button.</P><P><H2><A NAME="Heading27"></A>Summary</H2><P>So now you know more about the tools included as part of the Delphi suite. Someof these tools are easy to miss, so it helps to have an overview of what is availableto you. Some tools you might not use right away, but in the future you can take anotherlook at what's available to you. I ended the day by going over the Environment Optionsdialog box. For the most part, you can leave these settings on their defaults. Whenyou begin customizing the IDE, you will have a better understanding of what the individualoptions do.</P><P><B>Workshop</B></P><P>The Workshop contains quiz questions to help you solidify your understanding ofthe material covered and exercises to provide you with experience in using what youhave learned. You can find answers to the quiz questions in Appendix A, "Answersto the Quiz Questions."</P><P><H3><A NAME="Heading28"></A>Q&A</H3><DL> <DT></DT> <DD><B>Q I'm creating an icon and trying to get an ellipse with a black border and a yellow fill. I set the foreground color to black and the background color to yellow, but all I get is a black circle. What do I have to do to get what I want?</B> <P> <DT><B></B></DT> <DD><B>A</B> The Image Editor works differently than some bitmap editors in this regard. To accomplish what you're after, you have to first draw a black, hollow ellipse
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -