home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 128 - Disc 1 / dpcs1098a.iso / Ocx / VCFIMP / VCIMPRES.Z / CHDRAW.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-11-01  |  12.8 KB  |  361 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "First Impression Draw to hDC Example"
  6.    ClientHeight    =   6570
  7.    ClientLeft      =   1305
  8.    ClientTop       =   1485
  9.    ClientWidth     =   9540
  10.    BeginProperty Font 
  11.       name            =   "MS Sans Serif"
  12.       charset         =   0
  13.       weight          =   700
  14.       size            =   8.25
  15.       underline       =   0   'False
  16.       italic          =   0   'False
  17.       strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   7035
  21.    Icon            =   "CHDRAW.frx":0000
  22.    Left            =   1215
  23.    LinkTopic       =   "Form1"
  24.    ScaleHeight     =   6570
  25.    ScaleWidth      =   9540
  26.    Top             =   1110
  27.    Width           =   9720
  28.    Begin Threed.SSPanel pnlControls 
  29.       Height          =   6435
  30.       Left            =   6240
  31.       TabIndex        =   1
  32.       Top             =   60
  33.       Width           =   3195
  34.       _Version        =   65536
  35.       _ExtentX        =   5636
  36.       _ExtentY        =   11351
  37.       _StockProps     =   15
  38.       BevelOuter      =   0
  39.       BevelInner      =   1
  40.       Begin VB.PictureBox Picture1 
  41.          Appearance      =   0  'Flat
  42.          AutoRedraw      =   -1  'True
  43.          BackColor       =   &H80000005&
  44.          ClipControls    =   0   'False
  45.          ForeColor       =   &H80000008&
  46.          Height          =   3195
  47.          Left            =   120
  48.          ScaleHeight     =   3165
  49.          ScaleWidth      =   2925
  50.          TabIndex        =   11
  51.          Top             =   120
  52.          Width           =   2955
  53.       End
  54.       Begin VB.Frame Frame1 
  55.          Caption         =   " Draw To: "
  56.          BeginProperty Font 
  57.             name            =   "Arial"
  58.             charset         =   0
  59.             weight          =   400
  60.             size            =   8.25
  61.             underline       =   0   'False
  62.             italic          =   0   'False
  63.             strikethrough   =   0   'False
  64.          EndProperty
  65.          Height          =   795
  66.          Index           =   2
  67.          Left            =   480
  68.          TabIndex        =   8
  69.          Top             =   5400
  70.          Width           =   2235
  71.          Begin VB.CommandButton cmdPrinter 
  72.             Caption         =   "Printer"
  73.             BeginProperty Font 
  74.                name            =   "Arial"
  75.                charset         =   0
  76.                weight          =   400
  77.                size            =   8.25
  78.                underline       =   0   'False
  79.                italic          =   0   'False
  80.                strikethrough   =   0   'False
  81.             EndProperty
  82.             Height          =   375
  83.             Left            =   1200
  84.             TabIndex        =   10
  85.             Top             =   300
  86.             Width           =   915
  87.          End
  88.          Begin VB.CommandButton cmdPicture 
  89.             Caption         =   "Picture"
  90.             BeginProperty Font 
  91.                name            =   "Arial"
  92.                charset         =   0
  93.                weight          =   400
  94.                size            =   8.25
  95.                underline       =   0   'False
  96.                italic          =   0   'False
  97.                strikethrough   =   0   'False
  98.             EndProperty
  99.             Height          =   375
  100.             Left            =   180
  101.             TabIndex        =   9
  102.             Top             =   300
  103.             Width           =   915
  104.          End
  105.       End
  106.       Begin VB.Frame Frame1 
  107.          Caption         =   " Chart Formatting "
  108.          BeginProperty Font 
  109.             name            =   "Arial"
  110.             charset         =   0
  111.             weight          =   400
  112.             size            =   8.25
  113.             underline       =   0   'False
  114.             italic          =   0   'False
  115.             strikethrough   =   0   'False
  116.          EndProperty
  117.          Height          =   795
  118.          Index           =   1
  119.          Left            =   480
  120.          TabIndex        =   5
  121.          Top             =   4500
  122.          Width           =   2235
  123.          Begin Threed.SSCheck chkStretch 
  124.             Height          =   195
  125.             Left            =   240
  126.             TabIndex        =   7
  127.             Top             =   480
  128.             Width           =   1755
  129.             _Version        =   65536
  130.             _ExtentX        =   3096
  131.             _ExtentY        =   344
  132.             _StockProps     =   78
  133.             Caption         =   "Scale To Fit"
  134.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  135.                name            =   "Arial"
  136.                charset         =   0
  137.                weight          =   400
  138.                size            =   8.25
  139.                underline       =   0   'False
  140.                italic          =   0   'False
  141.                strikethrough   =   0   'False
  142.             EndProperty
  143.          End
  144.          Begin Threed.SSCheck chkLayout 
  145.             Height          =   255
  146.             Left            =   240
  147.             TabIndex        =   6
  148.             Top             =   240
  149.             Width           =   1755
  150.             _Version        =   65536
  151.             _ExtentX        =   3096
  152.             _ExtentY        =   450
  153.             _StockProps     =   78
  154.             Caption         =   "Layout For New DC"
  155.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  156.                name            =   "Arial"
  157.                charset         =   0
  158.                weight          =   400
  159.                size            =   8.25
  160.                underline       =   0   'False
  161.                italic          =   0   'False
  162.                strikethrough   =   0   'False
  163.             EndProperty
  164.          End
  165.       End
  166.       Begin VB.Frame Frame1 
  167.          Caption         =   " Text Metrics "
  168.          BeginProperty Font 
  169.             name            =   "Arial"
  170.             charset         =   0
  171.             weight          =   400
  172.             size            =   8.25
  173.             underline       =   0   'False
  174.             italic          =   0   'False
  175.             strikethrough   =   0   'False
  176.          EndProperty
  177.          Height          =   795
  178.          Index           =   0
  179.          Left            =   480
  180.          TabIndex        =   2
  181.          Top             =   3540
  182.          Width           =   2235
  183.          Begin Threed.SSOption optTextMetrics 
  184.             Height          =   195
  185.             Index           =   0
  186.             Left            =   240
  187.             TabIndex        =   4
  188.             Top             =   240
  189.             Width           =   975
  190.             _Version        =   65536
  191.             _ExtentX        =   1720
  192.             _ExtentY        =   344
  193.             _StockProps     =   78
  194.             Caption         =   "Screen"
  195.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  196.                name            =   "Arial"
  197.                charset         =   0
  198.                weight          =   400
  199.                size            =   8.25
  200.                underline       =   0   'False
  201.                italic          =   0   'False
  202.                strikethrough   =   0   'False
  203.             EndProperty
  204.          End
  205.          Begin Threed.SSOption optTextMetrics 
  206.             Height          =   195
  207.             Index           =   1
  208.             Left            =   240
  209.             TabIndex        =   3
  210.             Top             =   480
  211.             Width           =   975
  212.             _Version        =   65536
  213.             _ExtentX        =   1720
  214.             _ExtentY        =   344
  215.             _StockProps     =   78
  216.             Caption         =   "Printer"
  217.             BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  218.                name            =   "Arial"
  219.                charset         =   0
  220.                weight          =   400
  221.                size            =   8.25
  222.                underline       =   0   'False
  223.                italic          =   0   'False
  224.                strikethrough   =   0   'False
  225.             EndProperty
  226.             Value           =   -1  'True
  227.          End
  228.       End
  229.    End
  230.    Begin VCIFiLib.VtChart VtChart1 
  231.       Height          =   6315
  232.       Left            =   120
  233.       TabIndex        =   0
  234.       Top             =   120
  235.       Width           =   5955
  236.       _version        =   65536
  237.       _extentx        =   10504
  238.       _extenty        =   11139
  239.       _stockprops     =   96
  240.       borderstyle     =   1
  241.       filename        =   "CHDRAW.frx":030A
  242.    End
  243. Attribute VB_Name = "Form1"
  244. Attribute VB_Creatable = False
  245. Attribute VB_Exposed = False
  246. Option Explicit
  247. Private Sub chkLayout_Click(Value As Integer)
  248.     ' Scaled is only used if Layout is False
  249.     chkStretch.Enabled = Not (chkLayout.Value)
  250. End Sub
  251. Private Sub cmdPicture_Click()
  252.    On Error GoTo DrawPictureError
  253.    Dim top%, left%, bottom%, right%
  254.    ' Set the destination to the entire picture box.
  255.    ' Convert from twips (default) to pixels with the
  256.    ' Screen.TwipsPerPixelX property. Note that you can
  257.    ' suffer roundoff error here so you may want to pad
  258.    ' the width and height.
  259.    top = Picture1.ScaleTop / Screen.TwipsPerPixelY
  260.    left = Picture1.ScaleLeft / Screen.TwipsPerPixelX
  261.    bottom = Picture1.ScaleHeight / Screen.TwipsPerPixelY + 2
  262.    right = Picture1.ScaleWidth / Screen.TwipsPerPixelX + 2
  263.    ' Clear out the old image
  264.    Picture1.Cls
  265.    ' Use the check boxes for args so we can readily see how
  266.    ' each possiblity affects the image.
  267.    VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
  268.       bottom, right, chkLayout.Value, chkStretch.Value
  269.       
  270.    Exit Sub
  271. DrawPictureError:
  272.    MsgBox Error
  273. End Sub
  274. Private Sub cmdPrinter_Click()
  275.    On Error GoTo DrawPrinterError
  276.    Dim top%, left%, bottom%, right%
  277.    Dim titleWidth&, titleHeight&
  278.    With Printer
  279.       ' Set the font and position a title on the page.
  280.       ' The chart already has a title -
  281.       ' this title is text drawn directly on the  object.
  282.       .FontSize = 48
  283.       .FontName = "Times New Roman"
  284.       .FontUnderline = True
  285.       titleWidth = .TextWidth("VtChDraw Example")
  286.       titleHeight = .TextHeight("VtChDraw Example")
  287.       
  288.       ' Center the text and move it down off the top margin
  289.       .CurrentX = .ScaleLeft + (.ScaleWidth - titleWidth) / 2
  290.       .CurrentY = 0.3 * titleHeight
  291.       ' Draw the text on the hDC
  292.       .Print "VtChDraw Example"
  293.       
  294.       ' Bounding rect for the chart. Place below Title and conert from twips to pixels.
  295.       top = (.ScaleTop + titleHeight) / .TwipsPerPixelY
  296.       left = .ScaleLeft / .TwipsPerPixelX
  297.       bottom = .ScaleHeight / .TwipsPerPixelY
  298.       right = .ScaleWidth / .TwipsPerPixelX
  299.       
  300.       ' Draw the chart on the  hDC using the option check boxes
  301.       ' as arguments
  302.       VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
  303.          bottom, right, chkLayout.Value, chkStretch.Value
  304.       
  305.       ' Use these to adjust the line drawings
  306.       '.DrawMode =
  307.       '.DrawStyle =
  308.       '.DrawWidth =
  309.       '.ForeColor =
  310.       
  311.       ' Draw a bounding box
  312.       Printer.Line (.ScaleLeft, .ScaleTop)-(.ScaleWidth, .ScaleTop)
  313.       Printer.Line (.ScaleWidth - 5, .ScaleTop)-(.ScaleWidth - 5, .ScaleHeight)
  314.       Printer.Line (.ScaleWidth - 5, .ScaleHeight - 5)-(.ScaleLeft, .ScaleHeight - 5)
  315.       Printer.Line (.ScaleLeft, .ScaleHeight - 5)-(.ScaleLeft, .ScaleTop)
  316.       
  317.       ' Feed a page and then flush it through the
  318.       .NewPage
  319.       .EndDoc
  320.    End With
  321.    Exit Sub
  322. DrawPrinterError:
  323.    MsgBox Error
  324. End Sub
  325. Private Sub Form_Load()
  326.    ' Put the form in the top left corner
  327.    Form1.left = 0
  328.    Form1.top = 0
  329.    pnlControls.top = 60
  330.    VtChart1.top = 120
  331. End Sub
  332. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  333.    End
  334. End Sub
  335. Private Sub Form_Resize()
  336.    VtChart1.Repaint = False
  337.    If ScaleHeight > 7200 Then
  338.       pnlControls.Height = ScaleHeight - 135
  339.       VtChart1.Height = ScaleHeight - 255
  340.    End If
  341.    If ScaleWidth > 4000 Then
  342.       pnlControls.left = ScaleWidth - pnlControls.Width - 60
  343.       VtChart1.Width = pnlControls.left - 235
  344.    End If
  345.    VtChart1.Repaint = True
  346. End Sub
  347. Private Sub optTextMetrics_Click(Index As Integer, Value As Integer)
  348. '' Screen and printer text metrics are different. If you
  349. '' draw to the screen, you will want to use virtual metrics
  350. '' (defined by the TrueType font). Otherwise use the device
  351. '' type which is optimized for your output device.
  352.    If Value Then
  353.       Select Case Index
  354.          Case 0
  355.             VtChart1.TextLengthType = VtTextLengthTypeVirtual
  356.          Case 1
  357.             VtChart1.TextLengthType = VtTextLengthTypeDevice
  358.       End Select
  359.    End If
  360. End Sub
  361.