Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Chart Control
  New Posts New Posts RSS Feed - Very small chart using PrintToDC
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Very small chart using PrintToDC

 Post Reply Post Reply
Author
Message
robertmdc View Drop Down
Newbie
Newbie


Joined: 23 May 2011
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote robertmdc Quote  Post ReplyReply Direct Link To This Post Topic: Very small chart using PrintToDC
    Posted: 28 May 2011 at 5:00am
On screen, this is my chart:



To print, I use PrintToDC method (VB6):

  Printer.Print " ";
  ChartControl.PrintToDC Printer.hDC, 500, 500, 3000, 3000
  Printer.EndDoc

...on Printer



Why chart and labels are very small?
How to print chart like "wysiwhg" using PrintToDC method?





Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 30 May 2011 at 1:31pm
Most easy way is to use our PrintPreview control from CommandBars.
for 15.0.3 we added new methods to show PrintPreview and send to printer.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Fabian View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22 November 2004
Location: Switzerland
Status: Offline
Points: 336
Post Options Post Options   Thanks (0) Thanks(0)   Quote Fabian Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2011 at 9:54am
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
Back to Top
robertmdc View Drop Down
Newbie
Newbie


Joined: 23 May 2011
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote robertmdc Quote  Post ReplyReply Direct Link To This Post Posted: 31 May 2011 at 5:10pm
Hi Fabian
Thank you! Everything works fine!
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.219 seconds.