ShowWindow

This property, added in VFP 5, determines who owns a form or toolbar. Together with the Desktop property, it also determines where the form or toolbar appears.

Usage

nWindowOwner = oObject.ShowWindow

Parameter

Value

Meaning

nWindowOwner

0

The main VFP window (_SCREEN) owns the form or toolbar.

1

A VFP-created top-level form owns the form or toolbar.

2

Windows owns the form—it's a top-level form.


Why does it matter who owns a form or toolbar? There are a couple of reasons, but the biggest is professionalism. Having your whole application contained in the main VFP window just doesn't look very good. Even if you set Desktop to .T. so the window can go anywhere, it still belongs to the main VFP window—when you minimize VFP, it goes along. That's not the way serious applications work. ShowWindow lets you create an independent window for your application and have it appear in the taskbar and behave independently from the main VFP window. So the next question is, to quote George Carlin, "Why are there three?" The answer is that, once you've created your top-level form to host your application, you may want to have it contain other windows (children). Even if you don't, you probably do want it to own a toolbar. The forms and toolbars that belong to a top-level form need ShowWindow set to 1. Setting ShowWindow to 1 only partly determines where a child form appears. If Desktop is .T., the child form belongs to the top-level form, but can appear anywhere. However, when you minimize the top-level form, the child form goes with it, even if it's physically elsewhere.

If you create a toolbar as a child of a top-level form too early in the form's existence, the toolbar is confined to the main VFP window rather than to the top-level form. Load and Init are definitely too early. Activate is late enough—just remember to add some code so you create the toolbar only once.


Top-level forms can't be modal. You can set WindowType to 1 all you want, but it doesn't do you any good. When you run the form, WindowType is set to 0 behind the scenes. However, forms shown in top-level forms (ShowWindow = 1) can be modal.

Example

IF This.ShowWindow = 2
   This.Caption = "You don't own me!"
ENDIF

See Also

AlwaysOnBottom, AlwaysOnTop, Desktop, MDIForm, _Screen, ShowInTaskBar, WindowType


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .