|
|
|
|||||||||||||||||||||
Requirements |
|||||||||||||||||||||
|
|||||||||||||||||||||
Using This Sample Program |
|||||||||||||||||||||
|
This sample is different from many of the others in that the sample for each development environment is slightly different. Even if you don't "speak" the other languages, it may be worthwhile to look at each version to see different ways to use dynamic creation of components in your application.
|
|||||||||||||||||||||
Download this Sample Program |
|||||||||||||||||||||
For Use TeleTools v3.7
|
|||||||||||||||||||||
How this Sample Program Works |
|||||||||||||||||||||
|
The code for this sample is very simple. In VB 5 and 6, we use the "load" function in to dynamically create components at runtime like this: etLineCount = etLineCount + 1 and to "UNLOAD" or destroy the component: Unload etLine(etLineCount - 1) This code, placed in a button, will create a new etLine component every time the button is pressed. In your own code, you would just use a loop with an index variable to increment your count for however many lines you need. Remember to enable the components and remember to destroy them when done! Here is another way to do it that does not require any component to be dropped on the form. You must have TeleTools installed in your components list first, so it can find the appropriate references. In addition, you must go into the project options ( Project | Properties | Make Tab) and UNCHECK "Remove information about unused ActiveX controls". Then just use this code: NOTE: Make sure to use the right version for your component, etTT36.etLIne, etTT37.etLine, etTT40.etLine, etc. General Section: Option Explicit Form_Load or Event of your choice: Set myetLine = Controls.Add("etTT40.etLine", "myetLine") and in Form_Unload clean things up: myetLine.DeviceActive = False In VBA (Visual Basic For Applications) or VB, yet another way: General Section: Public WithEvents etLine1 As etTT37.etLine Form_Load or Event of your choice: Set etLine1 = New etTT37.etLine In Delphi the code would look like this: NewetLine := TetLine.Create(Self); and to destroy the component... NewetLine.Destroy; In C++ this is the code: NewetLine = new TetLine((TComponent *) this); delete NewetLine; In VB.Net it looks like this: etLine(i) = New AxetTT37.AxetLine()Controls.Add(etLine(i)) Controls.Remove(etLine(i)) In VB.NET, you will need to do it this way if you want to create the components in the form_load event: CType(Me.etLine(iLine),
System.ComponentModel.ISupportInitialize).BeginInit() And to make programming easy and use one event handler called by multiple components, you can add this: AddHandler etLine(i).OnCallerID, AddressOf etLine_OnCallerID
Be sure to look at the sourcecode and it's detailed help
embedded in the source. Let us know if you have any questions!
NOTE: Since there is great variety between versions, this is only a general indication of the Controls and events used in the program. Download and view the source for the program or programs in the development environment of your choice.
|
|||||||||||||||||||||
Release Notes |
|||||||||||||||||||||
August 15, 2003Add VB.NET version, enhance Delphi version and make minor cosmetic changes to all versions. July 1, 2002First release |
|
|
||||
|
||||