Microsoft KB Archive/141425

= FIX: Toolbar Events Fire Differently When Using Dock Method =

Article ID: 141425

Article Last Modified on 9/30/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition

-



This article was previously published under Q141425



SYMPTOMS
The BeforeDock, Undock, and AfterDock events are not triggered in the same order when a toolbar is docked interactively versus when a toolbar is docked under program control.

When the dock position of a toolbar is changed interactively, the events fire in the following order: BeforeDock, AfterDock When the dock position of a toolbar is changed under program control with the Dock method, the events fire in the following order: BeforeDock, Undock, BeforeDock, AfterDock



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual FoxPro 5.0 for Windows.



WORKAROUND
There is no way to prevent the events from occurring, or to trigger the events under program control. However, if you have code for the BeforeDock and Undock methods and do not want to call it when the Dock method is executed, follow these steps:

 Add a property to the class called lDockit.  In the Dock method, set the value of this property to true (.T.) as in this example: IF THIS.DockPosition != -1 && The toolbar is already docked THIS.lDockit=.T.  ENDIF   In the event handler for BeforeDock, add the following: IF THIS.lDockit <> .T.  ENDIF   In the event handler for Undock, add the following: IF THIS.lDockit<>.T.     ELSE THIS.lDockit=.F.  ENDIF 



Steps to Reproduce Problem
 Type CREATE CLASS in the Command window.</li>  In the Create Class dialog box, enter the following information to create a class based on the Toolbar class: ClassName: TbrDock Based On : select Toolbar Store In : Clstbar </li>  In the Class Designer, enter the following line for the AfterDock, BeforeDock, and Undock event handlers: =MESSAGEBOX(PROGRAM) </li> Save the class.</li>  Create a toolbar object by typing the following code in the Command window: SET CLASSLIB TO clstbar oTrdock=CREATEOBJECT("TbrDock") oTrdock.Show </li> Use the mouse to dock the toolbar. The BeforeDock and AfterDock events fire.</li>  From the Command window, call the Dock method to move to another docked position: oTrDock.Dock(1) The BeforeDock, Undock, BeforeDock, and AfterDock events are triggered. </li></ol>

Keywords: kbbug kbfix kbvfp500fix KB141425

-

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

© Microsoft Corporation. All rights reserved.