Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 97 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
97
Dung lượng
1,26 MB
Nội dung
462 1001 Things You Always Wanted to Know About Visual FoxPro executed directly. It can be called from another VFP executable that is already running within the run time environment. The Win32 executable / COM server (.exe) build option performs all the actions that are done for the application executable. Then the app file goes through a metamorphic process that adds the needed boot code to make it a Windows executable that calls the needed run- time DLL files, adds the icon and the .exe version information. The executable generated will require the VFP run-time files (Vfp6r.dll and Vfp6rXXX.dll (XXX denotes the specific language version)) to run outside of the VFP development environment. A Type Library file is generated if there are OLE Public classes in the project. The single-threaded COM server (.DLL) build option and the multi-threaded COM server (.DLL) options build full COM objects and the needed Type Library (.TLB) files after going through the rebuild process. The Type Library file is generated in the same directory as the DLL. These projects also need to have classes marked as OLE Public. The multi-threaded DLL requires a special run-time file called VFP6T.DLL. All servers that are built are added to the Server page of the Project Information dialog. How to use the project options to your advantage The Project Information dialog presents developers with key details about the project and the files that are part of the project. The first page is the Project tab. This form allows the developer to enter in their address information. This information is stored in generated code for menus. Other than that, it is only documentation for the project. Back in the 2.x days, the project information was also stored in the generated screen code. More importantly, this page gives developers access to key settings for the build process. How do you use a project’s Debug Info setting? The Debug Info setting is critical in two situations. The first is when debugging an application and tracing through code. If the code was not compiled with the Debug Info on (checked), then you get a "Source is out of date" message in the Trace Window. This can be truly aggravating when you are ten levels deep in the call stack and you hit a program that was compiled without the debug code. We hate when that happens! It is critical to note that a file is not compiled unless the Recompile All is checked when doing the build or the file was modified since the last build. Checking on the Debug Code option does not guarantee that all files will have source compiled in. The only time is when the Rebuild All is marked. The second situation that is critical is when you are building the final shipping version of the application. There is a significant difference in executable size between the Debug Code being checked on and off. We recommend checking this option off when building the code to be shipped with the release. The size could be more than 10 times bigger with code included. We had one case of an .exe being 50 megabytes with source code included for debugging and just over 4 megabytes without it. Sending code with Debug Code set on ships the source code in the executable. This is how the Trace Window can display each line being executed. Note that the customer or another developer will have access to this code if it is shipped to the production arena. Chapter 14: Project Management 463 How do you use a project’s Encrypted setting? This brings us to the Encrypted setting. Don’t you just love how this all flows together? The Encrypted setting causes the generated executable to be encrypted so other developers cannot get access to the source code inside of the executable. It is pretty useless in the author’s mind since there are third party tools that will decompile an executable. Naturally, these third party tools allow you to stamp a key so another copy of the product cannot decompile it. This is rather like blackmailing you to buy the product isn’t it? On the other hand, the tool has some excellent use when someone loses the source code or the original developer skips town so it might be worth buying. Encrypted executables also cannot be compressed when zipped up based on the encryption scheme used internally. This author would love if Microsoft would allow the developer to enter a key when encrypting the executable to circumvent third-party tools and truly make it a valuable setting. The Last Built text box displays the date and time the last build was completed – a useful reminder of when you last compiled the application. The projecthook setting is tackled in Chapter 15, Project Objects and ProjectHooks. How do you set a custom icon for an executable? This is a two-step process. The first is to assign the _screen.Icon property to the icon file in the main start up program. The second is to use the Project Information dialog to attach the icon to the project. What happens during the project build with this icon? Well, it is physically stored into the executable. This gives Windows the ability to display your custom application icon instead of the cute fox icon. We say the cute icon, since we actually had a customer once note that they did not want us to replace the "cute" foxhead with some other icon for their application <g>. The icon file (.ico) can store multiple copies of the icon image. Each of these images is a different resolution. It is important to edit both images since Windows uses a 16 x 16 pixel image for application windows and the 32 x 32 pixel image for displaying a larger view in applications like Windows Explorer. We recommend getting one of the icon editing tools so you can either create your own icons or modify icons that you purchase. It is very important to use an icon editor that can edit both images. We use the Microsoft Imagedit.exe applet that shipped with VFP 5.0. When an icon is opened you are typically asked which of the images you want to edit. You should be able to select either the EGA/VGA 16 Color image (32x32) or the Small Icon 16 Color image (16x16). If one of the images is missing from the icon file, we do a "select all" on the image that does exist, and copy it to the clipboard. We open up the other image in the icon file and paste the clipboard contents to the image editor. The second image will either be expanded or shrunk. We like the automatic adjustment option that ImageEdit provides when expanding or shrinking the graphic to fit the new size. The proper use of icons can polish up an application and give it a more professional appearance. One of the easiest ways to build up a good collection of icons is to purchase several third-party image/icon CD-ROMs. There is plenty of useless icons on these CDs, but 464 1001 Things You Always Wanted to Know About Visual FoxPro one good icon is easily worth the price of the entire CD when you consider how much time you can spend creating your own. How do you manage files in the Project Manager? The Project Information Files tab allows you to sort via the ListView that contains the list of files. This means that developers can sort the list of files by the file type, the file name, last modified, whether it is included and the code page. Double-clicking on the "headers" will cause the column to be sorted. This dialog also allows you to toggle if the file is included or excluded from the application or executable builds. The included files show an "X" and the excluded files display an empty box. If the box is gray filled, that indicates the main file for the project. Files that maintain a code page can also be updated to the native code page. This is important for developers building applications that run outside of their native language and/or code pages. How do you manage Servers from the Project Manager? The Project Information Servers tab lists the classes in the project, both in Visual Class Libraries and program files (via DEFINE CLASS code) that are marked OLEPublic. Each class that is available as a server is listed in the list box on the left side of the page. As you scroll down the list, the Class Name, Class Library, description, help file, and help context id change for that specific class. Settings can be made to indicate if the Automation Server is single- threaded, multi-threaded, or cannot be created at all through the Instancing option. This is an important setting from a performance perspective. Single-threaded servers need an instance for each and every reference to the class. Only one process can be called at a time to that instance. This was a problem prior to Service Pack 3 when two processes needed to access separate methods in a server as only one could be handled at a time. If this is a performance issue, the multi-threaded server can step in and handle both calls with one instance. Type Library information is also displayed on this dialog. How do you set the project’s object description? Creating technical documentation has always been a low priority for most developers we know. It is not one of the fun things we do in our job. Each file that is tracked in the project has an optional description that can be filled in. This particular feature of the Project Manager is very useful in a team environment so all developers can understand what the file accomplishes or which features it supports. It can also be helpful in one-person shops to remind the developer what the purpose of the file is. The description can be accessed via the Project Manager’s shortcut menu (right-click menu) or the main menu Project|Edit Description option. This option displays the Edit Description dialog (see Figure 14.1). Enter in the text that describes the file and save it by pressing the OK button. Naturally, pressing the Cancel button will revert the changes you just typed in. Chapter 14: Project Management 465 Figure 14.1 Using the file description to describe the file’s purpose in the application can help you and your teammates understand what it is for without opening the file up. Several files retain the description inside the file source code metadata, others are saved in the project’s metadata. The descriptions entered in the Project Manager are retained in the class definitions (not the same for class libraries), databases, contained tables and the view definitions. If the descriptions are added/changed via the Class, Database, Table, or View Designer, they are stored in the source metadata and displayed in the Project Manager. The rest of the descriptions are stored directly in the project file. This is important to know if you ever have a project file corrupted. (Yes it does happen, although less frequently than in the 2.x days.) If you do not keep solid backups of the project files and have one corrupted, you will lose the descriptions during the rebuild of a new project. How to set the executable version information The Visual FoxPro 6.0 Project Manager stores the latest version information that is set up through the Build Dialog (see Figure 14.2). This information is used by the build process and stored in the resulting executable (.EXE). It should be noted that it is not stored in the application (.APP) file if that is the type of executable you generate. 466 1001 Things You Always Wanted to Know About Visual FoxPro Figure 14.2 Using the Build Options dialog to get the Version dialog, VFP developers can store information directly into the resulting executable. Some of this information can be seen in tools like Windows Explorer. This version information can be extracted via the new native function AFILEVERSION . If for some reason you are using VFP 5.0, you will need to use the GetFileVersion function that is available in FoxTools.fll. There are some differences in the calling of the functions and the information in the array of each function, so if you use VFP 5.0, consult the Help file. In VFP 6, AFILEVERSION function returns a zero if the file specified in the second parameter is not found. If the file is found, the array is created with 15 elements. Table 14.1 contains the information that would be seen by executing a LIST MEMO in the Command Window: ?AGETFILEVERSION(laEXEDetails, "Sample01.exe") Chapter 14: Project Management 467 Table 14.1 – Sample output from AGETFILEVERSION of the Sample01.exe Array Position Contents Sample Values 1 Comment "Developed for 1001 Things You Wanted to Know About VFP" 2 Company Name "Kirtland Associates" 3 File Description "Cool Application" 4 File Version "1.0.1" 5 Internal Name "sample01" 6 Legal Copyright "January 2000" 7 Legal Trademark "Sample Trademark" 8 Original File Name "sample01.exe" 9 Private Build "" 10 Product Name "Sample.exe" 11 Product Version "1.0.1" 12 Special Build "" 13 OLE Self Registration "" 14 Language "English (United States)" 15 Translation Code "040904e4" The AFILEVERSION function can be used to determine the version details in more than just VFP executables; it can also be used to get version specifics on other Windows executables. Therefore if you run the following code, you will get 9.0.2719 echoed to the screen for the initial version of Excel 2000: AGETFILEVERSION(laEXEDetails, ; "C:\Program Files\Microsoft Office\Office\EXCEL.EXE") ?laExeDetails[4] So what is the use of this feature? We use it to display the version information in both our standard splash screen and on the application’s About window. What are the advantages of including the Config.fpw in the project? The Config.fpw file allows Visual FoxPro developers control over the VFP environment settings. Adding the file to the project allows for easy editing of the settings for the application. Marking it included in the project will incorporate the configuration into the executable. VFP automatically uses this file to make any configuration changes as the application is starting. If the file is not marked as included in the project, it needs to be distributed separately with the executable. This is a sample Config.fpw file that can be included in the project. The settings inside this file would cause VFP to start up without the main screen being displayed and the FoxUser file in the system directory under the application root directory to be used as the apps resource file: 468 1001 Things You Always Wanted to Know About Visual FoxPro * Application starts with VFP Frame off screen = off resource = system\foxuser.dbf Including the file in the executable will eliminate the need for the install process having to load a configuration file and then assigning it through the usual mechanisms. In the past we might have included to a –c parameter on the command line within a shortcut for the application. If the user double-clicked on the executable in Windows Explorer, the settings were never made because the configuration file was never loaded. The other mechanism is the FOXPROWCFG DOS environment variable, but this forces the support staff or the user to make sure this is set up on each machine that the executable is run on. The other disadvantage of using the DOS environment setting is that it is the default configuration file for all loaded VFP applications. We like to have more control for each application, thus assigning a specific configuration file for each released system. How can we include non-VFP objects in the project? VFP developers are familiar with the different file types that are tracked in a standard VFP project like forms, reports, labels, visual class libraries, programs, APIs, applications, menus, text files, databases, and free tables. Did you know that you could include files from your favorite word processor, spreadsheet, graphics package or other application? There are several non-VFP files we like to include in the project manager for all applications we develop. If you have the Project Manager configured to open the file when double-clicked, it works just like Windows Explorer and will fire up the associated program and open the file. We like to include these non-VFP file types in the Other Files category in the Project Manager since it shows the file extension. One of the issues with this technique is the default file type for this category is a bitmap (.bmp;.msk) and the rest of the file types in the list are graphical. You need to select the "All Files" option and pick the file you want added to the project. Chapter 14: Project Management 469 Figure 14.3 Project Manager with non-VFP files included in the project There are a couple of noteworthy items to mention with this functionality. If you do not exclude these files, they will be built into the executable generated during the build process. They are included by default when you add them in. This can be beneficial if you want them shipped with the end product and do not want to send them as a separate file. The negative side of the coin is that these files will add the full byte size of the file to your executable. These bloated files can lead to slower loading executables and the need for more memory to run the application. The first of the files we like to have as part of the project is a ReadMe.txt file. This file includes any details that the development staff needs to include for the users to read after they load the latest revision of the application. This file has a list of new features, bug fixes, and outstanding issues for the version we are releasing. This gives the user base a starting point to understand what they need to review and the development staff a way to track a history of what was worked on for the release and what still needs to be completed before we ship. The second type of file we typically include are word processing files. There are several documents used for project management and development within the life cycle of a project. These include proposals, functional specifications, change control orders, priority listings and OLE Automation documents. Adding these files to a project can save the time required to find the directory within the word processor each time one of these documents needs to be 470 1001 Things You Always Wanted to Know About Visual FoxPro modified. It would also be prudent to mention that these files should be closely managed outside of the project as well, since they are important to the success of the project. Help files can be included whether they are the older HLP format or the newer compiled HTML format (CHM). This gives the project developers access to the generated Help file without firing up the application. HTML files can be modified using the native VFP editor, but there are better tools that modify this file type. If you have the HTM extension assigned to a tool like FrontPage or Hot Metal, or defaulting to a browser like Netscape Navigator or Internet Explorer, these files will be opened outside of Visual FoxPro. Even though project files are native to Visual FoxPro, they can be added to a project as an Other File. Sounds kind of strange, doesn’t it? Double-clicking on this file will open the project in its own instance of the Project Manager. If the architecture you have selected has one main executable and several applications that are run from the main executable you can set up the controlling project and have the "app" projects available from within it. There is virtually no limit to the number of external files that are part of the project file, only the 2 gigabyte file size limit on the project metadata table. The only requirement is that the file added must have a registered file extension that is associated with a program. We encourage you to leverage this functionality when you find it appropriate. How to reduce screen real estate taken by the Project Manager Docking functionality is usually associated with toolbars. Many new VFP developers have not been introduced to the docking capability of the VFP Project Manager because they see it as a form on the desktop. The Project Manager can be a full size form or can be shrunk to a toolbar-like existence. This can be toggled by clicking on the arrow command button to the right of the tabs. The Project Manager gets docked only when it is dragged to the top toolbar/menu area of the development environment or by double-clicking the Project Manager TitleBar (also known as the form Caption). The only way to close a docked project is by using the File|Close menu option. You can also undock the project to close it via the close button. Chapter 14: Project Management 471 Figure 14.4 This is what the Project Manager looks like when it is docked to a toolbar and one of the pages are accessed by clicking on the page tab How to tear off tabs from the Project Manager Tear off tabs have nothing to do with your favorite canned cold beverage. Well it might if you have some old fashioned cans, but when it comes to Visual FoxPro, tear off tabs have to do with the Project Manager that has been reduced to its toolbar-like state. Click on the page of your choice, and then drag the page tab off the toolbar. This will leave the tab on the desktop. Once the tab has been torn off the toolbar, you can drag it anywhere you want on the VFP desktop. VFP remembers where you left the project when it is closed, but for some reason it does not save the state of the pages torn off. Grabbing the lower right corner of the tab allows you to size it just like a regular sizable window. Dragging any of the sides cannot do this – it must be the corner. Closing and reopening the project reattaches the tabs that were previously torn off. Clicking on the pushpin will toggle the pushpin. This should lock where the tab is, so you cannot drag it anywhere until it is again toggled "out". In VFP 6.0 with Service Pack 3 applied, the pushpin has no effect on the drag capability. [...]...472 100 1 Things You Always Wanted to Know About Visual FoxPro Figure 14.5 Here is this chapter's sample project with the All and Code pages torn off You can expand the Project Manager to full size even with the tabs torn off The pages that are torn off are disabled and remain torn off You can return the tabs back to the Project Manager in either expanded or reduced size by dragging them back, but you. .. in Visual FoxPro Using the CREATE CLASS command brings up the New Class dialog shown in Figure 15.1 You specify the class name, base it on the VFP projecthook (or another projecthook class you have created previously), and select the class library that you want to save the class 480 100 1 Things You Always Wanted to Know About Visual FoxPro Figure 15.1 The VFP New Class Dialog that demonstrates how to. .. hoping to add the greatest thing since sliced bread and makes it so the class no longer instantiates Or what if the class is deleted from the class library? What happens with the project? Simple – the project 482 100 1 Things You Always Wanted to Know About Visual FoxPro does not open I know you are thinking this is an ingenious security feature to unleash to stop the junior developers from getting into... needed We found out the hard way that you need at least one file from every directory for each file type For instance, if we have class libraries in the project’s Libs directory and the framework’s Libs directory, we need to add one file from each This way the build of the project can find the rest of the files in the 486 100 1 Things You Always Wanted to Know About Visual FoxPro search path that it establishes... If you want a specific class dropped on another container class, you can select it in the Project Manager and drag it to the container class This does not bind the object like the drag operation of a table field This allows you to override the IntelliDrop settings that are premapped 474 100 1 Things You Always Wanted to Know About Visual FoxPro We expected that an icon dropped on a form might set the... to be added to the native IDE This is the true beauty of the projecthook extension It allows us to add functionality to the development environment without having to wait for Microsoft to move our request to the top of the priority list This concept of enhancing development makes VFP shine over other developer tools Some of the features we implemented in phkDevelopment: 490 100 1 Things You Always Wanted. .. Always Wanted to Know About Visual FoxPro • Field Mapping Utility • Cleaning out hard coded printer information in reports • Project Audit (activity tracking) • File Backup capability • Displaying compiler/build messages to Status Bar or WAIT • Instantiating toolbar with button to call RAS Project Builder • Changing the default directory to the project directory • Adjusting the path custom to a project... THIS.DeveloperMessage("Path Directory property is not character") ENDIF ELSE 494 100 1 Things You Always Wanted to Know About Visual FoxPro * No special pathing requirements for this project ENDIF There is one drawback to this method Since there is no Activate method for the project that we can hook into, this code is only run when we open the project The RAS Project Builder tool discussed later in this... ProjectAuditUpdate ProjectBuilderToolBarinit ProjectBuilderToolBarinit 492 100 1 Things You Always Wanted to Know About Visual FoxPro Table 15.5 Properties added to our development projecthook with a short description of their usage Properties Description aErrorDetail[1,0] cBuildMessageSetting A collection of details about the last error to occur during processing Contains the message setting type, "S" statusbar... Always Wanted to Know About Visual FoxPro and hooking in a process that zips up all the files in the project to a compressed file via DynaZip Unfortunately the current Files object does not expose this field to the developer at this time and the backup process will need to "hack" the project file How to go about documenting the project file Until the projecthook was given to us in VFP 6.0, the only way to . but 464 100 1 Things You Always Wanted to Know About Visual FoxPro one good icon is easily worth the price of the entire CD when you consider how much time you can spend creating your own. How do you. stored in the application (.APP) file if that is the type of executable you generate. 466 100 1 Things You Always Wanted to Know About Visual FoxPro Figure 14.2 Using the Build Options dialog to. capability. 472 100 1 Things You Always Wanted to Know About Visual FoxPro Figure 14.5 Here is this chapter's sample project with the All and Code pages torn off You can expand the Project Manager to