What are the scrolling limits of a Virtual Tree View? - delphi

How can I get the max scroll for the X and Y in virtualstringtree during onchange event?

The GetTreeRect method gives the dimensions in pixels of the entire tree, or the dimensions of the client area, whichever is larger. Note that if there are no columns configured, then the size of the tree can vary based on which nodes are displayed on the screen at the time — the scrolling width changes according to the widest nodes visible.
The Bottom and Right fields of that rectangle determine the scroll-bar range.

Related

iOS when one views height increase with code , alignment is deteriorating

I am trying raise the height of the ranked successive views. There is a certain distance between each of these views.(Vertical spaces)When I increase the height of one of them, distorted distance between the bottom. I can not align all elements under one single at a time. This event is automatically done on Android. How do I make this operation on iOS.
That is the problem

Highcharts: How to adjust size of bar chart with respect to spacing/size of bars?

I have a bar graph (note: the length of a bar spans horizontally. conversely, a column graph spans vertically. See below.) My series data can either become a long list or a short list so the number of bars varies between many and few. If I have many bars, my graph needs more height to maintain the same space between bars and maintain the width of the bars. How can I set the height of the graph to ensure that these are fixed?
I looked into a scrollbar for the vertical axis, but I didn't like this because the browser may have it's own vertical scrollbar. I also found advice on dynamically resizing the graph to fit the window, but this is won't work if I have more bars than would fit within a maximized window. So I think the best idea would be to have a graph that sizes with the number of bars. If the bar graph is greater than the page height, the browser's vertical scrollbar will come into action.
Bar graph:
===
==========
=============== ]---- width of bars needs to be maintained.
[spacing between bars also needs to be maintained.]
=======
===========
=== <--- a new bar would simply go here, and chart would increase height by 1 bar width.
The best solution that I have found for this is to determine the size by a simple count of the categories I will need on the server side.
When loading the page, I start with the height needed for the chart's top and bottom margin.
I do a count of my data, and multiply by however much space I need (usually 20, 25 pixels per category, in my cases).
Then set the height of the container accordingly.
I usually do this with php on page load. I'm sure a javascript implementation wouldn't be difficult to achieve.

Scrolling the TStringGrid pixel by pixel

Scrolling a TStringGrid using its horizontal scroll bar will scroll a column at a time. In some situations, this creates a really nasty behavior that makes the grid unusable: if the width of last column is large (example, 1000 pixels) the user won't be able to scroll the grid to see the entire content of the column.
There is a way to scroll by pixel? Or to set the correct scroll range for grid's scroll bar?
As far as I know, no you can't horizontally scroll the string or draw grids by pixels, only by whole columns. I agree it can be a problem by the way. I tend to autosize the columns but make the max initial size of any column be slightly less than the clientwidth of the control.
I have looked into the source code. With Borland's code it can't be done.
However, Lazarus has this capability.

Repositioning images on FormResize proportionally

I have a Delphi form with TImages on it. Actually, it's a "fake" desktop with "icons" (the TImages).
When the user resizes the form (scales it or maximizes it, for example) the icons on the form should align proportionally.
Right now, I'm doing something like this with the images:
ImageX.Left:=Round(ImageX.Left * (Width / OldWidth));
ImageX.Top:=Round(ImageX.Top * (Height / OldHeight));
Now this is OK, as long as I start to make the maximized form smaller.
In that case the rightmost images are cut in part by the form's border (they're off the form's client area).
If I reposition these images to fit the client area, then the position of the icons get distorted upon scaling back to maximum size.
Any ideas for a better algorithm/fix?
Thanks!
First of all, you can't have a correctly scaled desktop when you only move the images, and don't scale them as well. You can do slightly better by moving the midpoints of your images, not their top left corner. It still won't be perfect, but it will work better. Of course, now the images will be cropped on all four sides, not just bottom and right, but at least it will be symmetrical :-)
Second, you will get accumulative rounding errors since you constantly override the "original" values (ImageX's top and left coordinate). You'd be better off having the original values stored in some sort of collection or array, and setting the new position based on the original value, rather than the previous value.
Something like this:
ImageX.Left:=Round(ImageX_OriginalLeft * (Width / Original_Width));

How do I make a TCheckListBox scroll vertically?

I've got a TCheckListBox on a form. Its Columns property is set to 2, and if there are more items than can fit on-screen in two columns, it puts a horizontal scrollbar across the bottom of the control.
Thing is, the way this form it laid out, it would be much more convenient to scroll vertically. But I can't seem to figure out how to make the box do that. I thought setting Columns to 1 should work, but it doesn't.
Anyone know how to make a TCheckListBox scroll vertically instead of horizontally?
You need to set Columns to 0.
For all positive values the VCL sends a LB_SETCOLUMNWIDTH message to the underlying native list box control, with the width parameter set to the list box client width divided by the number of columns. Items that don't fit will start a new column with the same column width, so the horizontal scrollbar becomes visible.
If Columns is 0 then there is a single column that spans the entire client width of the list box, and items that don't fit will make the vertical scrollbar visible, and hide the horizontal scrollbar.
Edit:
There seems to be genuine interest what happens when a negative value is used for the Columns property.
The method TCustomListBox.CreateParams() sets the LBS_MULTICOLUMN list box style depending on the Columns property being different from 0. For negative values the style flag is set, but the VCL doesn't send the LB_SETCOLUMNWIDTH message, so the native control uses the default column width. It is documented to be:
15 times the average character width for the font used by the list box.
(Search for "The LBS_MULTICOLUMN style specifies" to find the relevant passage of text.)

Resources