FILE: Treewrap.exe: Sample TreeView Control in Visual FoxProLast reviewed: November 19, 1997Article ID: Q176270 |
The information in this article applies to:
SUMMARYVisual FoxPro 5.0, ships with the TreeView control that is one of the controls in the Comctl32.ocx. When you use the TreevView control in a Visual FoxPro application, several issues may prevent you from using all the features of the control. However, you may work around the problems by creating an ActiveX control in Visual Basic 5.0 that acts as a wrapper for the TreeView control. Code that will not work if written in FoxPro may be written in Visual Basic. When you create the control, build the functionality needed into the wrapper control. The sample file explains how to create the wrapper control in Visual Basic and expose the different properties, methods, and events to a container that is using the control. For example, the code that gives a user the ability to drag and drop nodes in the TreeView control is built in the wrapper control. There is also an ImageList control inside the wrapper control so that you can assign images for the TreeView to use. The following file(s) is available for download from the Microsoft Software Library:
~ Treewrap.exeFor more information about downloading files from the Microsoft Software Library, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q119591 TITLE : How to Obtain Microsoft Support Files from Online Services MORE INFORMATIONThe TreeView control example illustrates some basics of using and manipulating the TreeView control. Because Visual FoxPro does not handle some of the methods and properties of the TreeView control, this example uses an ActiveX control written in Visual Basic that acts as a wrapper for the TreeView control. The example also shows how to add Nodes to the control using the five different relationship settings of the Nodes Collection Add Method. The sample code also allows you to remove a selected Node or branch. The main focus of the example is to show how to save and restore the Nodes in a FoxPro table. The algorithm used saves the Nodes in viewing order. This allows you to save and restore the TreeView control with the Nodes in the same order that the user was viewing them when the application closed. The sample file also illustrates dragging and dropping of the Nodes. The code allows you to drag a Node and drop it on top of a different Node so that the dragged Node is now the child of the Node on which it was dropped on. The drag and drop code was written into the wrapper control with Visual Basic. The wrapper control then exposes the necessary properties, methods, and events so that you can use the control in Visual FoxPro. An Imagelist control is also included in the wrapper control to give you the ability to assign an image to the nodes.
NOTE: To use this sample in FoxPro, you need to issue a SYS(2333,0) before you open or run the TreeView form. You will also need to use Regsvr32.exe and register the Vbtofox.ocx before you use the .ocx file. (It does not matter where the .ocx file is located for this example to work.) The syntax for using Regsvr32.exe is as follows:
Regsvr32 [/u] [/s] <.ocx File Name> where: /u means Unregister the .ocx File /s means Silent Mode (display no messages)If you build the .ocx file in Visual Basic, it will register the control for you. The default in Visual Basic is to give the control a new class ID every time the control is rebuilt. This can cause errors in Visual FoxPro because it may be looking for a version of the control with a different class ID. To use this sample, you will need to have Visual Basic 5.0 and Visual FoxPro 5.0 installed on your system. This sample has not been tested on a machine that did not have both Visual Basic and Visual FoxPro installed. Here are the steps to run the sample:
REFERENCESFor more information on the TreeView control see the Online Help. Additional information on creating ActiveX controls in Visual Basic may be found in the Visual Basic's Component Tools Guide and Books Online. Visual FoxPro Help; 5.0, 5.0a; search on: TreeView control1 Visual Basic's Component Tools Guide and Books Online; search on: Creating ActiveX controls in Visual Basic (c) Microsoft Corporation 1997, All Rights Reserved. Contributions by Brian Combs, Microsoft Corporation
|
Additional query words: vfoxwin
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |