LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Front Panel Aspect Ratio

Is there an easy way to keep the aspect ratio of the front panel window?  For example, if my window is square, I want it to stay square if the user decides to resize it.  I have played around with the "front panel resize" event and tried ajusting proportionally, but it ends up flickering and not being very user friendly... I am surprised this isn't a default property built in labVIEW since it could be very useful.
Anyone have the same problem?

Thanks!

Yohan
0 Kudos
Message 1 of 13
(4,460 Views)
If you go to File->VI Properties->Window Size (may have changed, I'm using 8.2), there's two options you can check: maintain proportions of window for different monitor resolutions and Scale all objects on front panel as the window resizes.

You might want to be careful though, as sometimes the latter can result in some funny looking front panels (see the note in the properties window about it)
0 Kudos
Message 2 of 13
(4,457 Views)
 I am using 8.0 and these options are also apparent (been there for a while I believe).  But what I want is to keep the size ratio of the window whenever the user resizez it.  These options do not solve my problem 😞
Thanks
0 Kudos
Message 3 of 13
(4,454 Views)
Anyone?
0 Kudos
Message 4 of 13
(4,432 Views)
Hello,
 
You can program that functionality.  Basically you monitor the window height and width, and use the following basic logic:
if (making window bigger)
   height = width = max(height, width)
if (making window smaller)
   height = width = min(height, width)
 
you'll have to decide if you want to increase or decrease which dimension in the cases: width increase, height decrease, and vice versa.
 
you can use the panel resize event with an event structure - it gives you access to the old and new bounds values, so you can compute the logic you desire, and then write the front panel window -> panel bounds property for that VI using VI Server to resize it and make it square.
 
happy programming!
 
JLS
Best,
JLS
Sixclear
Message 5 of 13
(4,424 Views)
Hi JLS,
thanks for the input!  I had already tried working out this approach but I found the result to be a little "glitchy".  This is because the user is allowed to resize the window and once the change is made, the panel is then resized the way I want it. To you have any idea on how to go around this?
Thanks again!

Yohan
0 Kudos
Message 6 of 13
(4,408 Views)
Hello,
 
Well, to eliminate glichiness (if that's a word) I tried monitoring mouse up and down events, but those only exist for the panel, not the VI itself.  Using these events would theoretically work because on mouse down, you record the current dimensions, then on mouse up, you assign your new computed aspect ratio preserving dimentions... using a shift register, you have access to both the old and new resize dimensions, from which you can compute your new aspect ratio preserving dimensions.  The mouse down is caught when you click the resize section, but it seems the mouse up is not caught unfortunately, so this attempt was thwarted as well.
 
I'm not sure if the mouse down and mouse up events for the PANEL are supposed to catch events that happen technically outside of the panel space on the window border where a resize is done, thus, I don't know if this is a bug or expected behavior.  It is interesting that it catches the mouse down and not the mouse up though...  I tried to be a bit more tricky and say "perhaps the VI event 'mouse enter' will work if while resizing it considers you outside the panel... seems this didn't work either.
 
Feel free to play around, but it looks like programmatically achieving this will take a bit more work... definitely post a solution if you have time to look into it!  Sorry the theoretically straightforward attempts aren't directly implementable.
 
Best Regards,
 
JLS 
 
 
Best,
JLS
Sixclear
Message 7 of 13
(4,400 Views)
Thanks again for looking into this.  As for the mouse events, I haven't tried yet the way you described.  I'll try this out when I find some time.  I will definitely post up a solution if (hopefully!)  I figure a way around this.
Cheers

Yohan
0 Kudos
Message 8 of 13
(4,391 Views)

Ok, I played for another minute, and here's something you may be able to use.  Basically, I use the mouse down event on the panel to recognize when the the panel is starting to be resized (to get initial "before resize" size) and then use the mouse leave event on the panel to compute and assign the new size.  The result is that if i resize and then just move my mouse outside the bounds of the VI window, it updates with the square aspect you desire.  More specifically, it uses the following logic:

 

If at least one dimesion (height or width) got bigger then resize bigger (to the bigger of the height and width)

Otherwise, resize smaller (to the smaller of the height and width)

 

Here it is in 8.0 as I believe you noted you were using - I hope this helps!

Best Regards,

JLS

Message Edited by JLS on 10-02-2006 12:39 PM

Best,
JLS
Sixclear
Message 9 of 13
(4,387 Views)
Hi JLS,
thanks a million for the example!   It's fun that you found time to help me out.  I had some time to play around with it and I found out something particular... The event structure doesn't seem to notice the mouse down event either!  It only registers the event when the mouse is "down" or "up" on the actual pane and not on the border.  I tried doing it using the "register for events" and the result stays the same.  Seems that using Windows events is the only way to go... unless you have any other suggestion! 😉
Thanks again,

Yohan

Message Edited by NahoY on 10-02-2006 01:11 PM

0 Kudos
Message 10 of 13
(4,379 Views)