1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
void __fastcall TForm1::Button5Click(TObject *Sender)
{
double a;
double b;
double c;
double d;
int j;
double coef_Hauteur;
double coef_Largeur;
StringGrid1->Visible = false;
Image1->Visible = true;
coef_Largeur = Printer()->PageWidth;
coef_Largeur = (coef_Largeur /297);
coef_Hauteur = Printer()->PageHeight;
coef_Hauteur = (coef_Hauteur / 210);
Image1->Left = 10;
Image1->Top = 50;
Image1->Width = ClientWidth * 2;
Image1->Height = ClientHeight * 2;
Image1->Canvas->Pen->Color = clRed;
Image1->Canvas->Pen->Width = 2;
// graphique ecran
for (j = 2; j < StringGrid1->RowCount - 1; j++)
{
a = StringGrid1->Cells[14][j].ToDouble(); // X
b = StringGrid1->Cells[13][j].ToDouble(); // Y
c = StringGrid1->Cells[14][j + 1].ToDouble(); // X
d = StringGrid1->Cells[13][j + 1].ToDouble(); // Y
Image1->Canvas->MoveTo(a, b); // X,Y
Image1->Canvas->LineTo(c,d); // X,Y
}
Image2->Left = 10;
Image2->Top = 50;
Image2->Width = ClientWidth * 2;
Image2->Height = ClientHeight * 2;
Image2->Canvas->Pen->Color = clRed;
Image2->Canvas->Pen->Width = 6;
// graphique imprimante
double zoom;
zoom = 25.9;
for (j = 2; j < StringGrid1->RowCount - 1; j++)
{
a = ((StringGrid1->Cells[14][j].ToDouble() / 250) * coef_Hauteur) * zoom; // X
b = ((StringGrid1->Cells[13][j].ToDouble() / 250) * coef_Largeur) * zoom; // Y
c = ((StringGrid1->Cells[14][j + 1].ToDouble() / 250) * coef_Hauteur) * zoom; // X
d = ((StringGrid1->Cells[13][j + 1].ToDouble() / 250) * coef_Largeur) * zoom; // Y
Image2->Canvas->MoveTo(a, b); // X,Y
Image2->Canvas->LineTo(c,d); // X,Y
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
StringGrid1->Visible = true;
Image1->Visible = false;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int Hauteur;
int Largeur;
TPrinter *Prntr = Printer();
TRect Rect ;
//Definir le coordonnée du Rect.
Rect.left = 0;
Rect.top = 0;
Rect.right = Prntr->PageWidth; // NB pixels largeur
Rect.bottom = Prntr->PageHeight; // NB pixels hauteur
Image2->Width = Prntr->PageWidth;
Image2->Height = Prntr->PageHeight;
Prntr->BeginDoc();
Prntr->Canvas->Rectangle(Rect);
Prntr->Canvas->StretchDraw(Rect,Image2->Picture->Bitmap);
Prntr->EndDoc();
} |
Partager