Admin Production ni-theme
Current Publication

SetCtrlsToAttributeExtreme

LabWindows/CVI

SetCtrlsToAttributeExtreme

int SetCtrlsToAttributeExtreme (int panel, int attribute, int whichExtreme, int numberOfCtrls, ...);

Purpose

This function examines the value of a control attribute for every control specified. It then sets the value of that attribute in each control to either the largest or the smallest value it found, depending on the setting of the whichExtreme parameter.

This function can be used to size and position controls when creating dialogs programmatically. For example, the following code, which can be run in the interactive window, creates three buttons and then calls SetCtrlsToAttributeExtreme to make all three buttons the same width.

Example Code

{

int panel, okBtn, defaultBtn, cancelBtn;

panel = NewPanel(0, "Test Panel", 40, 40, 300, 300);

defaultBtn = NewCtrl (panel, CTRL_SQUARE_COMMAND_BUTTON,

"__Default", 250, 20);

okBtn = NewCtrl (panel, CTRL_SQUARE_COMMAND_BUTTON, "__Ok",

250, 120);

cancelBtn = NewCtrl (panel, CTRL_SQUARE_COMMAND_BUTTON,

"__Cancel", 250, 220);

DisplayPanel(panel);
GetUserEvent(1,0,0); /* wait for any button to be pressed */

/* make all buttons the same width */
SetCtrlsToAttributeExtreme(panel, ATTR_WIDTH, VAL_TB_MAX, 3,

defaultBtn, okBtn, cancelBtn);

GetUserEvent(1,0,0); /* wait for any button to be pressed */
DiscardPanel(panel);

}

Parameters

Input
Name Type Description
panel int The specifier for a particular panel that is currently in memory.

This handle will have been returned by the LoadPanel, NewPanel, or DuplicatePanel function.
attribute int Specify which attribute to set in the designated controls. The data type of the attribute must be integer (example: ATTR_TOP, ATTR_WIDTH).
whichExtreme int This parameter specifies whether to set the value of the attribute in every designated control to the largest or to the smallest value of the attribute currently set for any of the designated controls.

If you specify VAL_TB_MAX or select Maximum in the function panel, the function uses the largest value of the attribute.

If you specify VAL_TB_MIN or select Minimum in the function panel, the function uses the smallest value of the attribute.
numberOfCtrls int Specifies how many control IDs are being passed to the function.

Pass zero for this parameter if you want the function to continue through the control argument list until it finds a control ID of zero. This feature makes it unnecessary to count the number of controls passed if the last control ID passed is always a zero.
controlList ... This parameter takes a variable number of comma separated control ID arguments.

If the value of numberOfCtrls is zero, then the last control ID passed should be a zero in order to mark the end of the list of controls. Otherwise, numberOfCtrls should be set to the number of control IDs passed.

Return Value

Name Type Description
status int Returns 0 if the function succeeded or a negative error code if the function failed.

The possible negative error codes are:

–1 to –999 A User Interface Library error code. (Constants are available in userint.h.)

A description of any of these error codes can be obtained using the GetGeneralErrorString function in the toolbox.fp instrument driver.

Additional Information

Library: Programmer's Toolbox

Include file: toolbox\toolbox.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later