Introduction, NkDialog_AddColumn, NkDialog_AddControl, NkDialog_AddControlEx, NkDialog_AddMacroMessageHandler, NkDialog_AddRemoveOptions, NkDialog_AddRow, NkDialog_Create, NkDialog_FindControl, NkDialog_SendMessage, NkDialog_SendMessageString, NkFile_Append, NkFile_BrowseForFolder, NkFile_FindClose, NkFile_FindFirstFile, NkFile_FindNextFile, NkFile_GetOpenFileName, NkFile_Write, NkLsEdit_GetFlags, NkLsEdit_GetValue, NkLsEdit_SetFlags, NkLsEdit_SetFormat, NkLsEdit_SetRange, NkLsEdit_SetScale, NkLsEdit_SetUnit, NkLsEdit_SetValue, NkPMTGainEdit_AttachToHighVoltage, NkPMTGainEdit_IsNkPMTGainEditWindow, NkPMTGainEdit_SetCalibration, NkProgressBar_SetCompletionText, NkWindow_DestroyWindow, NkWindow_FindWindow, NkWindow_FindWindowByText, NkWindow_FindWindowDeep, NkWindow_GetMainWindow, NkWindow_GetMainWindowNext, NkWindow_GetParent, NkWindow_GetWindow, NkWindow_GetWindowLong, NkWindow_GetWindowPos, NkWindow_GetWindowRect, NkWindow_GetWindowSize, NkWindow_PostMessage, NkWindow_SendKeyboardInput, NkWindow_SendMessage, NkWindow_SendMessagePointer, NkWindow_SendMessageString, NkWindow_SendMouseInput, NkWindow_SetForeground, NkWindow_SetWindowLong, NkWindow_SetWindowPos, NkWindow_SetWindowRect, NkWindow_SetWindowSize, NkWindow_ShowWindow
Description
Introduction();
The commands in the NkWindow.dll library implement creation of a custom dialog with controls. User interaction with the controls can trigger execution of macro functions. Run the macro ~nis\macros\NkWindow.mac to load the library in NIS. The example macros ~nis\Examples\NkPropSheetDemo.mac and ~\nis\Examples\NkWindowDemo.mac illustrate how to create a dialog and assign macros to handle the control notifications. To create a custom dialog, save the file NkPropSheetDemo.mac under a new name; replace the PSD_ prefix with another distinctive acronym and modify the dialog template definition. Most NkWindow commands relay to standard win32 API functions. Documentation for the win32 API is found here: https://learn.microsoft.com/en-us/windows/win32. The NkWindow.dll library includes commands for file operations: writing, appending, browsing and finding files and folders.
Example:
# a fragment from ~nis\Examples\NkPropSheetDemo.mac int main() { if(!ExistProc("NPS_ShowPropertyDialog")) { RunMacro("c:/Program Files/NIS-Elements/macros/NkWindow.mac"); RunMacro("c:/Program Files/NIS-Elements/macros/NkPropSheet.mac"); } PropSheetDemo_ShowDialog(0) }
Description
NkWindow_GetMainWindow( char *title
, char *szMainWindowClass
, long *phMainWindow
);
Returns the window handle of the first top level window that matches the specified title and class. The main window can be specified as parent in the call to NkWindow_Create().
Example: long hNIS; NkWindow_GetMainWindow("NIS-Elements","lxMDIClient",&hNis);
Parameters
Description
NkWindow_GetMainWindowNext( char *title
, char *szMainWindowClass
, long *phNextMainWindow
);
Returns the window handle of the next top level window that matches the specified title and style. The variable pWnd should be initialized by NkWindow_GetMainWindow().
Parameters
Description
NkWindow_FindWindow( longhParentWnd
, char *szChildWindowClass
, char *szChildWindowTitle
, long *phChildWindow
);
Finds a child window of the hWnd window with the specified title and class.
Parameters
Description
NkWindow_FindWindowDeep( longhParentWnd
, char *szChildTitleOrClass
, long *phChildWindow
);
Finds a (grant) child window of the hWnd window with the specified title or class.
Description
NkWindow_FindWindowByText( longhParentWnd
, char *szChildTitle
, long *phChildWindow
);
Finds a (grant) child window of the hWnd window with the specified title.
Description
NkWindow_GetWindow( longhWnd
, longuGetWindowCmd
, long *phWnd
);
Returns the window handle of the window with the specified relation to the hWnd argument by calling the win32 API function. The uCmd argument constants are defined in the macro file win32.mac.
Parameters
uGetWindowCmd
The relationship between the specified window and the window whose handle is to be retrieved. This parameter can be one of the following values:
The retrieved handle identifies the child window at the top of the Z order, if the specified window is a parent window; otherwise, the retrieved handle is NULL. The function examines only child windows of the specified window. It does not examine descendant windows. | |
The retrieved handle identifies the enabled popup window owned by the specified window (the search uses the first such window found using GW_HWNDNEXT); otherwise, if there are no enabled popup windows, the retrieved handle is that of the specified window. | |
The retrieved handle identifies the window of the same type that is highest in the Z order. If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. | |
The retrieved handle identifies the window of the same type that is lowest in the Z order. If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. | |
The retrieved handle identifies the window below the specified window in the Z order. If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. | |
The retrieved handle identifies the window above the specified window in the Z order. If the specified window is a topmost window, the handle identifies a topmost window. If the specified window is a top-level window, the handle identifies a top-level window. If the specified window is a child window, the handle identifies a sibling window. | |
The retrieved handle identifies the specified window's owner window, if any. |
Description
NkWindow_GetParent( longhWnd
, long *phParentWnd
);
Returns the window handle of the parent window of the specified window.
Description
NkWindow_GetWindowLong( longhWnd
, longuGetWindowLongIndex
);
Returns the windows property value on position “index” of the window by calling the win32 API function GetWindowLong. Check the win32 documentation of GetWindowLong for more details.
Return value: The value of the property.
Description
NkWindow_SetWindowLong( longhWnd
, longuSetWindowLongIndex
, longuSetWindowLongValue
);
Sets the windows property value on position “index” of the window by calling the win32 API function SetWindowLong. Check the win32 documentation of SetWindowLong for more details.
Description
NkWindow_DestroyWindow(
long hWnd
);
Destroys the window by calling the win32 API function DestroyWindow(). Use this function only for windows created with NkDialog_Create() and NkDialog_AddControl().
Description
NkWindow_ShowWindow( longhWnd
, longnShowCmd
);
Shows or hides the window by calling the win32 API function ShowWindow(). The nShowCmd argument constants are defined in the macro file win32.mac.
Parameters
nShowCmd
The show command. This argument can have the following values:
Hides the window and activates another window. | |
Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time. | |
Activates the window and displays it as a minimized window. | |
Activates the window and displays it as a maximized window. | |
Displays a window in its most recent size and position. This value is similar to SW_SHOWNORMAL, except that the window is not activated. | |
Activates the window and displays it in its current size and position. | |
Minimizes the specified window and activates the next top-level window in the Z order. | |
Displays the window as a minimized window. This value is similar to SW_SHOWMINIMIZED, except the window is not activated. | |
Displays the window in its current size and position. This value is similar to SW_SHOW, except that the window is not activated. | |
Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window. | |
Sets the show state based on the SW_ value specified in the STARTUPINFO structure passed to the CreateProcess function by the program that started the application. | |
Minimizes a window, even if the thread that owns the window is not responding. This flag should only be used when minimizing windows from a different thread. |
Description
NkWindow_SendMessage( longhWnd
, longuMsg
, longwParam
, longlParam
);
Sends a win32 message to the window using the win32 API function SendMessage(). Check out the win32 SendMessage documentation for the arguments.
Description
NkWindow_SendMessageString( longhWnd
, longuMsg
, longwParam
, char *szlParam
);
Use this command to send a message to a window for messages that have string pointer as lParam argument.
Description
NkWindow_SendMessagePointer( longhWnd
, longuMsg
, longwParam
, byte *pblParam
);
Use this command to send a message to a window for messages that have byte pointer as lParam argument.
Description
NkWindow_PostMessage( longhWnd
, longuMsg
, longwParam
, longlParam
);
Sends a win32 message to the window using the win32 API function PostMessage(). Check out the win32 PostMessage documentation for the arguments.
Description
NkWindow_GetWindowRect( longhWnd
, long *left
, long *top
, long *right
, long *bottom
);
This command returns the position of all sides of the window.
Description
NkWindow_SetWindowRect( longhWnd
, longleft
, longtop
, longright
, longbottom
);
This command sets the position of all sides of the window.
Description
NkWindow_SetWindowPos( longhWnd
, longleft
, longtop
);
This command sets the position of the window.
Description
NkWindow_GetWindowPos( longhWnd
, long *left
, long *top
);
This command returns the position of the window.
Description
NkWindow_GetWindowSize( longhWnd
, long *width
, long *height
);
This command returns the size of the window.
Description
NkWindow_SetWindowSize( longhWnd
, longwidth
, longheight
);
This command sets the size of the window.
Description
NkWindow_SetForeground(
long hWnd
);
This command moves the window to the foreground by calling the win32 API function SetForeGround().
Description
NkWindow_SendMouseInput( longx
, longy
, longuSendMouseInputData
, longuSendMouseInputFlags
);
This command mimics a mouse input action with the specified conditions. Check the win32 API function SendInput() with the INPUT_MOUSE for more details.
Description
NkWindow_SendKeyboardInput( longuVirtualKey
, longuScanCode
, longuSendKeyboardInputFlags
);
This command mimics a keyboard input action with the specified conditions. Check the win32 API function SendInput() with the INPUT_KEYBOARD for more details.
Description
NkDialog_Create( longhDialogParent
, char *Title
, long *phDlg
);
This command creates a modeless dialog to which controls can be added using NkDialog_AddControl and NkDialog_AddControlEx. See the macro “NkWindowDemo.mac” in the ~nis\Examples folder illustrates the use of this function.
Description
NkDialog_AddRemoveOptions( longhDlg
, dworddwDialogOptionsToAdd
, dworddwDialogOptionsToRemove
);
This command adds or removes option flags from the dialog. The NKD_AUTONEXTROW can be removed to add controls to the same line (using the “left” parameter to position them right of the previous control). When the NKD_AUTONEXTROW flag is removed, the function NkDialog_AddRow() must be called to position new controls on the next line.
Parameters
Description
NkDialog_AddRow(
long hDlg
);
By default the dialog option NKD_AUTONEXTROW is active and each new control is position on a new line. After removing the option NKD_AUTONEXTROW, new controls are positioned on the same line. Call NkDialog_AddRow() to position the next control on a new row.
Description
NkDialog_AddColumn(
long hDlg
);
The NkDialog_AddControl command adds a control from top to bottom. Call NkDialog_AddColumn to position the next control on a new column.
Description
NkDialog_AddControl( longhDlg
, char *szControlID
, char *szControlClass
, longuControlStyle
, longlControlLeftOrHeight
, longlControlWidth
, long *phCtrl
);
This commands adds a control to a dialog created by NkDialog_Create(). See the macro “NkWindowDemo.mac” in the ~nis\Examples folder illustrates the use of this function. Controls are added from top to bottom. Call NkDialog_AddColumn to move to the next column.
Parameters
szControlID
The identifier of the control, that can be used with FindControl() to get the handle of the control.
szControlClass
The class name of the control. All standard win32 control classes are supported. In addition the NkWindow library implements these control classes:
EDIT control for numbers in a range. Check the NkLsEdit_ commands for specifying the range, scale, format, unit and other options. | |
SCROLLBAR that connects to the previously created “NkLsEdit” control. | |
“msctls_progress32” control that supports automatically counting up or down and can show a text on completion. Set a timer with ID to count up; set a timer with ID 2 to count down. Use the command NkProgressBar_SetCompletionText() to set the completion text. | |
a “NkLsEdit” control that implements the double logarithmic relation between PMT High Voltage and gain. Check the NkPMTGainEdit_ functions for details. |
uControlStyle
The style options for the control. Check the documentation of the win32 control class for available style options. The styles WS_VISIBLE and WS_CHILD are automatically added when creating the control.
Description
NkDialog_AddControlEx( longhDlg
, char *szControlID
, char *szControlClass
, longuControlStyleEx
, longlControlLeftOrHeight
, longlControlWidth
, long *phCtrl
);
This commands adds a control with an extra style to a dialog created by NkDialog_Create(). See the macro “NkWindowDemo.mac” in the ~nis\Examples folder illustrates the use of this function. Controls are added from top to bottom. Call NkDialog_AddColumn to move to the next column.
Parameters
szControlID
The identifier of the control, that can be used with FindControl() to get the handle of the control.
szControlClass
The class name of the control. All standard win32 control classes are supported. In addition the NkWindow library implements these control classes:
EDIT control for numbers in a range. Check the NkLsEdit_ commands for specifying the range, scale, format, unit and other options. | |
SCROLLBAR that connects to the previously created “NkLsEdit” control. | |
“msctls_progress32” control that supports automatically counting up or down and can show a text on completion. Set a timer with ID to count up; set a timer with ID 2 to count down. Use the command NkProgressBar_SetCompletionText() to set the completion text. | |
a “NkLsEdit” control that implements the double logarithmic relation between PMT High Voltage and gain. Check the NkPMTGainEdit_ functions for details. |
uControlStyleEx
The extra style options for the control. E.G. use WS_EX_CLIENTEDGE for “EDIT” controls to get a nice border.
Description
NkDialog_AddMacroMessageHandler( longhDlg
, char *szControlID
, longuMsg
, longwParam
, longwParamMask
, longlParam
, longlParamMask
, char *Macro
);
This command registers a NIS macro that is invoked when the indicated control receives a message with the specified arguments. Check the win32 control class documentation for the details of notification messages. Many notification IDs are defined in the macro file win32.mac.
Parameters
szControlID
The identifier of the control, that can be used with FindControl() to get the handle of the control.
wParamMask
A mask applied to the argument before comparing it with the wParam parameter. Specify 0 both both wParam and wParamMask to accept any value. Specify -1 to compare the full value. Specify 0xFFFF (65535) to compare only the lower 16 bits.
Description
NkDialog_FindControl( longhDlg
, char *szControlID
, long *phCtrl
);
This command returns the control handle of the control with specified controld ID.
Description
NkDialog_SendMessage( longhDlg
, char *szControlID
, longwParam
, longlParam
);
Sends a win32 message to the control using the win32 API function SendMessage(). Check out the win32 SendMessage documentation for the arguments.
Description
NkDialog_SendMessageString( longhDlg
, char *szControlID
, longwParam
, char *szlParam
);
Use this command to send a message to a control for messages that have string pointer as lParam argument.
Parameters
Description
NkLsEdit_SetRange( longhCtrl
, doublelower
, doublehigher
, doubleincrement
);
This command sets the range and resolution of a NkLsEdit control.
Description
NkLsEdit_SetScale( longhCtrl
, doublescale
, doubleOffset
);
his command sets the scale and the offset of a NkLsEdit control. The scale and the offset are applied when calling NkLsEdit_GetValue() and NkLsEdit_SetValue(). E.G. when vbalid values range between 0 and 1000 and a scale of 0.1 and unit “%” are specified, the value 1000 is shown as “100.0%”.
Description
NkLsEdit_SetFormat( longhCtrl
, char *format
);
This command sets sprintf format of the text shown in a NkLsEdit control. E.g. to show a value with two significant digits, use the format “%.2lf”.
Description
NkLsEdit_SetUnit( longhCtrl
, char *unit
);
This command sets the unit for displaying the value in a NkLsEdit control.
Description
NkLsEdit_SetValue( longhCtrl
, doublevalue
);
This command sets the value of a NkLsEdit control. The value is clipped to the lower and higher limits and specified increment. It is displayed with the specified scale, offset, format and unit. When a NkLsScrollbar control is attached, the scrollbar will be updated as well.
Description
NkLsEdit_GetValue(
long hCtrl
);
This command returns the value of a NkLsEdit control.
Return value: the value.
Description
NkLsEdit_SetFlags( longhCtrl
, dworduNkLsEditFlags
);
This command sets the options flags of a NkLsEdit control.
Parameters
uNkLsEditFlags
Any combination of these values:
Reverse the scrollbar (left is higher limit; right is lower limit). | |
The scrollbar moves logarithmically. | |
Don't send SB_THUMBTRACK and SB_THUMBPOSITION notifications during dragging the scrollbar. | |
Don't update the edit box when dragging the scrollbar. |
Description
NkLsEdit_GetFlags(
long hCtrl
);
This command returns the options flags of a NkLsEdit control. See the documentation of the NkLsEdit_SetFlags command for details.
Return value: the option flags.
Description
NkPMTGainEdit_IsNkPMTGainEditWindow(
long hCtrl
);
This command returns if this control is a “NkPMTGainEdit” control.
Return value: TRUE (1) if the control is a “NkPMTGainEdit” control or FALSE (0) if not.
Description
NkPMTGainEdit_SetCalibration( longhCtrl
, doublea
, doubleb
);
This command sets the calibration of the double logarithmic relation between the high voltage value and the shown gain. The conversion formula is: gain = a * log10(high_voltage) + b.
Description
NkPMTGainEdit_AttachToHighVoltage( longhCtrl
, longhWndHighVoltage
);
This command connects a NkPMTGainGainEdit control to a PMT high voltage EDIT control. When the gain in the NkPMTGainEdit control is changed, the corresponding High Voltage value is send to the PMT high voltage EDIT control.
Description
NkProgressBar_SetCompletionText( longhCtrl
, longhEdit
, char *szCompletionText
);
This command programs the NkProgressBar to set the text of the specified hEdit control upon completion.
Description
NkFile_Write( char *file
, char *text
, intbConvertToAscii
);
Saves the text string to the file. An existing file will be overwritten. Set bConvertToAscii to TRUE to convert the 2-byte UNICODE strings used by NIS to 1-byte ASCII characters.
Description
NkFile_Append( char *file
, char *text
, intbConvertToAscii
);
Appends the text string to the file. The file will be created if it does not exist. Set bConvertToAscii to TRUE to convert the 2-byte UNICODE strings used by NIS to 1-byte ASCII characters.
Description
NkFile_FindFirstFile( int64 *find_data
, char *pattern
, char *szFoundFile
);
Finds the first file that matches the specified pattern. Returns 1 if a file was found. Call NkFile_FindNextFile() to find more files. Call NkFile_FindClose() afterwards.
Return value: 0 when no file matches the pattern, 1 when a file was found.
Description
NkFile_FindNextFile( int64 *find_data
, char *szFoundFile
);
Finds the next file that matches the pattern specified in the call to NkFile_FindFirstFile(). Returns 1 if a file was found. Call NkFile_FindNextFile() to find more files. Call NkFile_FindClose() afterwards.
Return value: 0 when no file matches the pattern, 1 when a file was found.
Description
NkFile_FindClose(
int64 *find_data
);
Releases the resources allocated when calling NkFile_FindFirstFile().