Scaling User Interface Objects When Scaling the Panel in LabWindows™/CVI™

Updated May 14, 2023

Environment

Software

  • LabWindows/CVI

I want my application's user interface (UI) contents to scale when a panel resizes in LabWindows™/CVI. How do I enable the auto-scaling of UI panel contents?

To automatically scale user interface objects when scaling the panel, you should follow these steps:
  1. Open your .uir file and double-click the main panel to open Edit Panel window
  2. Click on Other Attributes... button, shown below:
  1. Enable Scale Contents on Resize checkbox. This option specifies that LabWindows™/CVI will auto-scale the contents of a panel when it is resized to maintain a proportionally consistent display.
  2. Set Min Panel Height When Scaling and Min Panel Width When Scaling attributes to desired values


Please refer to Additional Information section for information on the three attributes that are associated with scaling. 
This feature can be also set programmatically, just like any other attribute using SetPanelAttribute function. Please refer to Additional Information section.

Additional Information

The following are the definitions of the three attributes that can be set in Other Attributes window:
  • Scale Contents on Resize - This attribute specifies whether the contents are scaled when the panel is resized. This applies to programmatic resizing, resizing in the User Interface Editor, and resizing by the end-user. 
  • Min Panel Height When Scaling - This attribute specifies the smallest panel height for which scaling is allowed. If the user resizes the panel so that it is shorter than the specified height, the content area is clipped. In order to access this attribute, the Scale Contents on Resize attribute must be enabled. 
  • Min Panel Width When Scaling - This attribute specifies the smallest panel width for which scaling is allowed. If the user resizes the panel so that it is narrower than the specified width, the content area is clipped. In order to access this attribute, the Scale Contents on Resize attribute must be enabled. 

These attribute can also be set programmatically, in order to enable scaling of the user interface objects programmatically. You should follow these steps:
  1. Launch LabWindows™/CVI and open up your application.
  2. Open up your source code by double-clicking your *.c file located in the Project Tree.
  3. Use the SetPanelAttribute() function to access panel properties.
  4. Open up the function panel for the SetPanelAttribute() function and set the Panel Attribute to Scale Contents on Resize. This attribute is found under the Panel Attribute category as shown below:
  1. Set the Attribute Value to 1.
  2. Use the SetPanelAttribute() function
  3. Insert this function into your code before the RunUserInterface() function is called as shown below:
int main (int argc, char *argv[]) {   if (InitCVIRTE (0, argv, 0) == 0)      return -1;   if ((panelHandle = LoadPanel (0, "test.uir", PANEL)) < 0)      return -1;   DisplayPanel (panelHandle);   /***************************************************/   SetPanelAttribute (panelHandle, ATTR_SCALE_CONTENTS_ON_RESIZE, 1);      SetPanelAttribute (panelHandle, ATTR_MIN_HEIGHT_FOR_SCALING, 45);      SetPanelAttribute (panelHandle, ATTR_MIN_WIDTH_FOR_SCALING, 45);   /***************************************************/   RunUserInterface ();   DiscardPanel (panelHandle);      return 0; }