Page 1 of 1

MakeIsoAxis

Posted: Mon Feb 16, 2009 5:24 pm
by 10549537
MakeIsoAxis does not always work well. Apparently, GetDeviceCaps always returns HORTSIZE = 320 and VERTZSIZE = 240 for some versions of Windows (XP and NT I think are two of them). Is there some other way that we can get this function to work properly?

XYScreen:=1.0*(GetDeviceCaps(Canvas.Handle,HORZSIZE)/Screen.Width)/
(GetDeviceCaps(Canvas.Handle,VERTSIZE)/Screen.Height);

-Jerry

Posted: Tue Feb 17, 2009 10:14 am
by yeray
Hi Jerry,

Are you testing this allways with the same monitor? In that case, this happens because the call GetDeviceCaps returns the size in mm of your screen monitor.

Could you please explain what are you trying to achieve?

Posted: Tue Feb 17, 2009 6:36 pm
by 10549537
I am trying to use the MakeIsoAxis function from the All Features demo under 'Isometric Axis' :

procedure MakeIsoAxis(Vertical, Horizontal: TChartAxis); overload;
var tmpX,
tmpY,
XRange,
YRange,
Offset,
XYScreen : Double;
begin
with Vertical.ParentChart do
if (ChartHeight>0) and (ChartWidth>0) then
begin
With Horizontal do XRange:=Maximum-Minimum;

tmpX:=(XRange/ChartWidth);

{$IFDEF CLX}
XYScreen:=1024.0/768.0; //TODO
{$ELSE}
XYScreen:=1.0*(GetDeviceCaps(Canvas.Handle,HORZSIZE)/Screen.Width)/
(GetDeviceCaps(Canvas.Handle,VERTSIZE)/Screen.Height);
{$ENDIF}

With Vertical do YRange:=Maximum-Minimum;

tmpY:=(YRange/ChartHeight)*XYScreen;

if tmpX>tmpY then
begin
if tmpY<>0 then
begin
Offset:=((YRange*tmpX/tmpY)-YRange)/2.0;
With Vertical do SetMinMax(Minimum-Offset,Maximum+Offset);
end;
end
else
if tmpX<tmpY then
begin
if tmpX<>0 then
begin
Offset:=((XRange*tmpY/tmpX)-XRange)/2.0;
With Horizontal do SetMinMax(Minimum-Offset,Maximum+Offset);
end;
end;
end;
end;

Using Windows XP the GetDeviceCaps function returns

HORZSIZE = 320
VERTZIZE = 240

The same monitor using Windows 2000 returns

HORZSIZE = 470
VERTZIZE = 293

From a brief search of the internet, it appears that a lot of other people have had the same problem and Windows XP and perhaps NT will always return these values regardless of what size monitor is attached.

So, if I use the 'Isometric Axis' feature in the demo and click 'Make axis Isometric' then 'square' area on the chart has an approximate width of 153 and a height of 125 millimeters.

Posted: Thu Feb 19, 2009 1:25 pm
by yeray
Hi Jerry,

We've tested with different windows versions and couldn't reproduce the problem here. Could you please test if the following code replacing the line where GetDeviceCaps is called at MakeIsoAxis method works fine for you?

Code: Select all

XYScreen:=1.0*(GetSystemMetrics(SM_CXSCREEN)/Screen.Width)/
                  (GetSystemMetrics(SM_CYSCREEN)/Screen.Height);
Thanks in advance.

Posted: Tue Feb 24, 2009 2:18 pm
by 10549537
I think that GetSystemMetrics(SM_CXSCREEN) and GetSystemMetrics(SM_CYSCREEN) are the exact same thing as sceen.width and screen.height and therefore XYScreen would always be equal to 1?

I'm testing Windows XP inside a virtual machine. Maybe the virtual machine is incapable of getting the correct values from GetDeviceCaps?

Posted: Tue Feb 24, 2009 3:37 pm
by yeray
Hi Jerry,

I've tested this with several windows and screens and now I think I've found the problem. It seems that having a comfortable proportional resolution the demo apparently works fine (or the error is small) and when the resolution is "strange" the demo doesn't return square axis.

I've added this to the wish list to be revised for further releases (TV52013894) but, are you using proportional resolutions? I mean, your characters look fine? With a comfortable resolution I can see that the demo doesn't work perfectly but its error is minimum (about ten pixels more in high than in width).

I can't recommend you a resolution because the "comfortable look" should depend on the combination of resolution and screen size.