====================================== FoxPro Developers Network of San Diego ====================================== FoxDev TipsLetter #01-12 14 December, 2001 Website: Editor: ---------------------------------------------------------------------- CONTENTS: * Christmas Party ** Wednesday, December 19 * Calendar * Tech Tips: Write to a Form Without Controls ProFox All About TitleBars Malcolm Greene Saving File Status the Classy Way Dan Covill Steve Sawyer's ViewEdit * Links: Where Can I Find...? * Other Stuff: David Parnas on Certification ACM/Ubiquity The Balloon Joke Complexity in the Interface Age Jeremy Shapiro * Administrivia ====================================================================== CHRISTMAS PARTY: Dec 19 (Wednesday) ------------------ Our annual holiday dinner party will be at Trophy's La Jolla, in the Costa Verde center across Genesee from UTC. We'll meet at 7:00. From I-5: Take the La Jolla Village Dr exit and head east, toward UTC. Turn right on Genesee and right at the first light, into the Costa Verde center. Trophy's will be right up ahead on the right. From 805: Take the Miramar Rd/La Jolla Village Dr exit and head west, past UTC. Turn left on Genesee and right at the first light, into the Costa Verde center. ---------------------------------------------------------------------- CALENDAR: Jan 2 - Web Connection Part 1 ----------------------------- Barbara Peisch will demonstrate the basics of how to create data-driven web sites using West Wind's Web Connection. Feb 6 - Web Connection Part 2 ----------------------------- Barbara Peisch will complete the presentation on Web Connection, focusing mainly on how to deploy a web application created with Web Connection to a live server. ------------------------------- Escondido meetings are at Bergelectric, 2222 Meyers Avenue. All meetings are at 6:30 pm. Take the Nordahl exit from Highway 78 (west of I-15). Head South. Right on Meyers Ave, first right past Mission. It's a one-story building on the right (there's no sign). ====================================================================== TIPS ====================================================================== WRITING TO A FORM WITHOUT CONTROLS ProFox You don't need controls on a form to display information! You can use the form's own font* properties and just write FP DOS style. It's the simplest possible way to display a message or data in VFP, and also a very handy way to deal with some of the issues when running old FP DOS programs. oForm = createobject("Form") with oForm .autocenter = .T. .fontname = "Courier" .font = bold .forecolor=rgb(255,255,255) endwith oForm.Show @ 5,5 say "Hello, World" When you run the form, it behaves just like an FPD screen. This means you can put big extended messages on a form, without having to use a label. You can also position text precisely in this way. It is cool !! And brings reminiscences of the old trustworthy FPD. It is probably not very OOPish, but, if it works, who cares ? You can also do: .currentX = 10 .currentY = 5 .print("Hello, World") and you get the same result, but you use three lines of code vs only one line if you use @ say. You could also have your own method and call it with: thisform.atsay(10,10,"Hello") [From ProFox posts by Rafael Copquin and Allen Pollard] ---------------------------------------------------------------------- ALL ABOUT TITLEBARS Malcolm Greene -----Original Message----- Is there a way in VFP7 to change the control box menu in forms? [From right-clicking on the icon at the left of the window's title bar. DC] Instead of the usual 'Move' 'Minimize', etc. I'd like to have form specific options. Is it possible? Rafael Vilar -----Reply----- Keeping in mind that there are usually many ways to skin a Fox ... Here are some general ideas for 'faking' what you want to accomplish. 1. Get rid of your form's titlebar by turning it off via a .Titlebar property. 2. Add your own (fake) 'title bar' to your form using a shape or container control. 3. There are API calls (possibly VFP's Sysmetric() function?) that return the color and height of a title bar so you can size and color your title bar to match a PC's default titlebar characteristics. 4. The Marlett font (comes with all 32 bit flavors of Windows) has characters that match the min, max, restore, close and whats-this-help buttons typically found in the right hand corner of a typical titlebar. Add buttons to your titlebar using this font. Size (height/width) the buttons relative to the height of your titlebar. Have the GotFocus event return .F. so that these buttons don't fall into your tab order. Place code in each button's Click() event that carries out the corresponding action (minimize window, maximize window, etc.) Don't forget tooltips for these controls! 5. Place your form icon on the left hand edge of this container. Follow with an autosizing, transparent label containing your form's Caption. 6. In your form's icon click event activate your custom form popup (your custom control box menu). Your icon's DblClick() event should attempt to close the form. 7. Place an transparent shape sized to fit between your form icon and the left most control property found on the right hand side of your titlebar. You can use the MouseDown() event to track the relative shift in mouse position and move your form accordingly. This will allow your users to click and drag on your form's new titlebar to move the form. You will also want to add code to your the shape's DblClick() event to handle a request to toggle the form's state between a normal (restore) and maximized size. 8. If you have a resizable form, your form's Resize() event will need to resize your titlebar and re-position your min, max, etc. controls to the form's right hand margin. In your form's KeyPress () event you may also want to trap for common keystroke shortcuts for min, max, close, etc. if you decide not to include menu bars for these actions on your form's shortcut menu. Note that your titlebar creation and event code should query the appropriate form properties before determining whether a form can be moved, resized, maximized, minimized, etc. That's it! Well, not exactly. Newer flavors of Windows have titlebars with gradient colors vs. solid colors. I'm not sure how you could determine the color gradient and duplicate it in your titlebar. I'm not sure (I'm not on a VFP enabled workstation) if there's a way for VFP to trap the Alt+Space keystroke which is the keyboard shortcut for activating a form's control box menu. While the above sounds complicated, it could easily be turned into a reusable class. And if your forms are simple (not resizable) the effort may be much easier. A simpler idea might be to activate your form specific menu via your form's RightClick() event. Malcolm Greene [Some great information here, if you're thinking about mucking with Windows standard form features. For myself, I look at this as several good reasons to leave it alone! I find it hard to see how any usability benefit can possibly offset the cost, complexity, and risk of this sort of dumpster-diving. And what do you do when Win XP2 changes everything? DC] ---------------------------------------------------------------------- SAVING FILE STATUS THE CLASSY WAY Dan Covill We've all written the following code, in many procedures: local OldSel OldSel = select() ..(use some other file).... select (OldSel) return a) Sometimes you need to save the order and record number also. b) If there's another "return" you have to restore there too. c) If use the same file but set a filter, you may be in trouble. "wOOdy" Wondzinski suggested a better way on ProFox that I have implemented as my SaveStatus class. a) Saves select, order, recno(), and filter all in one shot. b) You don't have to restore anything! The magic is that the object is declared local: local oSave oSave = createobject("SaveStatus") ... (do whatever you want) ... You're done! There is no "restore" code, no matter how many exits you have. The magic is this: the class saves everything in its own properties during init() - it restores them in the destroy() method. Since exiting your procedure destroys all local objects, everything gets restored! *------------------------------------ define class SaveStatus as separator * Save workarea and restore on exit. * Saves select, order, recno(), and filter * Usage: local oSave; oSave = createobject("SaveStatus") * Needs no "restore" call on procedure exit, * because the local object is automatically destroyed. * 11/13/01 - D.Covill, from an idea by Juergen Wondzinski nSelect = 0 cFilter = '' cOrder = '' nRecno = 0 procedure Init with this .nSelect = select() .cFilter = set("Filter") .cOrder = order() .nRecno = recno() endwith endproc procedure Destroy *-- Make saved area the current one local OldFilter with this select (.nSelect) *-- Is it still open? if not empty(alias()) OldFilter = .cFilter set filter to &OldFilter && (.cFilter) doesn't work set order to (.cOrder) && but (.cOrder) does! goto (.nRecno) endif endwith endproc enddefine ---------------------------------------------------------------------- STEVE SAWYER'S VIEW EDITOR from Profox Q. Is there a way to hack the view designer, so I can write by hand a SQL statement? I have a .dbc, a connection to a SQL Server and a few remote views. But, as the views become more complicated, it's harder to write them in view designer. A. Don't use the view designer - use Steve Sawyer's ViewEditor. The view designer generates SQL statements using nested joins rather than sequential ones, and if you have more than 2 tables involved the result is generally wrong. Go to http://www.stephensawyer.com/, click on Technical Info and Tools, then pick View Editor. There are two versions, one for VFP6 and a new, improved one for VFP7, with chrome ashtrays. Download is free. ====================================================================== LINKS ====================================================================== This is a (semi) permanent list of places to look for technical help when you get blind-sided by the latest urgent requirement. We don't give specific URLs for MSDN articles because (a) they're too long and (b) they change too often! ------------------------------- MSDN ON LINE: There's a ton of stuff here, look at the Magazines tab, and read some of the regular columns. MSDN Library Look in Technical Articles | Visual Studio | Visual FoxPro MSDN Library: "Building Three-Tier Client/Server Applications with Visual FoxPro" ADO MSDN Library: ADO Jumpstart for Microsoft Visual FoxPro Developers John V. Petersen, April 1999 DNA (Distributed interNet Architecture): MSDN On-line: "Top Windows DNA Performance Mistakes and How to Prevent Them" FoxPro 2.6: http://members.aol.com/FoxProResources/fpfp.htm MTS: Microsoft Transaction Server MSDN Library: "Microsoft Transaction Server for Visual FoxPro Developers" ODBC: MSDN Library: "Using Visual FoxPro to Access Remote Data" ODBC drivers are part of MDAC - Microsoft Data Access Components - and are available for download at: "www.microsoft.com/data" VS Installer: MSDN Library: a. "Using Visual Studio Installer for VFP 6.0 Applications" b. "VFP 6.0 and VS Installer Tutorial" VFP General: MS Developer Applications Forum on Compuserve http://go.compuserve.com/msdevapps The Universal Thread http://www.universalthread.com Here is the most complete set of FoxPro links you're likely to find: http://www.cetus-links.org/oo_visual_foxpro.html Private websites with useful free downloads: www.prolib.de/foxlinks.afp (wOOdy Wondzinski) www.honeypass.com (Allen Pollard) WEB Development: These products all work well with VFP. DotFox www.elsoftware.com WestWind www.west-wind.com FoxWeb www.foxweb.com AFP www.afpweb.com and www.afpages.com X-WORKS www.x-works.com Windows General Win32 API (with VFP examples) XML - What's New in XML for Microsoft Windows 2000 See also OLE DB drivers for XML in MDAC 2.6 at "microsoft.com/data" [Contributions solicited. DC] ====================================================================== OTHER STUFF ====================================================================== DAVID PARNAS ON CERTIFICATION Ubiquity: A Web-based publication of the ACM Volume 2, Number 30, Week of October 1, 2001 Interview with David Parnas "Do You Have a License to Drive That Mouse?" Dave Parnas has written extensively on many aspects of software engineering, and is generally considered one of the founders of Object Oriented Programming. He has recently written in favor of the licensing and certification of software professionals, which he believes is, in principle, as necessary as the certification and licensing of doctors, lawyers, hairdressers and other professionals. Read his comments at: http://www.acm.org/ubiquity/interviews/d_parnas_1.html ---------------------------------------------------------------------- THE BALLOON JOKE - MANAGEMENT VERSION A man in a hot air balloon realized he was lost. He reduced altitude and spotted a woman below. He descended a bit more and shouted, "Excuse me, can you help? I promised a friend I would meet him an hour ago, but I don't know where I am." The woman replied, "You are in a hot air balloon hovering approximately 30 feet above the ground. You are between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude." "You must be an engineer," said the balloonist. "I am," she replied, "How did you know?" "Well," answered the balloonist, "everything you told me is technically correct, but I have no idea how to use it, and I am still lost. Frankly, you've not been much help so far." The woman responded, "You must be in Management." "I am," replied the balloonist, "but how did you know?" "Well," said the woman, "you don't know where you are or where you are going. You have risen to where you are due to a lot of hot air. You made a promise which you have no idea how to keep, and you expect people beneath you to solve your problems. The fact is you are in exactly the same position you were in before we met, but now it's become my fault!" ---------------------------------------------------------------------- COMPLEXITY IN THE INTERFACE AGE by Jeremy Shapiro from an interview on 11/20/01 Shapiro is a faculty member in the Human and Organization Development Program at The Fielding Institute. SHAPIRO: I am interested in the old "sorcerer's apprentice" issue: the way in which technologies that are supposed to be instruments and servants of people are their masters. I have been thinking of making a T-shirt called "People are merely means for the creation of better technologies." I'm talking about the underlying model of the computer user as na‹ve, passive consumer. I am one of those old-fashioned people who doesn't like everything to be done for me invisibly behind the scenes. I like to understand how it's done, and through that understanding be able to influence it myself. It's not just a personal preference, it's a political belief in autonomy and the decentralization of power. Part of my current frustration about interfacing has to do with the fact that in the Microsoft world, more and more things happen invisibly, behind the scenes, without your knowledge or approval. In the current computer environment, things are constantly being done to your computer without your approval or knowledge: files are installed, defaults are set, programs try to access the Internet, information is recorded and transmitted, all without your knowledge. Ads are injected, cookies are deposited, and so on. That is an operating environment that I find not only distasteful and hard to use but morally and politically reprehensible, because it means that you are subject to the control of mysterious entities that are not in your own environment that you can't really talk back to. I don't like that type of operating environment -- it's totalitarian. And it makes interfacing more difficult because you don't have information that would be helpful in rectifying problems. --------------------------Administrivia------------------------------- This newsletter is a service to all FoxPro developers, provided without charge by the FoxPro Developers Network of San Diego (FPDN). Anyone may subscribe (or unsubscribe) at our web site . The link is on the home page. The Resources button on the website will take you to the back issues of the newsletter. The editor (Dan Covill) is solely responsible for the content. E-mail him with YOUR tips, comments, or complaints. Editor: Dan Covill 858-272-2448 dcovill@acm.org Board of Directors: Eric Lendvai - President 760-734-4929 eric@elsoftware.com Art Bergquist - Vice Pres 760-740-0428 abergquis@cs.com Claude Nikula - Secretary 619-615-6318 crndev@home.com Barbara Peisch - Treasurer 760-729-9607 barbara@peisch.com Dan Covill - Director 858-272-2448 dcovill@acm.org Thad V'Soske - Director 619-544-9900 tvsoske@hanoverdirect.com ----------------------------------------------------------------------