PRB: Some OLE Control Events Do Not Fire in Visual FoxPro 3.0bID: Q143303 3.00b WINDOWS kbinterop kbprb The information in this article applies to:
SYMPTOMSUnder certain circumstances, user code attached to events of OLE Controls may not execute. In particular, if you click a control while user code of another control is running, the OLE control seems to get the focus. However, the user code associated with the Click event is not called. This article explains why this behavior may happen.
CAUSEVisual FoxPro regularly calls the Windows API PeekMessage to handle function keys and ON KEY LABEL. Calling PeekMessage yields Visual FoxPro processing and allows the OLE control to trigger the event. However, the firing of the event fails, and this behavior is not handled by the OLE control.
STATUSThis behavior is by design.
MORE INFORMATIONIn xBase a user has the ability to assign commands to Hot-Keys, or ON KEY LABEL (OKL).The command associated with OKLs is called as soon as the key is pressed, no matter what is happening in Visual FoxPro. In the following example program, pressing the F5 key stops the execution of the program and immediately calls the statement assigned to the OKL. Once the OKL command is completed, Visual FoxPro resumes the program.
To support this behavior, Visual FoxPro calls the Application Program
Interface (API) PeekMessage() between each execution of a command. In the
previous case, Visual FoxPro calls PeekMessage between the FOR command and
the ENDFOR command. Visual FoxPro also calls PeekMessage() when it is
executing a query or indexing a big table because users may press the ESC
key to interrupt and halt the command. If Visual FoxPro didn't call
PeekMessage, it wouldn't see the key until it's too late.
Calling PeekMessage yields Visual FoxPro processing and gives an OLE control a chance to look at its message queue and trigger events. However, at that time, Visual FoxPro does not handle the firing of an event because it is looking for key messages that are defined with OKLs. Visual FoxPro thus fails the firing of the control event. Visual FoxPro fails the firing of the event in two different situations. 1. Visual FoxPro is currently handling an event. As Visual FoxPro begins 2. Visual FoxPro sees that the event was fired while it was executing
Steps to Reproduce Behavior1. Create a new form. 2. Place an OLE Container control on the form. When the Insert object 3. Place the following code in the Init event of the OLE control:
4. Place the following code in the MouseDown and the Click events:
5. Place a command button on the form, and in its Click event, type:
6. Save the form, and run it. When the window appears, click the command
KBCategory: kbinterop kbprb
KBSubcategory: FxinteropOle
Additional reference words: 3.00b ActiveX OCX
|
Last Reviewed: February 27, 1997 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |