Window

(Engine-Level Function)

Description: Opens a new window, starts a module inside, and eventually returns the module's value.
Returns: Module Instance
Usage: Steady State only.
Function Groups: Basic Module,  Window
Related to: SizeWindow | MoveWindow | VStatus | WindowClose | WindowOptions
Format: Window(Left, Top, ViewWidth, ViewHeight, VirtualWidth, VirtualHeight, Module, Style, Title, Color, Enable [, HelpFileName, HelpContext, enableDynamicPositioning])
Parameters:  
Left   
Required. Any numeric expression that gives the left coordinate of the new window. If the new window is a child window, Left is the user coordinate within the window of the calling module. If the new window is not a child window, Left is the number of pixels from the left of the screen.
Top   
Required. Any numeric expression that gives the top coordinate of the new window. If the new window is a child window, Top is the user coordinate within the window of the calling module. If the new window is not a child window, Top is the number of pixels from the top of the screen.
ViewWidth   
Required. Any numeric expression that gives the window width in pixels. The minimum width allowable is based on the operating system in use and the style options of the window (see the Comments section for more details).
ViewHeight   
Required. Any numeric expression that gives the window height in pixels. This value must be greater than or equal to 0.
VirtualWidth   
Required. Any numeric expression that gives the width inside the new window in user coordinates (which may be pixels). If VirtualWidth is larger than the client area specified, a horizontal scroll bar appears.
VirtualHeight   

Required. Any numeric expression that gives the height inside the new window in user coordinates (which may be pixels). If VirtualHeight is larger than the client area specified, a vertical scroll bar appears.

If VirtualWidth and VirtualHeight are both set to 0 (zero) the effective virtual size of the window becomes the size of the monitor the window is within, varying dynamically.

Module   
Required. Any expression that uses a module call. The module will start, and all graphics in the module will draw in the new window.
Style   

Required. Any numeric expression that gives the style of the window when it opens. This parameter has no effect after the window has opened. Style is formed by adding together bit values from the table below.

This parameter can be overridden by the variable PageWinOpt within a page's source code.

(See: Bitwise Parameters & Operations)

Bit Number

Description

0 Enable system close button (if bit 1 is set)
1 Show title bar
2 Thick border, not resizable
3 Thin border, not resizable
4 Enable minimize button (if bit 1 is set )
5 Enable maximize button (if bit 1 is set)
6 Create window minimized
7 Create window maximized (full virtual size)
8 Disable scroll bars
9 Child window
10 Always on top
11 Reserved for future use
12 ModalClosed A modal dialog is always displayed on top of the calling window and prevents further interaction with that window. window (like dialog box)
13 Use pixel coordinates in window (otherwise user coordinates)
14 Use Load statement to size window.
Not supported by the Anywhere client.
15 Owned window
16 Initially inactive window
17 Invokes "automatic" alpha blending, where the window is set to be 50% translucent when inactive and opaque when active.
Not supported by the Anywhere client or on child windows (bit 9 is set).
18 Window is to be rendered as transparent, with whatever color is specified as the background color being the transparent color.
Not supported by the Anywhere client or on child windows (bit 9 is set)
19 Indicates that a WindowClose statement will be associated with this window. See "WindowClose" for more details.
20 Force the window to remain at a fixed aspect ratio
21 Reserved.
22 Window may serve as a drop target for GUITransforms dragged from a palette.
Not supported by the Anywhere client.
23 Window may serve as a palette, from which GUITransforms may be dragged.
Not supported by the Anywhere client.
24 If set along with bit 23, the window that is the source of the object being dragged will hide itself automatically during the drag operation.
25 Hide horizontal scrollbar
26 Hide vertical scrollbar
(Setting both bits 25 and 26 is the same as setting bit 8, disable scroll bars)

Notes on the style settings:

  • The default window (if Style is set to 0) has a thick border and is resizable.
  • If bit 1 is not set, the title bar is not shown, and bits 0, 4 and 5 have no effect.
  • If bits 2 and 3 are both set, there will not be a border unless bit 1 is set, in which case there will be a thin border. If neither bit 2 nor bit 3 is set, the border will be a resizable thick border.
  • Bits 4 and 5 specify whether minimize and maximize buttons are disabled, rather than specifying whether they are visible (both the minimize and maximize buttons will be either visible or not visible). Furthermore, these options have no effect without bit 0 being set (except under Windows NT 3.51). The system close button must be enabled for the user to have any control over the minimize and maximize buttons.
  • Setting bit 8 disables the scroll bars that are normally shown if the window has been resized (smaller). In this case, the entire window must be enlarged to its original size if you wish to view its contents.
  • Bit 9 (child window) specifies a "window within a window". The new window is another graphic object within the calling window and is truncated by the borders of the parent window. This means that as the parent window is dragged, the child stays on top of the parent window in the same position within and relative to the parent's borders. If the parent window is minimized, then the child window is also minimized. Child windows do not produce status line title-windows. It is impossible to make a window a child window if the Window statement is in a module that isn't running in a window already. A child window is always an owned window.
  • Setting bit 12 means that the window will take all of the input until closed. Care should be taken when using this option in conjunction with bit 14 (size based on load). A problem will occur if the load file cannot be found, and the window will not show up but will still be modal. The result is that the system will take no input until the window is closed.
  • Setting bit 14 hides the window until a Load statement is executed in Module. The window is then opened in the size required to display the loaded image.
  • Bit 15 (owned window) creates a window that is always in front of the calling window. Unlike child windows, which are controlled by their parents, owned windows are not restricted by their owner's boundaries, nor does the movement of the parent window change their position. The exception to this, however, is that if the owning window is minimized, the owned window will also be minimized. Owned windows do not produce status line title-windows. Although all child windows are owned, not all owned windows are child windows.
  • Bit 17. An alpha-blended window is one that has an alpha channel set up in the final renderer, resulting in a translucent effect to the window (i.e. it behaves like a normal window, except that you can see through the window to some degree. The degree of translucency ranges from zero (invisible) to 255 (completely opaque, just like a normal window). Setting bit 17 on your Window statement invokes "automatic" alpha blending, where the window is set to be 50% translucent when inactive and opaque when active. This is useful for dialogs that are non-modal and always on-top, so that when another window is active, you can see through to the underlying windows. If you need a finer degree of control on this, do not set bit 17, but use a new value for the "Option" parameter of WindowOptions (9) and set the WindowOptions "OptValue" parameter to the degree of alpha-blending that you wish (0 to 255). Note that these effects DO NOT work with child windows. Also note that these effects are NOT designed for animation purposes are not sufficiently efficient for this. The amount of processing power required to redraw one of these windows depends on the rating of the graphics card in your machine. The newer and faster the better.
  • Bit 18. A transparent window is one that has a transparent background. The intended use for this is to allow the display of non-rectangular windows, by rendering the background as transparent and allowing mouse messages (movement and clicks) to "drill-through" the transparent area. The simplest way to create a transparent window is to specify a background color less than zero (-1, for example). The underlying implementation, however, requires that a specific color is used as a "key" color. All pixels of that color in the otherwise rectangular screen area that the window occupies are rendered as transparent. Using a background color of < 0 results in the key color being black [i.e. RBG(0, 0, 0)] and the window background being set to that color. It may well be that you wish to have black as a color in your window, however. Therefore, setting bit 18 in the Window statement also announces that this window is to be rendered as transparent, with whatever color is specified as the background color being the transparent color.
  • A WinXLoc/WinYLoc statement for the new window registers the values for the parent window when the mouse is over the parent and not itself, and will register the values for itself when the mouse is over it. The same is also true for the parent (it will see the values for the child window when the mouse is over the child).
  • Bits 22 and 23 are mutually exclusive. A window cannot be both a palette and a drop-target.
Title   
Required. Any text expression that gives the window title.
Color   
Required. Any numeric expression that gives the background color of the window's client area when the window opens.
If set to -1, then the resulting window will be transparent, as will anything drawn in black (RGB 0, 0, 0) upon it. Not supported by the Anywhere client or on child windows (bit 9 is set).
This parameter has no effect after the window has opened.
Any of the following may be used:
Enable   
Required. Any logical expression. If true, the window opens and Module starts. If false, the window is closed and Module is stopped.
HelpFileName   
Optional file name of the help file to use if the user presses F1 while this window is the active window. If absent or invalid when the user presses F1, the parent window will be checked for a file name. This continues recursively until the top of the window tree is reached.

If no help file name is found, the default help file is used. The default help file can be set through the Setup.ini variable WEBHelp, or by using the EnableHelp statement.
HelpContext   
Optional help context. If absent or invalid, but the HelpFileName is valid, then the "finder" dialog for help is displayed when the user presses F1. If valid and numeric, the help file is searched for a matching topic number and help is displayed for that topic.
If valid and textual, the help file is searched for an exact match on the text string among the topic index of the help file. If there is more than one text match, the index is positioned at the first partial string match.
If valid but a topic match is not found (neither textual nor numeric), the same action as an Invalid HelpContext is taken. If the HelpFileName parameter is Invalid, this parameter is ignored.
enableDynamicPositioning
An optional parameter that, when set to TRUE, will cause the window position to be updated if the window is a child window inside a GUITransform that moves, or if the LEFT or TOP parameters change. Set to FALSE by default.
RibbonName
Optional text string, identifying the ribbon. See comments.
RibbonState

Optional. A retained variable name, holding the persisted state of the ribbon. The persisted state is an XML snippet generated internally by the Microsoft ribbon API and is opaque to VTScada script code.

The retained variable is typically set in the destructor for the module instance the Window statement runs.

Comments:

This function returns the value returned by Module.

When a window is maximized, its maximized size is not based on the size of the screen, although for many commercial applications the two are the same, but rather, its full size is defined by the fifth and sixth parameters, namely virtual width and height. If the view area and the virtual area of the window have been defined to be the same, selecting the maximize button will appear to have no effect.
The minimum size of a window is based on the operating system under which the application is running, as well as the attributes of the window itself as defined by the Style parameter. The width need only be greater than or equal to 0. Window heights similarly need only be greater than or equal to 0.
GUITransform functions may make use of VStatus to inquire about the boundaries of the window they are within.

A window can be turned into a drag and drop target by adding the callback modules, OLEDrag and OLEDrop. Further details can be found in the chapter, Create Windows & Use Graphics Functions.

If a ribbon is to be associated with this window, then the ribbon must be instantiated at the same time that the window is created, using the two optional parameters, RibbonName and RibbonState.

Ribbons are compiled into resources, using Microsoft Visual Studio. The resources can then be linked directly into VTS.EXE (Trihedral use only) or into an external DLL. This allows multiple ribbons to be provided in separate DLLs. You can have more than one ribbon in VTS.EXE or a DLL.

RibbonName is of the form "dllname|ribbonname", being the name of the DLL, a vertical pipe symbol and the name of the ribbon resource within the DLL. If the ribbon is compiled into VTS, the dllname and the pipe separator character are omitted.

If adding a ribbon to a window, and if there is a chance that the window will be maximized, you should use the window's virtual width and virtual height as follows:

Window(0, 0, 1024, 768,
       VStatus(Self(), 26), VStatus(Self(), 27) + VSTatus(Self(), 23), ...

The virtual height in particular is important as otherwise there will be a gap at the bottom of the window (normally, eight pixels) that is the size of the frame height.

Example:

  Window(  0,   0           { Upper left corner   },
         800, 600           { View area           },
         800, 600           { Virtual area        },
         Graphics()         { Start user graphics },
         {65432109876543210}
        0b00010000000110011, "Sample Window", 0, 1);

This statement will open a window, and run the module Graphics() in it.

Windows, Pages, and Graphics - A collection of best practices and related information.