DAQFactory normally has just one Main window, however, you can create multiple windows or popups to display your pages. The windows can either be "Modal", which means you can only interact with that window while it is open, or "Modeless" which means you can interact with that window as well as other windows including the main DAQFactory window. Modal windows are typically used for popups for data entry, like a form, or a request for login information. Modeless windows allow you create several concurrent and independent views of your application, and are especially useful in multi-monitor systems.
When you start DAQFactory there is a single window called Main. You can add additional windows by using:
window.add(newWindowName)
Like pretty much all DAQFactory names, newWindowName has start start with a letter and contain only letters, numbers or the underscore. Adding a new window doesn't actually show it, but adds it to the list of available windows. You typically will then adjust the settings of that window using the variables listed below, then call either ShowModal() or ShowModeless() to actually display the window. You can then call Hide() to close the window. Hiding the window doesn't destroy the window though, so you can always call ShowModal() or ShowModeless() again to make the window appear. For example, to create a modeless popup window for Page_1, you might do:
window.add("Page_1_Popup")
window.Page_1_Popup.CurrentPage = "Page_1"
window.Page_1_Popup.ShowModeless()
In addition to any windows you create and the Main window, there is a "virtual" window called Active. This simply refers to whichever window is currently the active window in DAQFactory, the one you last interacted with. The primary purpose of this "window" is to allow screen controls to change the parameters of the window they are currently being displayed in, especially the CurrentPage variable. So, if our Page_1 in the above example had a button to switch to Page_2, the script for the click event would be:
window.Active.CurrentPage = "Page_2"
We could have done window.Page_1_Popup.CurrentPage = "Page_2", but that would only work to change the page for our Page_1_Popup window. If you then displayed Page_1 in a different window, say Main, instead of changing the page in Main, it would change the page in Page_1_Popup. There certainly are cases where this is desired, but in most cases you'll want to use Active.
As you have probably noticed, all the functions involving windows start with the word window. This object holds all the windows you have created, along with Main and the virtual Active window. It supports one function:
Add(newWindowName): this function adds a new window to the list of windows available. newWindowName is a string with the desired name for the new window. If the window already exists, nothing will happen. The existing window will not be affected and no new window is created. For example:
window.add("myWindow")
Individual windows have a number of properties. All of them will start with window.myWindow. where myWindow is the name of the window you wish to configure. These properties only affect the specified window allowing you to individual control what and how each window is displayed.
The first few are supported by all windows including Main:
CurrentPage: the contains a string with the page(s) being displayed in the window. You can overlaid pages by listing all the desired pages in the string separated by commas. For example:
window.Active.CurrentPage = "MenuPage,Detail"
Scaling: the scaling factor used to display the content if AutoScale is not enabled. A value of 1 is original size, with smaller values resulting in a smaller interface:
window.Active.Scaling = 0.8
AutoScale: if true the system will use the ContentWidth and ContentHeight values and the size of the window to determine the best fit scaling factor. You must specify ContentWidth and ContentHeight for AutoScale to function.
ContentWidth: the width, in pixels, of the contents of the window. This is only used and required for the AutoScale feature
ContentHeight: the height, in pixels, of the contents of the window. This is only used and required for the AutoScale feature
LastInteractionTime: contains a timestamp containing the last time the page was interacted with, either with the keyboard, mouse move or mouse click. This is primarily designed to allow you to implement an auto-logout feature in your application. To give you more fine control, there are three additional variables that give more specific time stamps: LastKeyPressTime, LastMouseClickTime, and LastMouseMoveTime.
LastPageDrawTime: returns the amount of time, in seconds, that it took to render the page. Note that this number will be slightly smaller than the one displayed in the status bar as that one includes a few extra rendering steps for the general DAQFactory user interface.
The rest are only supported by user created windows because the Main window can't be popped up:
BorderVisible: determines if a border is drawn around the popup window. Whether this works and how is affected by the current Windows theme settings.
NoClose: if true, then the X at the top right of the window will not function and the window can only be closed through script you provide, for example in your own Close button. Be careful when using this with Modal dialog boxes. If you do not provide your own way to close the popup, you will not be able to close it, nor will you be able to interact with the rest of DAQFactory, including the ability to save your document. We suggest, therefore, leaving this disabled until you are sure you can close the window from your user interface.
Resizeable: if true, then the user can resize the window by dragging the corners, just like any other Windows window.
Title: the title displayed at the top of the window.
TitleBarVisible: if false, then the title bar is not displayed. Like NoClose, you will want to be careful hiding the title bar as the normal windows X will also be hidden. If you do not provide a way to close a modal window from your user interface you could get stuck.
User created windows also support a number of functions. Again, these are not supported by the Main window because it can't be popped up:
ShowModal([Current Page]): displays the window as a modal window. When a modal window is displayed, you cannot interact with any other windows in DAQFactory. You can optionally provide a string with the desired page(s) to display. This sets the CurrentPage variable.
ShowModeless([Current Page]):displays the window as a modeless window. Modeless windows are separate windows that you can interact with at the same time as the main window and other modeless windows. You can optionally provide a string with the desired page(s) to display. This sets the CurrentPage variable.
Hide(): hides the window from view. The position of the window is saved so the next Show...() function will display the window in the same place unless you move it using the functions below.
WaitForClose(): causes the current script to wait until the window has closed. This is usually used for popup windows that return information to the calling script. For example a popup window requesting login information. The script would display the window then wait for the window to close before processing what the user entered. This is usually only used with Modal windows. Note that while this function will block the existing script from running, it can safely be called from component events.
Center(): centers the window on the main monitor. You can call this before the Show...() function call to position the window before displaying it, or you can do it afterwards.
GetPosition(): returns the current position of the window in the coordinate system defined by Windows. Usually the top left corner of your main monitor is 0,0 with positive values going down and to the left, much like component coordinates inside DAQFactory. If you have multiple monitors to the left or above the main monitor they will have negative coordinates. This returns the coordinates as a two dimensional array, much like component coordinates.
SetPosition(left,top,right,bottom):
SetPosition({{left, top},{right, bottom}}): sets the position of the window using the coordinate system defined by Windows. You have two choices in how you specify the coordinates. You can provide 4 parameters for the left, top, right and bottom positions, or a single parameter as a two dimensional array with the coordinates. This second format is the same format that GetPosition() returns.
UpdateEdits():
This function causes all the editing type screen controls to update with their current value based on the output target. Because DAQFactory could change a value that one is in the process of editing, it does not automatically update edit type controls, i.e. Edit Boxes, Date/Time select, Combo boxes, etc. with the current value of the output channel like it would, say, a Variable Value component. This is to allow for the operator to get a chance to edit the value before it gets changed somewhere else. To force the component to update the displayed value to the value of the output target, call this function.
The ability to create multiple independent windows in DAQFactory is new as of release 20. Older versions of DAQFactory supported popups, but you could only create a popup that showed a particular page and was quite limiting. For backwards compatibility the following functions / variables will still work, but map to the new windows features as described.
Note: You should not use these functions / variables for new applications or script. They are only for backwards compatibility.
(myPage below refers to the name of the page you are calling the function / access the variable on):
Page.myPage.PopupModal([No Close],[Top],[Left],[Bottom],[Right]): when called this function will create a new window object with the name "Page_myPage", set the NoClose variable and position (if provided) and call ShowModal() on it. So, for example:
Page.Page_1.PopupModal()
will do:
window.Add("Page_Page_1")
window.Page_Page_1.ShowModal()
Page.myPage.PopupModeless([No Close],[Top],[Left],[Bottom],[Right]): when called this function will create a new window object with the name "Page_myPage", set the NoClose variable and position (if provided) and call ShowModeless() on it.
Page.myPage.ClosePopup(): when called this function will find the window object named "Page_myPage" and call Hide() on it. So for example Page.Page_1.ClosePopup() will simply call Window.Page_Page_1.Hide() internally.
Page.myPage.WaitForClosePopup(): when called this function will find the window object named "Page_myPage" and call WaitForClose() on it.
Page.strCurrentPage: this will set the currently displayed page for the Main window only. So, internally, Page.strCurrentPage = "Page_1" will actually do Window.Main.CurrentPage = "Page_1"
Page.Scaling: this will set the scaling for the Main window only. So, internally, Page.scaling = 0.8 will actually do Window.Main.Scaling = 0.8