What s New in Visual FoxPro 7.0 Tamar E. Granor Doug Hennig Kevin McNeish Hentzenwerke Publishing
Published by: Hentzenwerke Publishing 980 East Circle Drive Whitefish Bay WI 53217 USA Hentzenwerke Publishing books are available through booksellers and directly from the publisher. Contact Hentzenwerke Publishing at: 414.332.9876 414.332.9463 (fax) www.hentzenwerke.com books@hentzenwerke.com What s New in Visual FoxPro 7.0 By Tamar E. Granor, Doug Hennig & Kevin McNeish Technical Editor: Alex Wieder Copy Editor: Farion Grove Copyright 2001 by Tamar E. Granor, Doug Hennig & Kevin McNeish All other products and services identified throughout this book are trademarks or registered trademarks of their respective companies. They are used throughout this book in editorial fashion only and for the benefit of such companies. No such uses, or the use of any trade name, is intended to convey endorsement or other affiliation with this book. All rights reserved. No part of this book, or the ebook files available by download from Hentzenwerke Publishing, may be reproduced or transmitted in any form or by any means, electronic, mechanical photocopying, recording, or otherwise, without the prior written permission of the publisher, except that program listings and sample code files may be entered, stored and executed in a computer system. The information and material contained in this book are provided as is, without warranty of any kind, express or implied, including without limitation any warranty concerning the accuracy, adequacy, or completeness of such information or material or the results to be obtained from using such information or material. Neither Hentzenwerke Publishing nor the authors or editors shall be responsible for any claims attributable to errors, omissions, or other inaccuracies in the information or material contained in this book. In no event shall Hentzenwerke Publishing or the authors or editors be liable for direct, indirect, special, incidental, or consequential damages arising out of the use of such information or material. ISBN: 0-930919-06-9 Manufactured in the United States of America.
iii Our Contract with You, The Reader In which we, the folks who make up Hentzenwerke Publishing, describe what you, the reader, can expect from this book and from us. Hi there! I ve been writing professionally (in other words, eventually getting a paycheck for my scribbles) since 1974, and writing about software development since 1992. As an author, I ve worked with a half-dozen different publishers and corresponded with thousands of readers over the years. As a software developer and all-around geek, I ve also acquired a library of more than 100 computer and software-related books. Thus, when I donned the publisher s cap four years ago to produce the 1997 Developer s Guide, I had some pretty good ideas of what I liked (and didn t like) from publishers, what readers liked and didn t like, and what I, as a reader, liked and didn t like. Now, with our new titles for 2001, we re entering our fourth season. (For those who are keeping track, the 97 DevGuide was our first, albeit abbreviated, season, the batch of six Essentials for Visual FoxPro 6.0 in 1999 was our second, and, in keeping with the sports analogy, the books we published in 2000 comprised our third.) John Wooden, the famed UCLA basketball coach, posited that teams aren t consistent; they re always getting better or worse. We d like to get better One of my goals for this season is to build a closer relationship with you, the reader. In order for us to do this, you ve got to know what you should expect from us. You have the right to expect that your order will be processed quickly and correctly, and that your book will be delivered to you in new condition. You have the right to expect that the content of your book is technically accurate and up-to-date, that the explanations are clear, and that the layout is easy to read and follow without a lot of fluff or nonsense. You have the right to expect access to source code, errata, FAQs, and other information that s relevant to the book via our Web site. You have the right to expect an electronic version of your printed book to be available via our Web site. You have the right to expect that, if you report errors to us, your report will be responded to promptly, and that the appropriate notice will be included in the errata and/or FAQs for the book. Naturally, there are some limits that we bump up against. There are humans involved, and they make mistakes. A book of 500 pages contains, on average, 150,000 words and several megabytes of source code. It s not possible to edit and re-edit multiple times to catch every last
iv misspelling and typo, nor is it possible to test the source code on every permutation of development environment and operating system and still price the book affordably. Once printed, bindings break, ink gets smeared, signatures get missed during binding. On the delivery side, Web sites go down, packages get lost in the mail. Nonetheless, we ll make our best effort to correct these problems once you let us know about them. In return, when you have a question or run into a problem, we ask that you first consult the errata and/or FAQs for your book on our Web site. If you don t find the answer there, please e-mail us at books@hentzenwerke.com with as much information and detail as possible, including 1) the steps to reproduce the problem, 2) what happened, and 3) what you expected to happen, together with 4) any other relevant information. I d like to stress that we need you to communicate questions and problems clearly. For example Your downloads don t work isn t enough information for us to help you. I get a 404 error when I click on the Download Source Code link on http://www.hentzenwerke.com/book/downloads.html is something we can help you with. The code in Chapter 10 caused an error again isn t enough information. I performed the following steps to run the source code program DisplayTest.PRG in Chapter 10, and I received an error that said Variable m.licounter not found is something we can help you with. We ll do our best to get back to you within a couple of days, either with an answer or at least an acknowledgement that we ve received your inquiry and that we re working on it. On behalf of the authors, technical editors, copy editors, layout artists, graphical artists, indexers, and all the other folks who have worked to put this book in your hands, I d like to thank you for purchasing this book, and I hope that it will prove to be a valuable addition to your technical library. Please let us know what you think about this book we re looking forward to hearing from you. As Groucho Marx once observed, Outside of a dog, a book is a man s best friend. Inside of a dog, it s too dark to read. Whil Hentzen Hentzenwerke Publishing July 2001
v List of Chapters SECTION 1 Developer Productivity 3 Chapter 1: IntelliSense 5 Chapter 2: Editor Enhancements 31 Chapter 3: New and Better Tools 43 Chapter 4: More IDE Changes 75 SECTION 2 Developing Desktop Applications 79 Chapter 5: Data 81 Chapter 6: OOP Enhancements 107 Chapter 7: Strings 119 Chapter 8: Resource Management 125 Chapter 9: Arrays 141 Chapter 10: Bits and Pieces 147 SECTION 3 Developing Components 151 Chapter 11: Building Component-Based Software 153 Chapter 12: Building World-Class COM Servers in VFP 7 161 Chapter 13: Implementing Interfaces 183 Chapter 14: Playing in the COM+ Sandbox 197 Chapter 15: Working with Web Services 225 APPENDIX 251 Appendix: New Installation Features 253
vii Table of Contents Our Contract with You, The Reader Acknowledgements About the Authors How to Download the Files Foreword iii xvii xix xxi xxiii Introduction 1 Organization 1 Get the picture 2 What about the code? 2 Go to it 2 SECTION 1 Developer Productivity 3 Chapter 1: IntelliSense 5 What IntelliSense offers 5 Automatic keyword completion 5 Command and function syntax tips 7 List of members 9 Early binding 10 Values list 11 Most recently used file list 12 Table, field, and variable lists 13 Configuring IntelliSense 14 IntelliSense Manager 14 Configuring IntelliSense programmatically 19 Scripting IntelliSense 19 Creating your own shortcuts 19 Hooking into the default script 25 Other IntelliSense-related items 29 Summary 29 Chapter 2: Editor Enhancements 31 Writing code 31 Parenthesis matching 31
viii Dirty file indicator 31 Live hyperlinks 32 Formatting code 33 Tabs vs. spaces 34 Visible white space 34 More options to set 35 More menu items 37 Working with existing code 38 Moving around in the editor 38 Marking points 38 Finding text 39 Finding places 41 Better access to files 42 Summary 42 Chapter 3: New and Better Tools 43 Modern menus 43 Class and Form Designers 47 Drilling down into containers 47 Identifying ActiveX PEMs 47 Identifying inherited methods 48 Preserving case in parameters statements 49 Real grid coordinates 49 Project Manager 50 Report Designer 50 Distributing applications 50 Creating an InstallShield Express project 51 Organize your setup 52 Specify application data 53 Configure the target system 56 Customize the setup appearance 58 Define setup requirements 59 Prepare for release 59 Other InstallShield Express information 60 Window behavior 60 Dockable windows 60 Properties Window enhancements 63 Other window enhancements 63 Task List 64 Improved debugging 66 Active Accessibility and the Accessibility Browser 67 Automated testing 69 Modify Procedure and View 72 New FFC classes 72