Microsoft KB Archive/129205

= How to Add Multiple Properties When You Add Objects =

Article ID: 129205

Article Last Modified on 4/25/2000

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition

-



This article was previously published under Q129205



3.00 WINDOWS



SUMMARY
This article shows by example how to:


 * Add objects to a container within a Class definition by using the ADD OBJECT command, and specify multiple properties of the added object by using the WITH keyword.
 * During the creation of a container, use the AddObject (one word) method to add an object, and specify multiple properties of the object by using WITH...ENDWITH.



Example One
You can specify multiple properties of an added object within the Class definition by using the WITH clause. WITH...ENDWITH, however, is not valid within a Class definition and will result in an error.

  ** Start of Example One

MyNewForm=CREATE("frmForm") MyNewForm.Show

READ EVENTS

DEFINE CLASS frmForm AS Form

Visible = .T.     Left    = 50 Top    = 30 ADD OBJECT MyQuitButton AS cmdQuitButton WITH ; Left   = 30, ; Top    = 30, ; Height = 60, ; Width  = 100, ; Caption = "Quit"

ENDDEFINE

DEFINE CLASS cmdQuitButton AS CommandButton

PROCEDURE Click RELEASE ThisForm CLEAR EVENTS ENDPROC

ENDDEFINE

** Note: Without the semicolons and commas in the ADD OBJECT ... WITH ** clause, error messages will occur such as "Unrecognized command  ** verb" and "Command contains unrecognized phrase/keyword."

Example Two
This example shows how to use AddObject method with the WITH...ENDWITH clause to specify multiple properties for the object.   ** Start of Example Two

frmForm = CREATEOBJECT("Form")

WITH frmForm

.Visible  = .T.      .ScaleMode = 3 .AddObject("pgfPageFrame", "PageFrame") WITH .pgfPageFrame .Visible  = .T.         .PageCount = 2 .Left     = 50 .Top      = 20 .Height   = 200 .Width    = 250 ENDWITH

ENDWITH

** The WITH...ENDWITH may be used to specify properties of the object ** by pointing to the parent, which is the container in this case.

WITH frmForm.pgfPageFrame

.PageCount = 3

ENDWITH

READ EVENTS

Additional query words: VFoxWin

Keywords: kbcode KB129205

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.