LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Panel scaling when using a table control causes poor table appearance - how to fix?

Can anyone help me with figuring out how to configure a table control on a CVI panel that allows panel scaling (via the panel attribute ATTR_SCALE_CONTENTS_ON_RESIZE), so that when you scale the panel up (or down) from one panel size to another (while logged in at one fixed standard screen resolution: either 1280 X 1024 or 1600 X 1200) that the table control holds its appearance (the way it was originally set up by the developer in the UIR file) as the panel is scaled via either the mouse strecthing the window corners or via the window-maximize button...?
 
It seems that the table control wants to shrink or expand its row heights and/or column widths relative to its table border frame in such a way that is different that the scaling of the frame itself as it shrinks and expands.  I'm getting the feeling that it is font-face or font-size related, after spending many hours of playing with various table settings and font-faces to see if I can get my arms around how to keep a table reasonably nice-looking from one panel-size to another.  The problem can happen on simple 2 X 2 cell tables, but is exacerbated when you have a larger M X N table, which is what I am using in my project.
 
In fact, I'd even settle for having the table control go from one appearance in one panel-size to a different appearance in another panel-size if I could be certain that as I went back and forth (during run-time) between those various resolutions that the table's appearance did not get "stuck" along the way and could not go back to the way it once looked like it started out looking at its initial resolution (at program start-up).  Yes, this is happneing to me, I'm getting the impression that some font gets substituted along the way and it won't swap the font back again.
 
I've tried just about everything I could think of, including playing with the resolution adjustment setting when saving the panel while logged in at different screen resolutions, using scrollbars or not using scroll bars, setting row heights and column widths to be "explicit" sizes, etc.   Arrrggghh!  I'm about to give up.
 
Yes, I know the drill, so I am attaching a sample file, and I'm making it as simple as possible.  This is the UIR file that comes straight from a shipping example from CVI.8.0 (autoscaling.prj), with only one modification to the entire project from me: I added an empty 2-row X 2-column table to the panel that does the scaling during run-time, and I stretched the panel-size a bit to make this new table fit on it, and I stretched it to an arbitrary aspect ratio, because that's a real world situation where I come from.
 
Notice that I set the table border frame so that it evenly fits at the edge of the bottom row and right column of the 2 X 3 cells.   At run-time you will notice that if you shrink the panel size to be smaller than its start-up size, the table borders overlap the bottom row and right colomn.  If you expand the panel larger its start-up size it adds some "padding" after the bottom row and right column.  Larger M X N tables make this situation worse, so it must be cumulative, so I guessed it was font related.
 
Thanks if you can help, JB
--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 1 of 4
(3,162 Views)
You're right... it would be an exercise in frustration to try to configure the table such that panel scaling would leave it with an exact number of rows and columns showing. The problem is that the panel scaling tries to scale the controls completely proportionally (both vertically and horizontally), to the extent that this is possible. In theory, this should scale everything equally, leaving the relative sizes the same. However, controls have several parts that cannot scale proportionally: the fonts, which you pointed out, are close to proportional, but not quite, depending on the exact font. The scroll bars and the control frame also have limited sizes... and so on. The bottom line is that this is virtually impossible, for the table, at least.

The good news is that you do have a solution that is not too painful. At runtime, you receive an event each time the panel sizes. When you receive that event, all you have to do is to set the following attributes:

SetCtrlAttribute (panel, table, ATTR_NUM_VISIBLE_ROWS, desiredNumRows);
SetCtrlAttribute (panel, table, ATTR_NUM_VISIBLE_COLUMNS, desiredNumCols);

That should resize the table so that if fits exactly the number of rows and columns that you want. But I don't know if you want these to remain constant regardless of the panel size. If not, one thing you can do is find out how many columns the autosizing left you with, and then set the attribute again, to effectively "round" the table size to the nearest whole row/column. Like this, for example:

GetCtrlAttribute (panel, table, ATTR_NUM_VISIBLE_ROWS, &numRows); // this might be more rows than you actually have
GetCtrlAttribute (panel, table, ATTR_NUM_VISIBLE_COLUMNS, &numCols); // this might be more columns than you actually have
SetCtrlAttribute (panel, table, ATTR_NUM_VISIBLE_ROWS, Min (numRows, totalRowsAvailable));
SetCtrlAttribute (panel, table, ATTR_NUM_VISIBLE_COLUMNS, Min (numCols, totalColsAvailable));

Luis
NI

Message 2 of 4
(3,156 Views)
By the way, I just saw someone having the same problem as you, in another thread today:

http://forums.ni.com/ni/board/message?board.id=180&message.id=21666

Luis
0 Kudos
Message 3 of 4
(3,150 Views)

Thanks so much, Luis, for your fast and accurate reply...  I'm not so sure I would have figured that out on my own, I don't use CVI tables that much.

I suppose I should have asked my question sooner, I wasted too much time last week toying around with various table settings, all to no avail.

I would love to see a future update of some selected CVI example projects (such as the "autoscaling.prj", which I think goes back to CVI 4.0 or so), so that the new CVI features and controls are covered a bit better in the examples.

JB

--
To whom it may concern: My alias is also my nickname, I've had it since I was a (very) skinny basketball-playing teen. OK, so I've got a 38 inch waist now, but my hometown friends haven't shaken that appellation for me. I trust that you will someday be OK with that alias, as I have been with that nickname.
0 Kudos
Message 4 of 4
(3,142 Views)