home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / componen / vsflex / demo / fmerge.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-06-17  |  10.3 KB  |  336 lines

  1. VERSION 2.00
  2. Begin Form fMerge 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   3  'Fixed Double
  5.    Caption         =   "Summary Sheet"
  6.    ClientHeight    =   5745
  7.    ClientLeft      =   915
  8.    ClientTop       =   1155
  9.    ClientWidth     =   8115
  10.    Height          =   6150
  11.    Left            =   855
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   5745
  14.    ScaleWidth      =   8115
  15.    Top             =   810
  16.    Width           =   8235
  17.    Begin OptionButton Option1 
  18.       BackColor       =   &H00C0C0C0&
  19.       Caption         =   "VSFlex"
  20.       FontBold        =   -1  'True
  21.       FontItalic      =   0   'False
  22.       FontName        =   "Arial"
  23.       FontSize        =   9.75
  24.       FontStrikethru  =   0   'False
  25.       FontUnderline   =   0   'False
  26.       ForeColor       =   &H00000000&
  27.       Height          =   330
  28.       Index           =   1
  29.       Left            =   450
  30.       TabIndex        =   8
  31.       Top             =   1710
  32.       Width           =   1245
  33.    End
  34.    Begin Frame Frame1 
  35.       BackColor       =   &H00C0C0C0&
  36.       Enabled         =   0   'False
  37.       FontBold        =   0   'False
  38.       FontItalic      =   0   'False
  39.       FontName        =   "MS Sans Serif"
  40.       FontSize        =   8.25
  41.       FontStrikethru  =   0   'False
  42.       FontUnderline   =   0   'False
  43.       ForeColor       =   &H00FF0000&
  44.       Height          =   1500
  45.       Left            =   360
  46.       TabIndex        =   4
  47.       Top             =   1740
  48.       Width           =   1935
  49.       Begin CheckBox chkPictures 
  50.          BackColor       =   &H00C0C0C0&
  51.          Caption         =   "Add Pictures"
  52.          Enabled         =   0   'False
  53.          FontBold        =   0   'False
  54.          FontItalic      =   0   'False
  55.          FontName        =   "MS Sans Serif"
  56.          FontSize        =   8.25
  57.          FontStrikethru  =   0   'False
  58.          FontUnderline   =   0   'False
  59.          ForeColor       =   &H00000000&
  60.          Height          =   225
  61.          Left            =   390
  62.          TabIndex        =   7
  63.          Top             =   420
  64.          Width           =   1245
  65.       End
  66.       Begin CheckBox chkMergeCells 
  67.          BackColor       =   &H00C0C0C0&
  68.          Caption         =   "Merge Cells"
  69.          Enabled         =   0   'False
  70.          FontBold        =   0   'False
  71.          FontItalic      =   0   'False
  72.          FontName        =   "MS Sans Serif"
  73.          FontSize        =   8.25
  74.          FontStrikethru  =   0   'False
  75.          FontUnderline   =   0   'False
  76.          ForeColor       =   &H00000000&
  77.          Height          =   225
  78.          Left            =   405
  79.          TabIndex        =   6
  80.          Top             =   675
  81.          Width           =   1350
  82.       End
  83.       Begin CommandButton Command1 
  84.          BackColor       =   &H00C0C0C0&
  85.          Caption         =   "Drag && Drop"
  86.          Enabled         =   0   'False
  87.          FontBold        =   0   'False
  88.          FontItalic      =   0   'False
  89.          FontName        =   "MS Sans Serif"
  90.          FontSize        =   8.25
  91.          FontStrikethru  =   0   'False
  92.          FontUnderline   =   0   'False
  93.          Height          =   345
  94.          Left            =   390
  95.          TabIndex        =   5
  96.          Top             =   1020
  97.          Width           =   1095
  98.       End
  99.    End
  100.    Begin OptionButton Option1 
  101.       BackColor       =   &H00C0C0C0&
  102.       Caption         =   "Plain Grid"
  103.       FontBold        =   -1  'True
  104.       FontItalic      =   0   'False
  105.       FontName        =   "Arial"
  106.       FontSize        =   9.75
  107.       FontStrikethru  =   0   'False
  108.       FontUnderline   =   0   'False
  109.       ForeColor       =   &H00000000&
  110.       Height          =   330
  111.       Index           =   0
  112.       Left            =   465
  113.       TabIndex        =   3
  114.       Top             =   1350
  115.       Value           =   -1  'True
  116.       Width           =   1515
  117.    End
  118.    Begin vsFlexArray fa 
  119.       BackColor       =   &H00C0C0C0&
  120.       BackColorFixed  =   &H00000000&
  121.       Cols            =   4
  122.       ConvInfo        =   FMERGE.FRX:0000
  123.       DragIcon        =   FMERGE.FRX:000B
  124.       FixedCols       =   0
  125.       FocusRect       =   0  'None
  126.       FontBold        =   0   'False
  127.       FontItalic      =   0   'False
  128.       FontName        =   "Arial"
  129.       FontSize        =   9.75
  130.       FontStrikethru  =   0   'False
  131.       FontUnderline   =   0   'False
  132.       ForeColorFixed  =   &H0000FF00&
  133.       FormatString    =   "^Region            |^Product       |^Employee    |>Sales            "
  134.       GridColor       =   &H00008080&
  135.       GridLines       =   2  'Inset
  136.       Height          =   4650
  137.       HighLight       =   0  'Never
  138.       Left            =   2700
  139.       RowHeightMin    =   420
  140.       Rows            =   11
  141.       ScrollBars      =   0  'None
  142.       ScrollTrack     =   -1  'True
  143.       TabIndex        =   0
  144.       Top             =   810
  145.       Width           =   5130
  146.    End
  147.    Begin Label Label2 
  148.       Alignment       =   2  'Center
  149.       BackColor       =   &H00C0C0C0&
  150.       BackStyle       =   0  'Transparent
  151.       Caption         =   "See summary as:"
  152.       FontBold        =   -1  'True
  153.       FontItalic      =   0   'False
  154.       FontName        =   "Arial"
  155.       FontSize        =   13.5
  156.       FontStrikethru  =   0   'False
  157.       FontUnderline   =   0   'False
  158.       ForeColor       =   &H00000000&
  159.       Height          =   585
  160.       Index           =   0
  161.       Left            =   270
  162.       TabIndex        =   2
  163.       Top             =   675
  164.       Width           =   1935
  165.    End
  166.    Begin Image flag 
  167.       Height          =   480
  168.       Index           =   3
  169.       Left            =   810
  170.       Picture         =   FMERGE.FRX:030D
  171.       Top             =   4860
  172.       Visible         =   0   'False
  173.       Width           =   480
  174.    End
  175.    Begin Image flag 
  176.       Height          =   480
  177.       Index           =   2
  178.       Left            =   195
  179.       Picture         =   FMERGE.FRX:060F
  180.       Top             =   4875
  181.       Visible         =   0   'False
  182.       Width           =   480
  183.    End
  184.    Begin Image flag 
  185.       Height          =   480
  186.       Index           =   1
  187.       Left            =   2010
  188.       Picture         =   FMERGE.FRX:0911
  189.       Top             =   4875
  190.       Visible         =   0   'False
  191.       Width           =   480
  192.    End
  193.    Begin Image flag 
  194.       Height          =   480
  195.       Index           =   0
  196.       Left            =   1335
  197.       Top             =   4905
  198.       Visible         =   0   'False
  199.       Width           =   480
  200.    End
  201.    Begin Label Label1 
  202.       Alignment       =   2  'Center
  203.       BackColor       =   &H00000000&
  204.       Caption         =   "Summary"
  205.       FontBold        =   -1  'True
  206.       FontItalic      =   0   'False
  207.       FontName        =   "Arial"
  208.       FontSize        =   24
  209.       FontStrikethru  =   0   'False
  210.       FontUnderline   =   0   'False
  211.       ForeColor       =   &H0000FFFF&
  212.       Height          =   585
  213.       Left            =   2670
  214.       TabIndex        =   1
  215.       Top             =   165
  216.       Width           =   5175
  217.    End
  218. Option Explicit
  219. Sub chkMergeCells_Click ()
  220.     If fa.MergeCells = 0 Then
  221.         fa.MergeCells = 2
  222.     Else
  223.         fa.MergeCells = 0
  224.     End If
  225. End Sub
  226. Sub chkPictures_Click ()
  227.    Dim i%
  228.    fa.Row = 0
  229.    For i = 0 To 3
  230.       ' find "Country" column
  231.       fa.Col = i
  232.       If Trim(fa) = "Country" Then Exit For
  233.    Next i
  234.    If chkPictures Then
  235.       DoAddFlagsToColumn (fa.Col)
  236.    Else
  237.       DoRemoveFlagsFrom (fa.Col)
  238.    End If
  239. End Sub
  240. Sub Command1_Click ()
  241.    MsgBox "Drag and drop column's headers and see the data automatically rearranged"
  242. End Sub
  243. Sub DoAddFlagsToColumn (Col)
  244.    Dim i%
  245.    fa.Col = Col
  246.    For i = 1 To NUMREC - 1
  247.       fa.Row = i
  248.       fa.CellPictureAlignment = 1
  249.       Select Case fa
  250.          Case "USA": fa.CellPicture = flag(1)
  251.          Case "Canada": fa.CellPicture = flag(2)
  252.          Case "Germany": fa.CellPicture = flag(3)
  253.       End Select
  254.    Next i
  255. End Sub
  256. Sub DoFillData ()
  257.    Dim i%
  258.    ' from structure to FlexArray
  259.     For i = 0 To NUMREC - 1
  260.       fa.TextArray(fai(i, 0)) = MyData(i).Country
  261.       fa.TextArray(fai(i, 1)) = MyData(i).Product
  262.       fa.TextArray(fai(i, 2)) = MyData(i).Type
  263.       fa.TextArray(fai(i, 3)) = Format$(MyData(i).Sales, "##.00")
  264.       If Val(MyData(i).Sales) < 0 Then
  265.          fa.Row = i
  266.          fa.Col = 3
  267.          fa.CellForeColor = RGB(255, 0, 0)     ' negatives in red
  268.       End If
  269.     Next
  270. End Sub
  271. Sub DoInitialSettings ()
  272.     Dim i%
  273.     fa.Rows = NUMREC
  274.     fa.ColAlignment(0) = 7       ' Align CenterLeft
  275.     fa.Row = 0
  276.     ' change fonts on title Row
  277.     For i = 0 To fa.Cols - 1
  278.       fa.Col = i
  279.       fa.CellFontSize = 14
  280.       fa.CellAlignment = 4       ' Center Center
  281.     Next i
  282.     ' merge only first 3 columns
  283.     fa.MergeCol(0) = True
  284.     fa.MergeCol(1) = True
  285.     fa.MergeCol(2) = True
  286. End Sub
  287. Sub DoRemoveFlagsFrom (Col%)
  288.    Dim i%
  289.    For i = 1 To NUMREC - 1
  290.       fa.Row = i
  291.       fa.CellPicture = flag(0)      ' No Flag
  292.    Next i
  293. End Sub
  294. Sub DoSort ()
  295.     fa.Col = 0
  296.     fa.ColSel = fa.Cols - 1
  297.     fa.Sort = 1      'numeric ascendent
  298. End Sub
  299. Sub fa_DragDrop (Source As Control, X As Single, Y As Single)
  300.     If fa.Tag = "" Then Exit Sub
  301.     fa.Redraw = False
  302.     fa.ColPosition(Val(fa.Tag)) = fa.MouseCol
  303.     DoSort
  304.     fa.Redraw = True
  305. End Sub
  306. Sub fa_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
  307.    ' Debug.Print "dn"
  308.     fa.Tag = ""
  309.     If fa.MouseRow <> 0 Then Exit Sub
  310.     fa.Tag = Str(fa.MouseCol)
  311.     fa.Drag 1
  312. End Sub
  313. Sub fa_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
  314. 'Debug.Print "up"
  315. End Sub
  316. Function fai (r%, c%) As Integer
  317.     fai = c + fa.Cols * r
  318. End Function
  319. Sub Form_Load ()
  320.     DoInitialSettings
  321.     DoGetData
  322.     DoFillData
  323.     DoSort
  324. End Sub
  325. Sub Option1_Click (Index As Integer)
  326.    ' enable and disable controls
  327.    chkPictures.Enabled = Not chkPictures.Enabled
  328.    chkMergeCells.Enabled = Not chkMergeCells.Enabled
  329.    command1.Enabled = Not command1.Enabled
  330.    frame1.Enabled = Not frame1.Enabled
  331.    fa.Redraw = False
  332.    chkPictures.Value = Index
  333.    chkMergeCells.Value = Index
  334.    fa.Redraw = True
  335. End Sub
  336.