LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

autoscaling user interface to screen resolution ??

Luis,

I have tried all your suggestions and everything has worked. Thank You.

I do have another question.

Now that I have everything working in different resolutions. Meaning, that nothing is on top of each other and everything works as expected, I did discover one last issue. There are a couple of places in the code that makes the height of a decoration smaller or bigger(with SetCtrlAttribute). The height adjustment occurs at startup when I am loading the panels and can occur various times during run time. The decoration is set up to line up with other decorations around it. However, this only works nicely when I have saved the .uir file in the same resolution as the target computer's resolution. If I build in a resolution that is not 1024 x 768, the height adjustment is incorrect when I load the program onto the target that has a resolution of 1024 x 768. The requirement is to use a default resolution of 1024 x 768 but we need to allow the user to change to other resolutions.

1.) Is this expected behavior?

2.) What do you recommend as a fix for this? I have thought about completely getting rid of re-adjusting the decoration heights during run time, since it's only in a couple of places. I also have a quick fix in which I take the height of the decoration next to it and set the height to this value. This works but it doesn't seem like a good solution since I am building a dependency on another decoration. I have a few other clugy ideas. But all of them don't seem like a long term solution. Can you please advise.

Please let me know.

Thanks, Letty

0 Kudos
Message 21 of 25
(1,962 Views)
Hi Letty,

I'm not sure that I completely understand the problem you're describing. It sounds to me as if first you are loading the panel, then you are explicitly resizing one of the controls, at which point the UI no longer looks good -- if the resolution is different from the original resolution of the panel.

Is this correct?

My question is what exactly is happening with this decoration? Is it too big, or too small? And at point does it start looking bad? Is it right after you resize the decoration? Does the resize operation not do exactly what it's supposed to do? Can you provide a couple of screenshots of what you would like it to look like, versus what it really looks like when it doesn't work?

Finally, keep in mind that the "resolution adjustment" option only has an effect in the LoadPanel call. Once the panel is loaded it has no lasting effect.

Luis
0 Kudos
Message 22 of 25
(1,916 Views)
Luis,
 
Please see Decoration Height in diff resolutions.doc.
 
To answer your questions, your first statement is correct. All the other questions are answered in the .doc file.
 
Thanks,
 
Also, if this issue is too convoluted, please feel free to call me. My work number should be stored with my account. Thanks.

LuisG wrote:
Hi Letty,

I'm not sure that I completely understand the problem you're describing. It sounds to me as if first you are loading the panel, then you are explicitly resizing one of the controls, at which point the UI no longer looks good -- if the resolution is different from the original resolution of the panel.

Is this correct?

My question is what exactly is happening with this decoration? Is it too big, or too small? And at point does it start looking bad? Is it right after you resize the decoration? Does the resize operation not do exactly what it's supposed to do? Can you provide a couple of screenshots of what you would like it to look like, versus what it really looks like when it doesn't work?

Finally, keep in mind that the "resolution adjustment" option only has an effect in the LoadPanel call. Once the panel is loaded it has no lasting effect.

Luis



0 Kudos
Message 23 of 25
(1,874 Views)

Luis,

I just ran a test to print out the height of the decoration un different resolutions. The height value does indeed vary. Am I to assume that resizing is not a good idea when the app is supposed to work under different resolutions?

0 Kudos
Message 24 of 25
(1,873 Views)
Letty,
 
There's not wrong with setting your own sizes, on any resolution, but you have to be careful what you set those sizes to. Your problem is that you're setting the decoration to a fixed value (135 pixels), even though that value only makes sense at one particular resolution.
 
When CVI scales the UI to each resolution, it changes the sizes of all the fonts, control edges, etc. So you cannot assume that the controls are all going to have a fixed height. Therefore, you shouldn't size this one control to a fixed height, if you want it to look good relative to its neighboring controls.
 
You mentioned in your doc that the workaround that you came up with was to find out how tall the neighboring control is and then size this control to match that height. That's actually correct. There's nothing wrong with that approach, that I can see. It's what I would have done too. And it's also correct to remember the original (short) height of the control, and then set it to that size, instead of always setting it back to 75 pixels.
 
Speaking more generally, it's almost always a bad idea to use constant values to size controls to, whenever you're creating or adjusting a UI programmatically. It's almost always safer to use instead variables that represent what you really want to size your control to, such as neighboring controls, for example.
 
If you don't like this approach, and you want to use constant values instead, you always have the option of not doing any resolution adjustment, in which case you might be able to rely on the controls preserving the same exact height that they had in the .uir (I say 'might' because depending on what font you use -- NI Dialog? -- some controls might change size if they're loaded in a computer where NI Dialog resolves to a different system font).
If you choose to not use resolution adjustment, your task is simply to make sure that the entire panel fits in whichever is the smallest resolution that you want to support, so that the window is not cut off. That's what most applications do anyway. The only negligible downside is that when the application is run at a higher resolution, the window becomes physicall smaller and smaller. But most people are okay with that.
 
Luis
0 Kudos
Message 25 of 25
(1,854 Views)