Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GDIPlusX and Printing
Message
De
22/11/2007 08:59:41
 
 
À
03/04/2007 08:03:29
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:
01270670
Vues:
42
Hi Cesar,

You provided me with this code (see below) sample which worked great at the time you have send it to me, bit then when I come back t o it the other day gave me problem so perhaps it has to do
with some changes done to GdiPlusX library;

Code breaks at this point ;
	* Obtain a Graphics object based on the Printer HDC
	LOCAL loGraphics AS xfcGraphics
	m.lhGraphics = 0
	m.loPrintGraphics = NULL

	m.loPrintGraphics = loBmp.CreateNew("xfcGraphics")  &&<< 'Property CreateNew not found!'
	m.loPrintGraphics = m.loPrintGraphics.FromHdc(m.lnPrinterDC)
What happened here ?
Code You originally send me still works on another PC which have earlier
version of GdiPlusX so perhaps something got changed in the meanwhile.
I redownloaded GdiPlusX recently and with new version code breaks :((

Your original code;
_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
Pls Help

Sergio
*****************
Srdjan Djordjevic
Limassol, Cyprus

Free Reporting Framework for VFP9 ;
www.Report-Sculptor.Com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform