LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

scaling text boxes to screen size

Hi,

I am developing an application that needs to be run on multiple computers that have different screen resolutions. I would like to make the front panel of my program scale according to the current screen size. I saw two check boxes in the File>VI Properties>Window Size dialog box: 1. Maintain proportions of window for different monitor resolutions, and 2. Scale all objects on the front panel as the window resizes. However, there are still two issues that come up when both of these features are turned on. First, text boxes do not scale with everything else. When I run the program on a computer with smaller screen resolution (1366x768), the text is still the same size as it was on the computer I edited it on (1920x1080). This results in the content of the text boxes being larger than the boxes they are in and therefore unreadable. The second isssue is not as crucial, but I am curious if there is a way to resolve it. When using the "Scale all objects on the front panel as window resizes" feature, if I expand the window everything scales correctly; however, when I put the window back to its original size many of the buttons have shifted slightly.

 

Does anyone have any suggestions? Currently, the best thing I can think of is to make another version of the program for smaller screens, make a new main VI to detect screen resolution, and load the VI that has the correct size.

 

Thanks.

0 Kudos
Message 1 of 5
(4,174 Views)

You may want to try out the Front Panel Layout Tool, which was created to address the issue of creating a single UI for different screen resolutions.  It allows you to create multiple "layout" files for a single VI, then you can programmatically load one of the layouts when the VI runs.  Each layout stores the position and size information of all items on the front panel.  You can install the tool through VI Package Manager, then take a look at the example projects in <LabVIEW 20xx>\examples\Front Panel Layout\.

 

The issue you've been seeing with shifted buttons when you use "Scale All Objects with Panel" is a symptom of the fact that the LabVIEW UI is pixel based.  The position and size information of eveything on the front panel is stored as integer values.  When you shrink the front panel, some of the size values get rounded off to the nearest whole integer value.  Then, when you scale the panel back up to a larger size, the round off errors are amplified.  Repeating this several times can result in a highly distorted UI.  The Front Panel Layout Tool avoids this problem, because each resize is relative to the values stored in the layout file, instead of the values from the previous resize event.  I'd be curious to see if you have any feedback on the tool.

 

Chris  M

Message 2 of 5
(4,146 Views)

Thanks! This seems to be what I am looking for. I will incorporate it into my program and post some feedback about how things turn out.

Message 3 of 5
(4,130 Views)

Figuring out how to set this tool up in my VI is alittle overwhelming. Any chance there is a tutorial?

0 Kudos
Message 4 of 5
(4,113 Views)

@lbvw wrote:

Figuring out how to set this tool up in my VI is alittle overwhelming. Any chance there is a tutorial?


Right now, the documentation for this tool is a little sparse.  I hope to publish a "how to" document on it shortly.  In the mean time, here are some pointers for getting started:

  • The Front Panel Layout Tool palette is located in the functions palette under "Addons > Front Panel Layout".  Use the VIs in this palette to programmatically load a layout file and apply it to your VI.
  • Use the confugration dialog to create a layout file for your VI.
    1. Open your user interface VI, and make sure the front panel objects are arranged the way you wan them.
    2. Go to "Tools > Configure Front Panel Layout" to launch the dialog.  The VI should be listed in the dialog's tree.
    3. Click the "Save" button to capture the current state of the VI's front panel in a layout XML file.  You should see a new file (<viname>.xml) appear next to the VI.
  • Take a look at the "Simple Resizing.vi" example to see how to use the sub VIs to do resizing ("LabVIEW 20xx\examples\Front Panel Layout\Simple Resizing\").  This example is new in the very latest build of the tool (1.1.0.37).

Let me know if you have any questions.

0 Kudos
Message 5 of 5
(4,063 Views)