DOTNET_TKADDCTL
Add a form, control, or element to a previously-embedded form
WSupported on Windows
|
|
|
|
xcall DOTNET_TKADDCTL(window_id, object[, flags])
Arguments
window_id
The ID of a window created by %DOTNET_TKWIN. (Otherwise Toolkit throws an exception.) (n)
object
The .NET form, .NET control, or WPF element to add. This must be derived from System.Windows.Forms.Form, System.Windows.Forms.Control, or System.Windows.UIElement. If object is null or does not wrap a .NET form, .NET control or WPF element, Toolkit throws an exception. (@DotNetObject)
flags
(optional) Pass as DN_WPF if object is a WPF element; otherwise omit this argument. (n)
Discussion
DOTNET_TKADDCTL adds a .NET form, a .NET control, or a WPF element to the Controls collection for a previously embedded .NET form (contained in window_id), but it does not adjust its size or position. (On Unix and OpenVMS, this routine merely returns.)
To add a WPF element, pass flags as DN_WPF. If you pass flags as DN_WPF, object must be a WPF element (i.e., it must be instantiated from a class derived from System.Windows.UIElement); otherwise a DotNetException will be thrown.
See also
%DOTNET_TKWIN routine for information on embedding a .NET form in a Toolkit window
This example adds two .NET controls (a label and a field) to a composite window and processes the composite window. Toolkit automatically creates a .NET form for the controls. See step 1 of Embedding a .NET form.
.include "MyForm.inc" ;Include the .inc file generated by gennet40. main .include "WND:tools.def" record wndid ,i4 ctrid ,i4 ctl ,@TextBox lbl ,@Label form ,@DotNetObject proc xcall u_start ctrid = %c_container(DC_CREATE, "", 20, 78) ;Create composite window ;Create Toolkit container window and empty .NET form. (If you pass ; the <object> argument as null, Toolkit creates a .NET form, ; regardless of the <flags> setting.) wndid = %dotnet_tkwin("", 18, 78, ^null) xcall dotnet_tkform(wndid, form) ;Make sure form was created. if (form == ^null) throw new System.NullReferenceException() lbl = new Label() ;Instantiate a Label object. lbl.Text = "Label1: " ;Set Text property for Label object. xcall dotnet_tkaddctl(wndid, lbl) ;Add Label to the automatically- ; created .NET form. ctl = new TextBox() ;Instantiate a TextBox object. ctl.Text = "Lorem ipsum..." ;Set Text property of TextBox object. xcall dotnet_tkaddctl(wndid, ctl) ;Add TextBox to the automatically- ; created .NET form. ctl.Left = lbl.Left + lbl.Width + 10 ;Set TextBox position & width. ctl.Width = %u_winmetrics(D_CHARWIDTH, wndid) * 30 ; Add and place .NET form. xcall c_container(DC_ADD, ctrid, DC_WINDOW, wndid, 1, 1) xcall u_window(D_PLACE, ctrid, 1, 1) ;Process composite window. Default method for .NET form window ; (C_METHNET) will call DOTNET_TKINPUT. xcall c_process(ctrid) xcall u_finish endmain