My.ADVISOR.com Sign-In
ID
Password

Member Center / Sign-Up
Go to Article
Advanced Search 

VISUAL FOXPRO ADVISOR TIPS

Restore Visual FoxPro System Windows at Startup

If you tend to rearrange system windows during development, here's a way to easily restore their default size, position, and dock status.

By Mike Lewis, contributing editor


I often rearrange the system windows within my development environment, either inadvertently or as a temporary convenience. Because the new arrangement is saved in my resource file, when I restart VFP, I see the windows with their new size, position, and dock status rather than with my preferred defaults.


To get around this, I wrote the following code:

ACTIVATE WINDOW Document
ZOOM WINDOW "Document"  NORM AT 1, 1 SIZE 40, 50
DOCK WINDOW Document POSITION 2
ACTIVATE WINDOW VIEW
ZOOM WINDOW "View"  NORM AT 1, 1 SIZE 20, 50
DOCK WINDOW View POSITION 4 WINDOW Document
ACTIVATE WINDOW Properties
ZOOM WINDOW "Properties"  NORM AT 1, 1 SIZE 20, 50
DOCK WINDOW Properties POSITION 4 window Document
ACTIVATE WINDOW Command
ZOOM WINDOW "Command"  NORM AT 43, 1 SIZE 17, SCOLS()
DOCK WINDOW Command POSITION 3

To be able to run this code on demand, I used the Manage Environments dialog in the Task Pane. On the Environment Settings tab, I pasted the code into the "Run script after environment is set and project is loaded" box. I then created a shortcut to the environment (by right-clicking on the environment name and selecting "Copy shortcut"). This copied the following string to the clipboard:

vfps:doapplication?filename=(HOME() + "envmgr.app")
  WITH "_1WF0P5KWK"

The value "_1WF0P5KWK" is a unique internally-generated key that the Environment Manager uses to recognize the shortcut.

Finally, I created the following keyboard macro:

{CTRL+F2}DO{SPACEBAR}(HOME()+"envmgr.app"){SPACEBAR}
WITH{SPACEBAR}"_1WF0P5KWK"{ENTER}

Now, whenever I want to restore the system windows to their default size, position, and dock status, I just hit the macro key.

-- Mike Penny, Ilminster, United Kingdom

A simpler approach would be to store the code in a PRG file, and to run that file directly from the keyboard macro. Alternatively, you could designate the code as a startup program, so that it runs whenever you launch VFP (to do so, enter the program's fully-qualified filename against "Startup Program" on the File Locations tab in the Options dialog).

But Mike's solution has two advantages: He doesn't need to keep track of a separate program file; and the windows are restored automatically whenever he loads the environment.

-- Mike Lewis, contributing editor

Restore Visual FoxPro System Windows at Startup

No reader comments ... yet.

    What do YOU think about this topic? Share your advice and thoughts using this form.

    Your Name

    REQUIRED : PUBLIC

    Your E-Mail

    REQUIRED : PRIVATE

    Job, Company

    OPTIONAL : PUBLIC

    City, State, Country

    OPTIONAL : PUBLIC

    Your Web Site

    OPTIONAL : PUBLIC

    Your Comment

    Please help everyone by keeping your comments on-topic, using clean language, and not defaming or making personal attacks.


    Your e-mail address is required, but it will not be displayed to the public or given to anyone. See our Privacy Policy. Comments become visible after they pass our spam filter, and spammers and abusers are permanently blocked. Please report spam or abuse.

    Mike Lewis is a Visual FoxPro developer and trainer. Based in Scotland, he runs Visual FoxPro training courses for clients throughout Europe and the USA. http://www.ml-consult.co.uk

    Printer-friendly
    page layout

    Keyword Tags: Microsoft, Microsoft Visual FoxPro, Programming

    ADVISORAMA
    Good-bye. I am leaving because I am bored.
    -- George Saunders, last words

    ARTICLE INFO

    DataBased Advisor

    Web Edition: 2008 Week 06, Doc #19400

    FREE ACCESS FREE ACCESS

    SUBSCRIPTION STATUS
    You are not signed-in. If you are a subscriber to this publication, sign-in above to access locked articles. To subscribe or renew go to www.AdvisorStore.com.

    Subscribe to DATABASED.ADVISOR.com

    Get it all -- the most popular ADVISOR tech/business publications are now merged into one subscription, with new articles and a huge reference library packed with expert advice, how-to and downloads. Subscribe now to get it all.

    DataBased.Advisor.com

    Subscribe to FileMaker Advisor Magazine

    Read the advanced guide to creating custom business database solutions with FileMaker software. Subscribe now to gain access to all the archives and downloads.

    FileMaker.Advisor.com

    Subscribe to Advisor Basics of FileMaker Pro

    Learn the fundamentals of using FileMaker Pro software. Every issue gives you step-by-step instructions on creating the databases you need. Subscribe now!

    FileMaker.AdvisorBasics.com

    Showcase Your Smarts

    Submit your tips, techniques and advice and let Advisor promote your business and build your career. Show the world what you know!

    AdvisorTips.com

    Use of this or any other site, content, product or service of Advisor Media constitutes acceptance of Terms of Use.
    Portions copyright ©1983-2008 Advisor Media, Inc. All Rights Reserved.
    Reuse or reproduction of any portion or quantity of Advisor Media's copyrighted content, in any form, for any purpose, requires written permission.
    ADVISOR®, the ADVISOR logo, and other names and logos that incorporate ADVISOR are registered trademarks, trademarks or service marks of Advisor Media, Inc. in the United States and/or other countries.
    Other trademarks are used for identification, editorial or descriptive purposes and are the property of their owners.
    Hosted by Prominic.NET Website powered by
    LOTUS SOFTWARE
    lewim54 posted 02/04/2008 modified 01/09/2009 03:36:53 AM ztdbms/ztdbms
    domino-144.advisor.com my.advisor.com 01/09/2009 04:28:28 PM