yet another problem I run into with my 'colorbar' emulation. What I tried to achive is to have a fixed size ColorBar but the Charts width should adjust to the width of the right-axis labels. I've attached a sample application. Just run it (you need Codesite installed) and see the log output (do not move with the mouse across anything on that app. yet!).
In the log you can see that in the AfterDraw event the previous Width was 98 and the new Width is 109.
Now just move the mouse over one of the labels and see the width of the chart "jumping" (in the log you can see that the with ist staying at 109)
Now click the 'Change scale' button (don't move the mouse across the labels).
In the chart you can see the lables change (getting wider) and the color bar is shrinking but In the log you can see that the old width was 109 and is changed to 121.
You could move over one of the lables again and see how the 'physical' Width changes again BUT instead press the 'set' button. Now the Width is adjusted but only with the following trick:
Code: Select all
CMapChart.Width := CMapChart.Width+1;
CMapChart.Width := CMapChart.Width-1;
So I hope you know a way to adjust the charts width when the lables get bigger or smaller?