home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- Caption = "First Impression Draw to hDC Example"
- ClientHeight = 6570
- ClientLeft = 1305
- ClientTop = 1485
- ClientWidth = 9540
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 7035
- Icon = "CHDRAW.frx":0000
- Left = 1215
- LinkTopic = "Form1"
- ScaleHeight = 6570
- ScaleWidth = 9540
- Top = 1110
- Width = 9720
- Begin Threed.SSPanel pnlControls
- Height = 6435
- Left = 6240
- TabIndex = 1
- Top = 60
- Width = 3195
- _Version = 65536
- _ExtentX = 5636
- _ExtentY = 11351
- _StockProps = 15
- BevelOuter = 0
- BevelInner = 1
- Begin VB.PictureBox Picture1
- Appearance = 0 'Flat
- AutoRedraw = -1 'True
- BackColor = &H80000005&
- ClipControls = 0 'False
- ForeColor = &H80000008&
- Height = 3195
- Left = 120
- ScaleHeight = 3165
- ScaleWidth = 2925
- TabIndex = 11
- Top = 120
- Width = 2955
- End
- Begin VB.Frame Frame1
- Caption = " Draw To: "
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 795
- Index = 2
- Left = 480
- TabIndex = 8
- Top = 5400
- Width = 2235
- Begin VB.CommandButton cmdPrinter
- Caption = "Printer"
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 1200
- TabIndex = 10
- Top = 300
- Width = 915
- End
- Begin VB.CommandButton cmdPicture
- Caption = "Picture"
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 180
- TabIndex = 9
- Top = 300
- Width = 915
- End
- End
- Begin VB.Frame Frame1
- Caption = " Chart Formatting "
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 795
- Index = 1
- Left = 480
- TabIndex = 5
- Top = 4500
- Width = 2235
- Begin Threed.SSCheck chkStretch
- Height = 195
- Left = 240
- TabIndex = 7
- Top = 480
- Width = 1755
- _Version = 65536
- _ExtentX = 3096
- _ExtentY = 344
- _StockProps = 78
- Caption = "Scale To Fit"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- End
- Begin Threed.SSCheck chkLayout
- Height = 255
- Left = 240
- TabIndex = 6
- Top = 240
- Width = 1755
- _Version = 65536
- _ExtentX = 3096
- _ExtentY = 450
- _StockProps = 78
- Caption = "Layout For New DC"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- End
- End
- Begin VB.Frame Frame1
- Caption = " Text Metrics "
- BeginProperty Font
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 795
- Index = 0
- Left = 480
- TabIndex = 2
- Top = 3540
- Width = 2235
- Begin Threed.SSOption optTextMetrics
- Height = 195
- Index = 0
- Left = 240
- TabIndex = 4
- Top = 240
- Width = 975
- _Version = 65536
- _ExtentX = 1720
- _ExtentY = 344
- _StockProps = 78
- Caption = "Screen"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- End
- Begin Threed.SSOption optTextMetrics
- Height = 195
- Index = 1
- Left = 240
- TabIndex = 3
- Top = 480
- Width = 975
- _Version = 65536
- _ExtentX = 1720
- _ExtentY = 344
- _StockProps = 78
- Caption = "Printer"
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- name = "Arial"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Value = -1 'True
- End
- End
- End
- Begin VCIFiLib.VtChart VtChart1
- Height = 6315
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 5955
- _version = 65536
- _extentx = 10504
- _extenty = 11139
- _stockprops = 96
- borderstyle = 1
- filename = "CHDRAW.frx":030A
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub chkLayout_Click(Value As Integer)
- ' Scaled is only used if Layout is False
- chkStretch.Enabled = Not (chkLayout.Value)
- End Sub
- Private Sub cmdPicture_Click()
- On Error GoTo DrawPictureError
- Dim top%, left%, bottom%, right%
- ' Set the destination to the entire picture box.
- ' Convert from twips (default) to pixels with the
- ' Screen.TwipsPerPixelX property. Note that you can
- ' suffer roundoff error here so you may want to pad
- ' the width and height.
- top = Picture1.ScaleTop / Screen.TwipsPerPixelY
- left = Picture1.ScaleLeft / Screen.TwipsPerPixelX
- bottom = Picture1.ScaleHeight / Screen.TwipsPerPixelY + 2
- right = Picture1.ScaleWidth / Screen.TwipsPerPixelX + 2
- ' Clear out the old image
- Picture1.Cls
- ' Use the check boxes for args so we can readily see how
- ' each possiblity affects the image.
- VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
- bottom, right, chkLayout.Value, chkStretch.Value
-
- Exit Sub
- DrawPictureError:
- MsgBox Error
- End Sub
- Private Sub cmdPrinter_Click()
- On Error GoTo DrawPrinterError
- Dim top%, left%, bottom%, right%
- Dim titleWidth&, titleHeight&
- With Printer
- ' Set the font and position a title on the page.
- ' The chart already has a title -
- ' this title is text drawn directly on the object.
- .FontSize = 48
- .FontName = "Times New Roman"
- .FontUnderline = True
- titleWidth = .TextWidth("VtChDraw Example")
- titleHeight = .TextHeight("VtChDraw Example")
-
- ' Center the text and move it down off the top margin
- .CurrentX = .ScaleLeft + (.ScaleWidth - titleWidth) / 2
- .CurrentY = 0.3 * titleHeight
- ' Draw the text on the hDC
- .Print "VtChDraw Example"
-
- ' Bounding rect for the chart. Place below Title and conert from twips to pixels.
- top = (.ScaleTop + titleHeight) / .TwipsPerPixelY
- left = .ScaleLeft / .TwipsPerPixelX
- bottom = .ScaleHeight / .TwipsPerPixelY
- right = .ScaleWidth / .TwipsPerPixelX
-
- ' Draw the chart on the hDC using the option check boxes
- ' as arguments
- VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
- bottom, right, chkLayout.Value, chkStretch.Value
-
- ' Use these to adjust the line drawings
- '.DrawMode =
- '.DrawStyle =
- '.DrawWidth =
- '.ForeColor =
-
- ' Draw a bounding box
- Printer.Line (.ScaleLeft, .ScaleTop)-(.ScaleWidth, .ScaleTop)
- Printer.Line (.ScaleWidth - 5, .ScaleTop)-(.ScaleWidth - 5, .ScaleHeight)
- Printer.Line (.ScaleWidth - 5, .ScaleHeight - 5)-(.ScaleLeft, .ScaleHeight - 5)
- Printer.Line (.ScaleLeft, .ScaleHeight - 5)-(.ScaleLeft, .ScaleTop)
-
- ' Feed a page and then flush it through the
- .NewPage
- .EndDoc
- End With
- Exit Sub
- DrawPrinterError:
- MsgBox Error
- End Sub
- Private Sub Form_Load()
- ' Put the form in the top left corner
- Form1.left = 0
- Form1.top = 0
- pnlControls.top = 60
- VtChart1.top = 120
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- End
- End Sub
- Private Sub Form_Resize()
- VtChart1.Repaint = False
- If ScaleHeight > 7200 Then
- pnlControls.Height = ScaleHeight - 135
- VtChart1.Height = ScaleHeight - 255
- End If
- If ScaleWidth > 4000 Then
- pnlControls.left = ScaleWidth - pnlControls.Width - 60
- VtChart1.Width = pnlControls.left - 235
- End If
- VtChart1.Repaint = True
- End Sub
- Private Sub optTextMetrics_Click(Index As Integer, Value As Integer)
- '' Screen and printer text metrics are different. If you
- '' draw to the screen, you will want to use virtual metrics
- '' (defined by the TrueType font). Otherwise use the device
- '' type which is optimized for your output device.
- If Value Then
- Select Case Index
- Case 0
- VtChart1.TextLengthType = VtTextLengthTypeVirtual
- Case 1
- VtChart1.TextLengthType = VtTextLengthTypeDevice
- End Select
- End If
- End Sub
-