jb_______ Cdt

Registrado: 22 Dic 2003Mensajes: 21
|
Publicado: Vie 08 Oct, 2004 5:20 pm Asunto: Imprimir Texto en Vertical en el Canvas de la Impresora |
|
|
Sencilla función, pero que puede ser de gran utilidad.
void ImprimeTextoVertical(int X, int Y, AnsiString Texto)
// Imprime el texto en vertical desde la posicion especificada
// y con el tipo de letra seleccionada en ese momento en el objeto Printer().
//
// Si quieres usar posiciones absolutas en centimetros o milimetros
// puedes usar una de las siguientes variables:
//
// int CM = (GetDeviceCaps(Printer()->Handle, LOGPIXELSX) / 2.54);
// int MM = (GetDeviceCaps(Printer()->Handle, LOGPIXELSX) / 25.4);
{
TCanvas* imgCanvas = Printer()->Canvas;
imgCanvas->Font->Name = Printer()->Canvas->Font->Name;
imgCanvas->Font->Size = Printer()->Canvas->Font->Size;
imgCanvas->Font->Style = Printer()->Canvas->Font->Style;
imgCanvas->Font->Color = clBlack; // Color del texto.
imgCanvas->Brush->Color = clWhite; // Color de fondo del texto.
LOGFONT lf;
GetObject(imgCanvas->Font->Handle, sizeof(lf), &lf);
lf.lfOrientation = lf.lfEscapement = 10 * 90;
HFONT hFont = CreateFontIndirect(&lf);
imgCanvas->Font->Handle = hFont;
// Si hemos especificado la posicion en milimetros:
// x = (x * MM);
// y = (y * MM);
imgCanvas->TextOut(X, Y, Texto);
} |
|