Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GDIPlusX and Printing
Message
De
03/04/2007 08:03:29
 
 
À
03/04/2007 04:31:13
Information générale
Forum:
Visual FoxPro
Catégorie:
VFPX/Sedna
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01210581
Message ID:
01211604
Vues:
61
>It printed 5 pages ok, BUT printer que showed 5 consecutive printing
>sessions :((
>Is there any way to do this (repetive print) as SINGLE PRINT JOB.
>That is what interest me the most. This would resolve my problem almost completely. >


Have a look at the codes below, there I adapted the previous sample that I sent to you. At the end, you'll see the Printing managing routines. It's all commented, very easy to understand.

Hope this helps

Cesar
_SCREEN.AddProperty("System", NEWOBJECT("xfcSystem", LOCFILE("system.vcx","vcx"))) 

WITH _SCREEN.System.Drawing

* Create a new Bitmap
LOCAL loBmp as xfcBitmap
loBmp = .Bitmap.New(150,150)

* Create a Graphics object associated to the bitmap
LOCAL loGfx as xfcGraphics
loGfx = .Graphics.FromImage(loBmp)

* "Clears" the background of the image to Red
loGfx.Clear(.Color.Red)

* Fills a Blue ellipse
loGfx.FillEllipse(.Brushes.Blue, 20,20,110,110)

* Draw a string to the image
loGfx.DrawString("GdiPlusX is cool !", ;
	.Font.New("Verdana", 12, .FontStyle.BoldItalic), ;
	.SolidBrush.New(.Color.FromRGB(255,255,255)), ;
	0, 0)

* Saves the image to Disk
loBmp.Save("c:\GdiPlusXTest.png", .Imaging.ImageFormat.Png)

* Show the image in IE
RUN /N Explorer.exe c:\GdiPlusXTest.png



* API Declarations for direct printing
DECLARE INTEGER CreateDC IN WIN32API STRING cDriver, STRING cDevice, STRING cOutput, STRING @cInitData
DECLARE INTEGER DeleteDC IN Win32API INTEGER nDC
DECLARE INTEGER StartPage IN GDI32 INTEGER hdc
DECLARE INTEGER EndPage IN GDI32 INTEGER hdc
DECLARE INTEGER EndDoc IN GDI32 INTEGER hdc
DECLARE INTEGER StartDoc IN GDI32 INTEGER hdc, STRING lpdi


LOCAL lnPrinterDC, lcDocInfo

* Get Printer name
m.tcPrinterName = SET("Printer",3)
m.tlFitToPage = .F.

* Get Printer DC for the selected Printer
m.lnPrinterDC = CreateDC(NULL, m.tcPrinterName+0h00, NULL, NULL)

* Get the dimensions of the Image
m.lnWidth = loBmp.Width
m.lnHeight = loBmp.Height

* Start Printing
IF m.lnPrinterDC <> 0
	m.lcDocInfo = PADR(CHR(20), 20, CHR(0)) && Fake DocInfo Struct

	* Obtain a Graphics object based on the Printer HDC
	LOCAL loGraphics AS xfcGraphics
	m.lhGraphics = 0
	m.loPrintGraphics = NULL

	m.loPrintGraphics = loBmp.CreateNew("xfcGraphics")
	m.loPrintGraphics = m.loPrintGraphics.FromHdc(m.lnPrinterDC)


*--------------------------------------------

	* Start print job
	StartDoc(m.lnprinterdc, m.lcdocinfo)

*--------------------------------------------

	* Start new page
	StartPage(m.lnprinterdc)

	* Draw the image to 1st page
	loPrintGraphics.DrawImage(loBmp, 0, 0, m.lnWidth, m.lnHeight)

	loPrintGraphics.DrawString("This is the FIRST page !", ;
		.Font.New("Verdana", 20, .FontStyle.BoldItalic), ;
		.Brushes.Black, 0, 200)

	* Finish 1st page
	EndPage(m.lnPrinterDC)

*--------------------------------------------

	* Start new page
	StartPage(m.lnprinterdc)

	* Draw the image to 2nd page
	loPrintGraphics.DrawImage(loBmp, 0, 0, m.lnWidth, m.lnHeight)

	loPrintGraphics.DrawString("This is the second page !", ;
		.Font.New("Verdana", 20, .FontStyle.BoldItalic), ;
		.Brushes.Black, 0, 200)

	* Finish page
	EndPage(m.lnPrinterDC)

*--------------------------------------------

	* Start new page
	StartPage(m.lnprinterdc)

	* Draw the image to 2nd page
	loPrintGraphics.DrawImage(loBmp, 0, 0, m.lnWidth, m.lnHeight)

	loPrintGraphics.DrawString("AVE SERGIO !!! - THIRD page !", ;
		.Font.New("Courier New", 24), ;
		.Brushes.Black, 0, 200)

	* Finish page
	EndPage(m.lnPrinterDC)

*--------------------------------------------

	* End of Print Job
	EndDoc(m.lnPrinterDC)

	* Clearing handle
	DeleteDC(m.lnPrinterDC)

ENDIF

ENDWITH 

RETURN
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform