Strange annotation location upon DrawToMetaCanvas
Posted: Mon Nov 27, 2006 11:57 am
Hi,
Im not sure how to explain it, but I have a Chart with an annotation on it that gets a value I give it during a process. It works great and on the chart when the procedure is done its there. However when printing it for some reason the annotation always appears on the very first chart, whichever one is the first in the series of charts I have. Im not sure if I am doing something wrong.
Here's my code:
Thanks,
Tom
Im not sure how to explain it, but I have a Chart with an annotation on it that gets a value I give it during a process. It works great and on the chart when the procedure is done its there. However when printing it for some reason the annotation always appears on the very first chart, whichever one is the first in the series of charts I have. Im not sure if I am doing something wrong.
Here's my code:
Code: Select all
procedure TForm1.AdvToolBarButton14Click(Sender: TObject);
Var
topc,botc: Integer;
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
Meta: TMetaFile;
m: TMetafile;
c: TMetafileCanvas;
tmpW,tmpH: Integer;
resultspath: String;
mycanvas: TMetaFileCanvas;
b: TBitmap;
begin
Printer.PrinterIndex := Printer.PrinterIndex;
Printer.GetPrinter(Device, Driver, Port, hDMode);
if hDMode <> 0 then begin
pDMode := GlobalLock(hDMode);
if pDMode <> nil then begin
pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
pDMode^.dmPaperSize := DMPAPER_11X17;
GlobalUnlock(hDMode);
end;
end;
m := TMetafile.Create;
c := TMetafileCanvas.Create(m, 0);
i := 0;
topc := 2;
botc := 3;
m.enhanced := true;
tmpW:=myChart[i].Width;
tmpH:=myChart[i].Height;
for i := 0 to charts - 1 do
begin
if i = 0 then
myChart[i].DrawToMetaCanvas(c,Rect(0,0,tmpW,tmpH));
if i = 1 then
myChart[i].DrawToMetaCanvas(c,Rect(0,tmpH,tmpW,topc*tmpH));
if i >= 2 then
begin
myChart[i].DrawToMetaCanvas(c,Rect(0,topc*tmpH,tmpW,botc*tmpH));
Inc(topc);
Inc(botc);
end;
end;
try
c.Destroy;
Printer.BeginDoc;
Printer.Canvas.StretchDraw(Rect(10,50,6500,2400),m);
Printer.EndDoc;
//resultspath := ConfigGrid.ColumnByName['ResultPath'].Rows[1];
//m.SaveToFile(ResultsPath + '\' + run + ' ' + filename + '.emf');
//m.SaveToFile('C:\test.wmf');
finally
m.free;
end;
end;
Tom