 |
Club Builder Foro de C++Builder en español
|
| Ver tema anterior :: Ver tema siguiente |
| Autor |
Mensaje |
Susana Johannsen Cdt

Registrado: 13 Abr 2003Mensajes: 15
|
Publicado: Jue 27 Nov, 2003 8:35 pm Asunto: como actualizar el Canvas de la impresora |
|
|
Cuando quiero saber el ancho del texto inicialmente no tengo problemas
EJEMPLO: Printer()->Canvas->TextWidth("abcdefg");
hasta aqui todo bien.
Pero cuando cambio de impresora no se actualiza y el ejemplo de arriba falla y da una medida equivocada.
La forma en que si sale bien es con:
Printer()->BeginDoc;
Printer()->EndDoc;
pero este procedimiento hace que la impresora funcione y tome una hoja.
Yo deseo actualizar la impresora sin que esta tome la hoja ni se encienda. |
|
| Volver arriba |
|
 |
_Viktor Master


Registrado: 20 Jul 2003Mensajes: 463Ubicación: Santiago, Los Angeles - Chile
|
Publicado: Vie 28 Nov, 2003 12:39 am Asunto: |
|
|
Haber lo que te entendi es limpiar el canvas de la impresora para una nueva impresion ???, eso ??
Si es asi esto deberia funcionar:
| Código: |
Printer()->Refresh();
|
Espero que sea eso. Saludos! _________________ "Ser inteligente no es ser mas, solo equivocarse menos y no usar Visual Basic"
Atte.
Victor Yañez
Apoyen el Proyecto OpenSource del Club Builder. Ya tenemos componentes Listos!!! |
|
| Volver arriba |
|
 |
Invitado
|
Publicado: Sab 29 Nov, 2003 10:46 pm Asunto: |
|
|
| Gracias por tu interes pero ya lo probe y no funciona. Y no me refiero a limpiar sino a cambiar de impresora. Para entender mejor supongamos que estoy correctamente conectado a dos impresoras una Epson y una Hp. Cuando el software se inicia con la Empson, esta funciona correctamente, pero al cambiar a la HP Printer()->Canvas->TextWidth("abcdefg") da un resultado equivocado. Ahora cuando el software se inicia con la HP esta funciona y la Epson falla. En sintesis cambio segundo falla y Refresh() no funciona. |
|
| Volver arriba |
|
 |
Cesar C. Salazar Gonzalez Master


Registrado: 01 Oct 2002Mensajes: 2155Ubicación: San Cristóbal de Las Casas, Chiapas
|
Publicado: Dom 30 Nov, 2003 12:29 am Asunto: |
|
|
Aparte del Métod Refresh() mencionado arriba, intenta establecer la impresora con la que vas a trabajar, esto esta en la ayuda de builder
| Código: |
Specifies the current printer.
void __fastcall SetPrinter(char * ADevice, char * ADriver, char * APort, int ADeviceMode);
Description
Call SetPrinter to change the current printer.
ADevice specifies the device name of the new printer. This is the name that appears in the Print Manager (for example, "Epson FX-80"). It is not the printer model name.
ADriver specifies the driver name for the new printer (usually ‘WINSPOOL’).
APort is included for backward compatibility. It should be set to an empty string.
DeviceMode is the handle to a memory buffer containing a DEVMODE structure, which contains device-specific initialization data for the device driver. This handle can be obtained by calling the GlobalAlloc function to allocate the structure. |
que puede servite cuando cambies la impresora, de una a otra. es decir , cada vez que cambies tu impresora con SetPrinter, Activa el Refres(), para activar las fuentes y tamaños de la nueva impresora... pruebalo
ejemplo
| Código: |
And the C++Builder code..
//---------------------------------------------------------------------------
void __fastcall TfrmTPrint::btnSwitchPrinterClick(TObject *Sender)
{
TPrinter* newPrinter;
TPrinter* oldPrinter;
Graphics::TBitmap* bmInput;
// Assign new printer object separate from default Printer() function
newPrinter = new TPrinter;
newPrinter->Copies = 1;
newPrinter->Orientation = poLandscape;
// Load some graphics for our output
bmInput = new Graphics::TBitmap;
bmInput->LoadFromFile("C:\\INPRISE.BMP");
// Output the first report
Printer()->Copies = 2;
Printer()->Orientation = poLandscape;
Printer()->BeginDoc();
Printer()->Canvas->Draw(200, 0, bmInput);
Printer()->Canvas->TextOut(0, 500, "This report brought to you by C++Builder 4!");
Printer()->EndDoc();
// Switch to fax printer object, saving original printer object to oldPrinter
oldPrinter = SetPrinter(newPrinter);
Printer()->PrinterIndex = Printer()->Printers->IndexOf("Print to Fax on PRINTFAX:");
Printer()->BeginDoc();
Printer()->Canvas->TextOut(0, 150, "REPORT GIVEN TO CUSTOMER "+DateTimeToStr(Now()));
Printer()->EndDoc();
// Ficticious code here to call fax program to fax the file
// ...
// if (FaxWasSentSuccessfully) then
{
// Switch back to original printer object
SetPrinter(oldPrinter);
Printer()->BeginDoc();
Printer()->Canvas->TextOut(0, 150, "FAX CONFIRMATION REPORT");
// More code here to print results of our fictitious fax
// ....
// original configuration is still set to print two confirmations.
Printer()->EndDoc();
} // ~if (FaxWasSentSucessfully)
// Here we free the newPrinter object
// If we had not used SetPrinter to switch back to oldPrinter, we
// would free the oldPrinter object
newPrinter->Free();
bmInput->Free();
MessageBox(NULL,"Printed two reports, faxed report, and printed fax confirmation.",
"Printing Completed", MB_OK);
|
este ejemplo lo encontre en la siguiente direccion
http://www.interface.ru/fset.asp?Url=/borland/deicborl.htm
saludos y espero haberte ayudado... _________________
 |
|
| Volver arriba |
|
 |
Marky Master

Registrado: 28 Dic 2002Mensajes: 251Ubicación: Las Rozas - Madrid (España)
|
Publicado: Vie 05 Dic, 2003 11:38 pm Asunto: |
|
|
| ¿Has probado con: Printer()->PrinterIndex? |
|
| Volver arriba |
|
 |
Invitado
|
Publicado: Dom 07 Dic, 2003 7:41 pm Asunto: |
|
|
| lo provaré. gracias por su interes |
|
| Volver arriba |
|
 |
|
|
No puedes publicar temas nuevos en este foro No puedes responder a temas en este foro No puedes editar tus mensajes en este foro No puedes borrar tus mensajes en este foro No puedes votar en las encuestas de este foro
|
© 2002–2026 Club Builder · Funciona con phpBB.
|