How to Perform In-Place Activation on an OLE Control

ID: Q148642

3.00 WINDOWS kbinterop kbhowto

The information in this article applies to:

  • Microsoft Visual FoxPro for Windows, versions 3.0 and 3.0b

SUMMARY

When you add an OLE control to a Visual FoxPro form, you can force the control to have the focus and immediately be the object that receives keystrokes. This is called in-place activation. This article demonstrates two methods you can use to activate an OLE container control in this manner.

MORE INFORMATION

Two Techniques to Activate an OLE Control

1. Determine if the object will respond to the OLE DOVERB activation

   method. If the object will respond, fire the DOVERB("EDIT") method.
   This technique has the advantage of activating the object without
   placing any keystrokes in the keyboard buffer.

2. If the object does not respond to the DOVERB method of activation,
   stuff the keyboard with an ENTER keystroke, and move the focus to the
   object.

Step-by-Step Example to Demonstrate Both Techniques

1. Create a new form. Place an OLE container control with an object

   of your choice on the form.

2. Place a command button on the form with the following code in the
   click event:

   IF ThisForm.OleControl1.DoVerb('')
      * The vast majority of modern applications fall into this category
      =MESSAGEBOX("This object responded to activation",0)
      ThisForm.OleControl1.DoVerb("Edit")
   ELSE
   * To test the validity of this process, change the previous lines of
   * code into comments and run the three lines listed below.

      =MESSAGEBOX("This object must be activated with the Enter key",0)
      KEYBOARD '{ENTER}'
      ThisForm.OleControl1.SetFocus()
   ENDIF

3. Save and run the form.

Additional reference words: 3.00 inplace in-place KBCategory: kbinterop kbhowto KBSubcategory: FxinteropOle

Keywords          : kbcode FxinteropOle 
Version           : 3.00
Platform          : WINDOWS


Last Reviewed: May 22, 1998
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.