Windows.Form.Form that contains a WinFormVOWindowHost.
WinFormVOWindow routes keyboard events through the
WinFormVOWindowHost for processing.
Using VO Windows in a .NET Windows Form Application Paul Piko, February 2010 This article shows how to use a VO datawindow in a Vulcan .NET Windows Form application. It makes use of the class WinFormVOWindowHost that connects a VO window to a .NET Windows Form control. WinFormVOWindowHost is typically used to place a DataWindow onto a Panel control that resides on a Form. This example also demonstrates the class WinFormVOWindow, a subclass of System.Windows.Form.Form that contains a WinFormVOWindowHost. WinFormVOWindow routes keyboard events through the WinFormVOWindowHost for processing.
Transport the VO Application Start with a VO application containing dbservers and datawindow. In this example the application is called HostingVO.
Ensure the VO project containing the application is closed. Select Import Visual Objects Application from the Visual Studio Tools menu. Select the project containing the VO application.
Select the application.
Set the name for the new solution.
Complete the transporter wizard to create the solution. Open the new solution.
Create Windows Forms host Right click on the project and select Add, New Item. There are two templates based on the WinFormVOWindow class: "WinForms‐Hosted VO Window" and "WinForms‐Hosted VO Window with Toolbar". The first provides a WinFormVOWindow with a WinFormVOWindowHost component. The second, in addition to the WinFormVOWindowHost, includes a toolstrip with navigation buttons, and a panel control connected to the WinFormVOWindowHost. For this example, we select "WinForms‐Hosted VO Window with Toolbar".
The form with WinFormVOWindowHost, toolstrip and panel is shown in the form designer. References to the necessary assemblies are automatically added to the project.
Select the winFormVOWindowHost component and put the class name of the VO window into VOWindowClassName property.
Change Start The transported VO application automatically uses a VO‐style Start function, found in _Start.prg. Because the goal of this example was to show a VO window running in a Windows Form application we need to change the Start to make use of System.Windows.Forms.Application, as shown below. #using System #using System.Windows.Forms /// /// The main entry point for the application. /// [STAThread] ; FUNCTION Start() AS INT LOCAL exitCode AS INT SetExclusive(FALSE) SetDeleted(TRUE) SetDefault("D:\Test") Application.EnableVisualStyles() Application.SetCompatibleTextRenderingDefault( false ) Application.Run( FormVO1{} ) RETURN exitCode
At this stage the solution can be built and should compile successfully.
Required DLLs The VO application used a number of DLLs to support the databrowser. These are CATO3*.DLL in the VO Redist folder. These are also needed by the .NET application, and need to be copied to folder where the executable was created, the project's Debug folder.
Running the Application The application can now be run and our Windows Form is shown, containing the VO DataWindow. The toolstrip buttons navigate through the file.
Converting to MDI Application Add a new form called Shell to the project, following the earlier steps describing how to add a form. Change the form's IsMdiContainer property to True
Add a menustrip to the form, and create menu items as shown below
Double‐click on the Hosted VO Window item to create the event handler and source code stub. In the code shown below, the original window in instantiated and made an MDI child of the Shell. PRIVATE METHOD hostedVOWindowToolStripMenuItem_Click( sender AS System.Object, e AS System.EventArgs ) AS System.Void LOCAL form AS FormVO1 form := FormVO1{}
form:MdiParent := SELF form:Show() RETURN
The remaining thing to do is change the Start so that it shows the Shell. Application.Run( Shell{} )
Running the application now shows our hosted datawindow within the Windows Form shell.
Additional Notes If the datawindow's controls are not displayed, check that the project is referencing VulcanVOGUIClasses.