%DOTNET_TKWIN
Create a container window and embed a form, control, or element
WSupported on Windows
|
|
|
|
window_id = %DOTNET_TKWIN(name, height, width, object[, flags])
Return value
window_id
On Windows, the Toolkit container window ID. On Unix and OpenVMS, returns 0. (^VAL)
Arguments
name
The name of the Toolkit container window to create. This can be up to 15 characters. If you specify a null string (“”), Toolkit assigns a unique window name in the form _W_nnn, where nnn is the window ID. (a)
height
The height of the window in character rows. If you pass either height or width as 0, Toolkit sets the window to the height and width of the application screen. (n)
width
The width of the window in character columns. If you pass either height or width as 0, Toolkit sets the window to the height and width of the application screen. (n)
object
The .NET form, .NET control, or WPF element to embed. This must be derived from System.Windows.Forms.Form, System.Windows.Forms.Control, or System.Windows.UIElement and wrapped in a Synergy class (i.e., as a DotNetObject) by gennet40. (@DotNetObject)
flags
(optional) Pass DN_MAKEFORM to instruct %DOTNET_TKWIN to create a .NET form for a .NET control (object must be a .NET form or control or null). Pass DN_WPF to instruct %DOTNET_TKWIN to create a .NET form for a WPF element (object must be a WPF element or null). Although you can combine these bit flags with .BOR. or the vertical bar (|) operator (for a WPF element), this is not necessary because DN_WPF includes DN_MAKEFORM. (n)
%DOTNET_TKWIN enables you to embed a .NET form, .NET control, or WPF element in a Toolkit application. To do this, it creates a Toolkit container window and, optionally, it creates a .NET form to contain the form, control, or element passed as object. (On Unix and OpenVMS, this function returns zero, but otherwise does nothing.)
- To add a .NET form, pass the form as object, and omit the flags argument (unless you want the form to be treated as a .NET control and be added to an automatically-created .NET form).
- To embed a .NET control or a WPF element, pass the control or element as object and pass flags as DN_MAKEFORM (for a .NET control) or DN_WPF (for a WPF element). (If you want to add a .NET control or a WPF element to an already-embedded .NET form, use DOTNET_TKADDCTL.)
Before you pass a .NET form, .NET control, or WPF element as object, you must wrap it in a Synergy class using gennet40. (See Embedding a .NET form.) Otherwise Toolkit throws an exception.
If you pass DN_MAKEFORM or DN_WPF, this function creates a Toolkit container window with an embedded .NET form. If object is null, the .NET form will be empty. If object is non-null, Toolkit embeds object as a control in the Toolkit-created .NET form (even if object is a .NET form). Object is added to the Controls collection for the Toolkit-created form. Object is sized and positioned to fill the form; you can subsequently resize and move object by modifying the Toolkit-created form.
If you don’t pass flags (or if you pass it as a value other than DN_MAKEFORM or DN_WPF) and object is null, this function creates a Toolkit container window with an embedded .NET form. If object is non-null, it creates a Toolkit container window, but it doesn’t create a .NET form. Instead, Toolkit embeds object (which must be a .NET form) in the container window.
- The embedded .NET form is not sized automatically, meaning that the form may be cropped or portions of the Toolkit container window may be visible on the bottom or right of the .NET form. To adjust this, query and set the width and height properties of the .NET form.
- When a .NET form is embedded in a Toolkit container window, the frame around the .NET form is turned off, and the Toolkit container window becomes the parent window of the form’s outermost window. (And when the container window is deleted, the .NET form’s style is set to WS_POPUP, and its parent window is set to null.)
%DOTNET_TKWIN creates a container window by calling W_PROC. and passing name, rows, and cols. If W_PROC generates an error, you can trap it. Note that the container window is logged with Toolkit at the current environment level. You can use U_GBLWND to promote it to global.
When a user clicks on an embedded .NET form, that event does not automatically trigger a call to any UWNDEVENTS_METHOD associated with the Toolkit container window. To trigger Windows event processing, the .NET form must fire an event of its own.
See the DOTNET_TKADDCTL Examples.