home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 6 / mastvb6.iso / ch_code / appx_b / dataedit / dataedit.frm (.txt) next >
Encoding:
Visual Basic Form  |  1998-07-03  |  16.4 KB  |  480 lines

  1. VERSION 5.00
  2. Object = "{02B5E320-7292-11CF-93D5-0020AF99504A}#2.0#0"; "MSCHRT20.OCX"
  3. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  4. Begin VB.Form frmGRAPHEdit 
  5.    Caption         =   "Chart Data Editing"
  6.    ClientHeight    =   7305
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   10080
  10.    BeginProperty Font 
  11.       Name            =   "Verdana"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    LinkTopic       =   "Form1"
  20.    ScaleHeight     =   7305
  21.    ScaleWidth      =   10080
  22.    StartUpPosition =   3  'Windows Default
  23.    Begin MSChartLib.MSChart MSChart1 
  24.       Height          =   4650
  25.       Left            =   150
  26.       OleObjectBlob   =   "DataEdit.frx":0000
  27.       TabIndex        =   0
  28.       Top             =   120
  29.       Width           =   7035
  30.    End
  31.    Begin VB.CommandButton bttnPsteBMP 
  32.       Caption         =   "Paste Graph Bitmap"
  33.       BeginProperty Font 
  34.          Name            =   "Verdana"
  35.          Size            =   9.75
  36.          Charset         =   0
  37.          Weight          =   400
  38.          Underline       =   0   'False
  39.          Italic          =   0   'False
  40.          Strikethrough   =   0   'False
  41.       EndProperty
  42.       Height          =   465
  43.       Left            =   7425
  44.       TabIndex        =   18
  45.       Top             =   6075
  46.       Width           =   2475
  47.    End
  48.    Begin VB.CommandButton bttnPaste 
  49.       Caption         =   "Paste Data"
  50.       BeginProperty Font 
  51.          Name            =   "Verdana"
  52.          Size            =   9.75
  53.          Charset         =   0
  54.          Weight          =   400
  55.          Underline       =   0   'False
  56.          Italic          =   0   'False
  57.          Strikethrough   =   0   'False
  58.       EndProperty
  59.       Height          =   465
  60.       Left            =   7425
  61.       TabIndex        =   17
  62.       Top             =   5520
  63.       Width           =   2475
  64.    End
  65.    Begin VB.CommandButton bttnCopy 
  66.       Caption         =   "Copy Data"
  67.       BeginProperty Font 
  68.          Name            =   "Verdana"
  69.          Size            =   9.75
  70.          Charset         =   0
  71.          Weight          =   400
  72.          Underline       =   0   'False
  73.          Italic          =   0   'False
  74.          Strikethrough   =   0   'False
  75.       EndProperty
  76.       Height          =   465
  77.       Left            =   7425
  78.       TabIndex        =   16
  79.       Top             =   4980
  80.       Width           =   2475
  81.    End
  82.    Begin VB.TextBox Text1 
  83.       BeginProperty Font 
  84.          Name            =   "MS Sans Serif"
  85.          Size            =   8.25
  86.          Charset         =   0
  87.          Weight          =   400
  88.          Underline       =   0   'False
  89.          Italic          =   0   'False
  90.          Strikethrough   =   0   'False
  91.       EndProperty
  92.       Height          =   285
  93.       Left            =   75
  94.       TabIndex        =   2
  95.       Text            =   "Text1"
  96.       Top             =   4785
  97.       Visible         =   0   'False
  98.       Width           =   1170
  99.    End
  100.    Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
  101.       Height          =   2190
  102.       Left            =   720
  103.       TabIndex        =   1
  104.       Top             =   5010
  105.       Width           =   5475
  106.       _ExtentX        =   9657
  107.       _ExtentY        =   3863
  108.       _Version        =   393216
  109.       Rows            =   11
  110.       Cols            =   5
  111.    End
  112.    Begin VB.Frame Frame1 
  113.       BeginProperty Font 
  114.          Name            =   "MS Sans Serif"
  115.          Size            =   8.25
  116.          Charset         =   0
  117.          Weight          =   400
  118.          Underline       =   0   'False
  119.          Italic          =   0   'False
  120.          Strikethrough   =   0   'False
  121.       EndProperty
  122.       Height          =   4095
  123.       Left            =   7365
  124.       TabIndex        =   3
  125.       Top             =   30
  126.       Width           =   2520
  127.       Begin VB.OptionButton ChartType 
  128.          Caption         =   "3D Bar"
  129.          BeginProperty Font 
  130.             Name            =   "Verdana"
  131.             Size            =   9
  132.             Charset         =   0
  133.             Weight          =   400
  134.             Underline       =   0   'False
  135.             Italic          =   0   'False
  136.             Strikethrough   =   0   'False
  137.          EndProperty
  138.          Height          =   270
  139.          Index           =   0
  140.          Left            =   210
  141.          TabIndex        =   15
  142.          Top             =   240
  143.          Width           =   1440
  144.       End
  145.       Begin VB.OptionButton ChartType 
  146.          Caption         =   "2D Bar"
  147.          BeginProperty Font 
  148.             Name            =   "Verdana"
  149.             Size            =   9
  150.             Charset         =   0
  151.             Weight          =   400
  152.             Underline       =   0   'False
  153.             Italic          =   0   'False
  154.             Strikethrough   =   0   'False
  155.          EndProperty
  156.          Height          =   270
  157.          Index           =   1
  158.          Left            =   210
  159.          TabIndex        =   14
  160.          Top             =   555
  161.          Value           =   -1  'True
  162.          Width           =   1440
  163.       End
  164.       Begin VB.OptionButton ChartType 
  165.          Caption         =   "3D Line"
  166.          BeginProperty Font 
  167.             Name            =   "Verdana"
  168.             Size            =   9
  169.             Charset         =   0
  170.             Weight          =   400
  171.             Underline       =   0   'False
  172.             Italic          =   0   'False
  173.             Strikethrough   =   0   'False
  174.          EndProperty
  175.          Height          =   270
  176.          Index           =   2
  177.          Left            =   210
  178.          TabIndex        =   13
  179.          Top             =   870
  180.          Width           =   1440
  181.       End
  182.       Begin VB.OptionButton ChartType 
  183.          Caption         =   "2D Line"
  184.          BeginProperty Font 
  185.             Name            =   "Verdana"
  186.             Size            =   9
  187.             Charset         =   0
  188.             Weight          =   400
  189.             Underline       =   0   'False
  190.             Italic          =   0   'False
  191.             Strikethrough   =   0   'False
  192.          EndProperty
  193.          Height          =   270
  194.          Index           =   3
  195.          Left            =   210
  196.          TabIndex        =   12
  197.          Top             =   1185
  198.          Width           =   1440
  199.       End
  200.       Begin VB.OptionButton ChartType 
  201.          Caption         =   "3D Area"
  202.          BeginProperty Font 
  203.             Name            =   "Verdana"
  204.             Size            =   9
  205.             Charset         =   0
  206.             Weight          =   400
  207.             Underline       =   0   'False
  208.             Italic          =   0   'False
  209.             Strikethrough   =   0   'False
  210.          EndProperty
  211.          Height          =   270
  212.          Index           =   4
  213.          Left            =   210
  214.          TabIndex        =   11
  215.          Top             =   1500
  216.          Width           =   1440
  217.       End
  218.       Begin VB.OptionButton ChartType 
  219.          Caption         =   "2D Area"
  220.          BeginProperty Font 
  221.             Name            =   "Verdana"
  222.             Size            =   9
  223.             Charset         =   0
  224.             Weight          =   400
  225.             Underline       =   0   'False
  226.             Italic          =   0   'False
  227.             Strikethrough   =   0   'False
  228.          EndProperty
  229.          Height          =   270
  230.          Index           =   5
  231.          Left            =   210
  232.          TabIndex        =   10
  233.          Top             =   1815
  234.          Width           =   1440
  235.       End
  236.       Begin VB.OptionButton ChartType 
  237.          Caption         =   "3D Step"
  238.          BeginProperty Font 
  239.             Name            =   "Verdana"
  240.             Size            =   9
  241.             Charset         =   0
  242.             Weight          =   400
  243.             Underline       =   0   'False
  244.             Italic          =   0   'False
  245.             Strikethrough   =   0   'False
  246.          EndProperty
  247.          Height          =   270
  248.          Index           =   6
  249.          Left            =   210
  250.          TabIndex        =   9
  251.          Top             =   2130
  252.          Width           =   1440
  253.       End
  254.       Begin VB.OptionButton ChartType 
  255.          Caption         =   "2D Step"
  256.          BeginProperty Font 
  257.             Name            =   "Verdana"
  258.             Size            =   9
  259.             Charset         =   0
  260.             Weight          =   400
  261.             Underline       =   0   'False
  262.             Italic          =   0   'False
  263.             Strikethrough   =   0   'False
  264.          EndProperty
  265.          Height          =   270
  266.          Index           =   7
  267.          Left            =   210
  268.          TabIndex        =   8
  269.          Top             =   2445
  270.          Width           =   1440
  271.       End
  272.       Begin VB.OptionButton ChartType 
  273.          Caption         =   "3D Combination"
  274.          BeginProperty Font 
  275.             Name            =   "Verdana"
  276.             Size            =   9
  277.             Charset         =   0
  278.             Weight          =   400
  279.             Underline       =   0   'False
  280.             Italic          =   0   'False
  281.             Strikethrough   =   0   'False
  282.          EndProperty
  283.          Height          =   270
  284.          Index           =   8
  285.          Left            =   210
  286.          TabIndex        =   7
  287.          Top             =   2745
  288.          Width           =   1815
  289.       End
  290.       Begin VB.OptionButton ChartType 
  291.          Caption         =   "2D Combination"
  292.          BeginProperty Font 
  293.             Name            =   "Verdana"
  294.             Size            =   9
  295.             Charset         =   0
  296.             Weight          =   400
  297.             Underline       =   0   'False
  298.             Italic          =   0   'False
  299.             Strikethrough   =   0   'False
  300.          EndProperty
  301.          Height          =   270
  302.          Index           =   9
  303.          Left            =   210
  304.          TabIndex        =   6
  305.          Top             =   3075
  306.          Width           =   1830
  307.       End
  308.       Begin VB.OptionButton ChartType 
  309.          Caption         =   "2D Pie"
  310.          BeginProperty Font 
  311.             Name            =   "Verdana"
  312.             Size            =   9
  313.             Charset         =   0
  314.             Weight          =   400
  315.             Underline       =   0   'False
  316.             Italic          =   0   'False
  317.             Strikethrough   =   0   'False
  318.          EndProperty
  319.          Height          =   270
  320.          Index           =   14
  321.          Left            =   210
  322.          TabIndex        =   5
  323.          Top             =   3390
  324.          Width           =   1440
  325.       End
  326.       Begin VB.OptionButton ChartType 
  327.          Caption         =   "2D X-Y"
  328.          BeginProperty Font 
  329.             Name            =   "Verdana"
  330.             Size            =   9
  331.             Charset         =   0
  332.             Weight          =   400
  333.             Underline       =   0   'False
  334.             Italic          =   0   'False
  335.             Strikethrough   =   0   'False
  336.          EndProperty
  337.          Height          =   270
  338.          Index           =   16
  339.          Left            =   210
  340.          TabIndex        =   4
  341.          Top             =   3705
  342.          Width           =   1440
  343.       End
  344.    End
  345. Attribute VB_Name = "frmGRAPHEdit"
  346. Attribute VB_GlobalNameSpace = False
  347. Attribute VB_Creatable = False
  348. Attribute VB_PredeclaredId = True
  349. Attribute VB_Exposed = False
  350. '  ******************************
  351. '  ******************************
  352. '  ** MASTERING VB6            **
  353. '  ** by Evangelos Petroutos   **
  354. '  ** SYBEX, 1998              **
  355. '  ******************************
  356. '  ******************************
  357. Private Sub bttnCopy_Click()
  358.     MSChart1.EditCopy
  359. End Sub
  360. Private Sub bttnPaste_Click()
  361. '   Paste clipboard's contents on the MSChart control
  362.     MSChart1.EditPaste
  363. '   Uncomment the following lines
  364. '   to print the type of the data on the Clipboard
  365.     Debug.Print "Bitmap = " & Clipboard.GetFormat(vbCFBitmap)
  366.     Debug.Print "MetaFile = " & Clipboard.GetFormat(vbCFMetafile)
  367.     Debug.Print "RTF = " & Clipboard.GetFormat(vbCFRTF)
  368. End Sub
  369. Private Sub bttnPsteBMP_Click()
  370. '   Paste chart's bitmap on the frmGRAPHBitmap.Picture1 control
  371.     frmGRAPHBitmap.Show
  372.     frmGRAPHBitmap.Picture1.Picture = Clipboard.GetData()
  373. End Sub
  374. Private Sub ChartType_Click(Index As Integer)
  375. '   Change the chart's type
  376. '   THIS CODE WORKS BECAUSE THE OPTION BUTTONS HAVE
  377. '   NON-CONSECUTIVE INDEX VALUES!
  378.     MSChart1.ChartType = Index
  379. End Sub
  380. Private Sub Form_Load()
  381.     Me.Show
  382.     Me.Refresh
  383.     MSFlexGrid1.Col = 0
  384. ' Set 1st column's width on the grid control
  385.     MSFlexGrid1.ColWidth(0) = TextWidth("POINT # 999")
  386. ' Display row titles on the first column of the grid
  387.     For irow = 1 To MSChart1.RowCount
  388.         MSFlexGrid1.Row = irow
  389.         MSFlexGrid1.Text = "POINT # " & irow
  390.     Next
  391. ' scan each column of the grid and ...
  392.     For icol = 1 To MSChart1.ColumnCount
  393.         MSChart1.Column = icol
  394.         MSFlexGrid1.Col = icol
  395.         MSFlexGrid1.Row = 0
  396.         ' ...set the column title
  397.         MSFlexGrid1.Text = "SET # " & icol
  398.         ' ...get chart's column's color assign it to the grid's column's
  399.         If MSChart1.ChartType <> VtChChartType2dLine Or MSChart1.ChartType <> VtChChartType3dLine Then
  400.             With MSChart1.Plot.SeriesCollection(icol).DataPoints(-1).Brush.FillColor
  401.                 clr = RGB(.Red, .Green, .Blue)
  402.             End With
  403.         Else
  404.             With MSChart1.Plot.SeriesCollection(icol).Pen.VtColor
  405.                 clr = RGB(.Red, .Green, .Blue)
  406.             End With
  407.         End If
  408. ' scan each row of the chart control,
  409. ' read its value and assign it to the matching cell of the grid
  410.         For irow = 1 To MSChart1.RowCount
  411.             MSChart1.Row = irow
  412.             MSFlexGrid1.Row = irow
  413.             MSFlexGrid1.Col = icol
  414.             MSFlexGrid1.Text = MSChart1.Data
  415.             MSFlexGrid1.CellBackColor = clr
  416.         Next
  417.     Next
  418. ' In case the chart is 3D, rotate it
  419.     MSChart1.Plot.View3d.Set 60, 30
  420. End Sub
  421. Private Sub MSChart1_PointSelected(Series As Integer, DataPoint As Integer, MouseFlags As Integer, Cancel As Integer)
  422. ' get the chart's selected point's coordinates
  423. ' and use them to select a cell on the grid. Then call
  424. ' the SetTextBox subroutine to prepare the cell for editing
  425.     MSChart1.Column = Series
  426.     MSChart1.Row = DataPoint
  427.     MSFlexGrid1.Row = MSChart1.Row
  428.     MSFlexGrid1.Col = MSChart1.Column
  429.     SetTextBox
  430. End Sub
  431. Private Sub MSFlexGrid1_Click()
  432. ' prepare another grid cell for editing
  433.     MSChart1.Row = MSFlexGrid1.Row
  434.     MSChart1.Column = MSFlexGrid1.Col
  435.     SetTextBox
  436. End Sub
  437. Private Sub MSFlexGrid1_Scroll()
  438. ' This handler ends the editing of the current cell
  439. ' when the grid control is scrolled
  440. ' Remove this line to see what happens when
  441. ' the FlexGrid control is scrolled
  442.     Text1_KeyPress (13)
  443. End Sub
  444. Private Sub Text1_Change()
  445. ' comit changes made to the TextBox control
  446. ' by copying its value to the active cell
  447.     MSFlexGrid1.Text = Text1.Text
  448. End Sub
  449. Private Sub Text1_KeyPress(KeyAscii As Integer)
  450. ' The Enter key ends the editing of the current cell
  451.     If KeyAscii = 13 And Text1.Visible = True Then
  452.         Text1.Visible = False
  453.         MSChart1.Data = Text1.Text
  454.     End If
  455. End Sub
  456. Private Sub Text1_LostFocus()
  457. ' When the TextBox loses the focus, the editing of the current cell ends
  458.     Text1.Visible = False
  459.     MSChart1.Data = Text1.Text
  460. End Sub
  461. Sub SetTextBox()
  462. ' This subroutine resizes the TextBox according to the size
  463. ' of the current cell and places it on top of it, so that
  464. ' the user thinks he's editing a cell on the grid, not the TextBox
  465.     ' Set the TextBox control's coordinates
  466.     Text1.Left = MSFlexGrid1.Left + MSFlexGrid1.CellLeft
  467.     Text1.Top = MSFlexGrid1.Top + MSFlexGrid1.CellTop
  468.     ' Set the TextBox control's size
  469.     Text1.Width = MSFlexGrid1.CellWidth
  470.     Text1.Height = MSFlexGrid1.CellHeight
  471.     ' copy the cell's contents to the TextBox and select it
  472.     Text1.Text = MSFlexGrid1.Text
  473.     Text1.SelStart = 0
  474.     Text1.SelLength = Len(Text1.Text)
  475.     ' make the TextBox visible
  476.     Text1.Visible = True
  477.     ' and finally move the focus to the TextBox control
  478.     Text1.SetFocus
  479. End Sub
  480.