Hi Robertmdc
Probably the following code snippet in VB6 will help. but the result still depends on the printer resolution (BTW: I use the VSPrinter as canvas control):
Public Sub DrawChart(VSPrinter1 As VSPrinter, ChartControl1 As ChartControl, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long, Optional ByVal AsBitmap_OK As Boolean = False) Const MM_ISOTROPIC = 7 Const MM_ANISOTROPIC = 8 Dim Path As String Dim OldMapMode As Long Dim OldVE As POINTAPI Dim OldWE As POINTAPI Dim OldOrg As POINTAPI Dim OldSize As POINTAPI Dim PW As Long Dim ph As Long If AsBitmap_OK Then Path = GetTempPathName() + ".BMP" Call ChartControl1.SaveAsImage(Path, (x2 - x1) / Screen.TwipsPerPixelX, (y2 - y1) / Screen.TwipsPerPixelY) Call VSPrinter1.DrawPicture(LoadPicture(Path), x1, y1, x2 - x1, y2 - y1) Call KillFiles(Path) Else PW = (VSPrinter1.PageWidth - 1440) / VSPrinter1.TwipsPerPixelX ph = (VSPrinter1.PageHeight - 1440) / VSPrinter1.TwipsPerPixelY / 3 OldMapMode = SetMapMode(VSPrinter1.hDC, MM_ISOTROPIC) Call SetWindowOrgEx(VSPrinter1.hDC, 0, 0, OldOrg) Call SetWindowExtEx(VSPrinter1.hDC, PW, ph, OldWE) Call SetViewportExtEx(VSPrinter1.hDC, PW / 100, ph / 100, OldVE) Call ScaleViewportExtEx(VSPrinter1.hDC, 1200 / VSPrinter1.TwipsPerPixelX, 1, 1200 / VSPrinter1.TwipsPerPixelY, 1, OldSize) Call ChartControl1.PrintToDC(VSPrinter1.hDC, x1 / 12, y1 / 12, (x2 - x1) / 12, (y2 - y1) / 12) Call SetWindowOrgEx(VSPrinter1.hDC, OldOrg.x, OldOrg.y, OldOrg) Call SetViewportExtEx(VSPrinter1.hDC, OldVE.x, OldVE.y, 0) Call SetWindowExtEx(VSPrinter1.hDC, OldWE.x, OldWE.y, 0) Call SetMapMode(VSPrinter1.hDC, OldMapMode) End If End Sub
------------- Product: Xtreme SuitePro (ActiveX) version 16.2.3
Platform: Windows 7 (32bit)
Language: Visual Basic 6.0 / SP6
|