> * Obtain a Graphics object based on the Printer HDC > LOCAL loGraphics AS xfcGraphics > m.lhGraphics = 0 > m.loPrintGraphics = NULL > m.loPrintGraphics = .Graphics.FromHdc(m.lnPrinterDC) >>
do "system.prg">
>> * 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) >>>>
>>_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 >> >>>>