home *** CD-ROM | disk | FTP | other *** search
/ The Best of Select: Windows 95 Special 2 / WIN95_2.bin / utils / envelop / envelop.6 / Tools / Bootcamp / basic / listview / listview.eto < prev    next >
Encoding:
Text File  |  1996-07-08  |  12.6 KB  |  437 lines

  1. Type ListViewSample From Application
  2.   Dim AccessControl As New ACL
  3. End Type
  4.  
  5. Type ListForm From SampleMasterForm
  6.   Type ListView1 From ListView
  7.     Dim Column1 As New ColumnHeader
  8.     Dim Column2 As New ColumnHeader
  9.     Dim Column3 As New ColumnHeader
  10.     Dim font1 As New Font
  11.  
  12.     ' METHODS for object: ListForm.ListView1
  13.     Sub Column1_ColumnClick()
  14.       Sorted = False
  15.       SortOrder = IIf(SortKey = 0, 1 - SortOrder, "Ascending")
  16.       SortType = "Alphabetic"
  17.       SortKey = 0
  18.       Sorted = True
  19.     End Sub
  20.  
  21.     Sub Column2_ColumnClick()
  22.       Sorted = False
  23.       SortOrder = IIf(SortKey = 1, 1 - SortOrder, "Ascending")
  24.       SortType = "Numeric"
  25.       SortKey = 1
  26.       Sorted = True
  27.     End Sub
  28.  
  29.     Sub Column3_ColumnClick()
  30.       Sorted = False
  31.       SortOrder = IIf(SortKey = 2, 1 - SortOrder, "Ascending")
  32.       SortType = "Date"
  33.       SortKey = 2
  34.       Sorted = True
  35.     End Sub
  36.  
  37.     Function SortItem(item1 As String, item2 As String) As Integer
  38.       If (SortKey = 1) Then 
  39.         dim res as integer
  40.         res = Val(item1) < Val(item2)
  41.         If res = 0 Then res = IIf(Val(item1) = Val(item2), 0, 1)
  42.         SortItem = res
  43.       ElseIf (SortKey = 2) Then 
  44.         SortItem = StrComp(Right(item1, 4) & Left(item1, 6), Right(item2, 4) & Left(item2, 6))
  45.       End If
  46.     End Function
  47.  
  48.   End Type
  49.   Type SmallImageList From ImageList
  50.  
  51.     ' METHODS for object: ListForm.SmallImageList
  52.     Sub Clear
  53.       While Count > 0
  54.         RemoveImage(0)
  55.       Wend
  56.     End Sub
  57.  
  58.   End Type
  59.   Dim LargeImageList As New ListForm.SmallImageList
  60.   Dim PictureBox1 As New PictureBox
  61.   Dim PictureBox2 As New PictureBox
  62.   Dim PictureBox3 As New PictureBox
  63.   Dim cbView As New ComboBox
  64.   Dim BmpLGAudio As New Bitmap
  65.   Dim BmpLGArtwrx As New Bitmap
  66.   Dim BmpLGBinary As New Bitmap
  67.   Dim BmpLGText As New Bitmap
  68.   Dim BmpSMText As New Bitmap
  69.   Dim BmpSMBinary As New Bitmap
  70.   Dim BmpSMAudio As New Bitmap
  71.   Dim BmpSMArtwrx As New Bitmap
  72.   Type FakeFile
  73.     Dim FileName As String
  74.     Dim Size As Long
  75.     Dim Date As String
  76.   End Type
  77.   Type FalseDirectory
  78.     Dim FakeFile1 As New ListForm.FakeFile
  79.     Dim FakeFile2 As New ListForm.FakeFile
  80.     Dim FakeFile3 As New ListForm.FakeFile
  81.     Dim FakeFile4 As New ListForm.FakeFile
  82.     Dim FakeFile5 As New ListForm.FakeFile
  83.     Dim FakeFile6 As New ListForm.FakeFile
  84.     Dim FakeFile7 As New ListForm.FakeFile
  85.     Dim FakeFile8 As New ListForm.FakeFile
  86.     Dim FakeFile9 As New ListForm.FakeFile
  87.     Dim FakeFile10 As New ListForm.FakeFile
  88.     Dim FakeFile11 As New ListForm.FakeFile
  89.     Dim FakeFile12 As New ListForm.FakeFile
  90.   End Type
  91.   Dim PictureBox4 As New PictureBox
  92.  
  93.   ' METHODS for object: ListForm
  94.   Sub AddColumn()
  95.     dim name as string
  96.     name = UniqueEmbedName(ListView1, "Column")
  97.     ColumnHeader.Caption = Right(name, 1)
  98.     ColumnHeader.Width = 40 * 15
  99.     EmbedObject(ListView1, ColumnHeader, name)
  100.   End Sub
  101.  
  102.   Sub cbView_Click()
  103.     ListView1.View = cbView.Text
  104.   End Sub
  105.  
  106.   Sub Clear_ColumnHeaders()
  107.     dim ch as ColumnHeader
  108.     For Each ch EmbeddedIn ListView1
  109.       DestroyObject(ch)
  110.     Next 
  111.     UnloadForm
  112.     Show
  113.   End Sub
  114.  
  115.   Sub FillListView()
  116.     Dim o as ListForm.FakeFile
  117.     Dim item as ListItem
  118.     Dim index as Integer
  119.     ListView1.Clear
  120.     For Each o EmbeddedIn ListForm.FalseDirectory
  121.       Select Case Right$(o.FileName, 4)
  122.         Case ".txt"
  123.           index = ListView1.AddItem(0, o.FileName, 3, 3)
  124.           item = ListView1.Item(index)
  125.           item.SmallIcon = 3
  126.         Case ".bmp"
  127.           index = ListView1.AddItem(0, o.FileName, 0, 0)
  128.           item = ListView1.Item(index)
  129.           item.SmallIcon = 0
  130.         Case ".wav"
  131.           index = ListView1.AddItem(0, o.FileName, 1, 1)
  132.           item = ListView1.Item(index)
  133.           item.SmallIcon = 1
  134.         Case ".bin"
  135.           index = ListView1.AddItem(0, o.FileName, 2, 2)
  136.           item = ListView1.Item(index)
  137.           item.SmallIcon = 2
  138.       End Select
  139.       item.SetSubItem(1, o.Size & " bytes")
  140.       item.SetSubItem(2, o.Date)
  141.       Select Case Right$(o.FileName, 4)
  142.         Case ".txt"
  143.           item.SmallIcon = 3
  144.         Case ".bmp"
  145.           item.SmallIcon = 0
  146.         Case ".wav"
  147.           item.SmallIcon = 1
  148.         Case ".bin"
  149.           item.SmallIcon = 2
  150.       End Select
  151.     Next o
  152.   End Sub
  153.  
  154.   Sub Load()
  155.     SmallImageList.Clear
  156.     SmallImageList.AddBitmapsMasked(BmpSMArtwrx, 255)
  157.     SmallImageList.AddBitmapsMasked(BmpSMAudio, 255)
  158.     SmallImageList.AddBitmapsMasked(BmpSMBinary, 255)
  159.     SmallImageList.AddBitmapsMasked(BmpSMText, 255)
  160.     LargeImageList.Clear
  161.     LargeImageList.AddBitmapsMasked(BmpLGArtwrx, 255)
  162.     LargeImageList.AddBitmapsMasked(BmpLGAudio, 255)
  163.     LargeImageList.AddBitmapsMasked(BmpLGBinary, 255)
  164.     LargeImageList.AddBitmapsMasked(BmpLGText, 255)
  165.     ListView1.SmallIcons = SmallImageList
  166.     ListView1.LargeIcons = LargeImageList
  167.   
  168.     cbView.Clear
  169.     cbView.AddItem("0 - Icon")
  170.     cbView.AddItem("1 - SmallIcon")
  171.     cbView.AddItem("2 - List")
  172.     cbView.AddItem("3 - Report")
  173.     cbView.ListIndex = 3
  174.   End Sub
  175.  
  176.   Sub PictureBox1_Paint()
  177.     With LargeImageList
  178.       If .Count Then 
  179.         .Draw(0, PictureBox1.hDC, 0, 0, 0)
  180.       End If
  181.     End With
  182.   End Sub
  183.  
  184.   Sub PictureBox2_Paint()
  185.     With LargeImageList
  186.       If .Count Then 
  187.         .Draw(1, PictureBox2.hDC, 0, 0, 0)
  188.       End If
  189.     End With
  190.   End Sub
  191.  
  192.   Sub PictureBox3_Paint()
  193.     With LargeImageList
  194.       If .Count Then 
  195.         .Draw(2, PictureBox3.hDC, 0, 0, 0)
  196.       End If
  197.     End With
  198.   End Sub
  199.  
  200.   Sub PictureBox4_Paint()
  201.     With LargeImageList
  202.       If .Count Then 
  203.         .Draw(3, PictureBox4.hDC, 0, 0, 0)
  204.       End If
  205.     End With
  206.   End Sub
  207.  
  208.   Sub ResetApplication_Click ()
  209.     FillListView
  210.     cbView.ListIndex = 3 ' Report View
  211.     With ListView1
  212.       .Sorted = False
  213.       .SortKey = 0 ' FileColumn
  214.       .SortOrder = 0 ' Ascending
  215.       .SortType = 0 ' Alphabetic
  216.       .Sorted = True
  217.     End With
  218.   End Sub
  219.  
  220.   Sub Resize()
  221.     ListView1.Move(ListView1.Left, ListView1.Top, ScaleWidth - 260, ScaleHeight - 900)
  222.     PictureBox1.Top = ScaleHeight - PictureBox1.Height - 75
  223.     PictureBox2.Top = PictureBox1.Top
  224.     PictureBox3.Top = PictureBox1.Top
  225.     PictureBox4.Top = PictureBox1.Top
  226.   
  227.     cbView.Top = PictureBox1.Top ' - (cbView.Height - PictureBox1.Height)
  228.     cbView.Left = ScaleWidth - 75 - cbView.Width
  229.   
  230.     ListView1.Column1.Width = ListView1.Width * 0.5
  231.     ListView1.Column2.Width = ListView1.Width * 0.25
  232.     ListView1.Column3.Width = ListView1.Width * 0.25 - 17 * 15 ' Account for scrollbar
  233.   
  234.   End Sub
  235.  
  236. End Type
  237.  
  238. Begin Code
  239. ' Reconstruction commands for object: ListViewSample
  240. '
  241.   With ListViewSample
  242.     .ModulePath := "base.ebo;win32.ebo;dialogs.ebo;tools.ebo;envelop.ebo;listview.eto"
  243.     .ProjectFileName := "C:\Current\listview\ListView.epj"
  244.     .MainForm := ListForm
  245.     .Path := "C:\Current\listview\"
  246.     .EXEName := "ListView"
  247.     With .AccessControl
  248.       .ObjectAccess := "R,W,C,M,P"
  249.     End With  'ListViewSample.AccessControl
  250.   End With  'ListViewSample
  251. ' Reconstruction commands for object: ListForm
  252. '
  253.   With ListForm
  254.     .Caption := "ListView Sample"
  255.     .Move(4890, 1470, 7530, 7245)
  256.     .CurrentY := 480
  257.     .BorderStyle := "Fixed Double"
  258.     .MaxButton := False
  259.     .MinButton := False
  260.     .SampleDir := "C:\Current\listview\"
  261.     .SampleName := "listview"
  262.     With .ListView1
  263.       .ForeColor := 0
  264.       .Font := ListForm.ListView1.font1
  265.       .ZOrder := 6
  266.       .Move(150, 150, 7180, 5640)
  267.       .View := "Report"
  268.       .Sorted := True
  269.       .SmallIcons := ListForm.SmallImageList
  270.       .LargeIcons := ListForm.LargeImageList
  271.       With .Column1
  272.         .Width := 3585
  273.         .Caption := "FileName"
  274.       End With  'ListForm.ListView1.Column1
  275.       With .Column2
  276.         .Width := 1785
  277.         .Caption := "Size"
  278.       End With  'ListForm.ListView1.Column2
  279.       With .Column3
  280.         .Alignment := "Center"
  281.         .Width := 1530
  282.         .Caption := "Date"
  283.       End With  'ListForm.ListView1.Column3
  284.       With .font1
  285.         .FaceName := "Arial"
  286.         .Size := 9.000000
  287.         .Bold := False
  288.         .Italic := True
  289.         .Strikethru := False
  290.       End With  'ListForm.ListView1.font1
  291.     End With  'ListForm.ListView1
  292.     With .SmallImageList
  293.       .ImageWidth := 16
  294.       .ImageHeight := 16
  295.     End With  'ListForm.SmallImageList
  296.     With .LargeImageList
  297.       .ImageWidth := 32
  298.       .ImageHeight := 32
  299.     End With  'ListForm.LargeImageList
  300.     With .PictureBox1
  301.       .Caption := "PictureBox1"
  302.       .ZOrder := 5
  303.       .Move(150, 5865, 600, 600)
  304.     End With  'ListForm.PictureBox1
  305.     With .PictureBox2
  306.       .Caption := "PictureBox2"
  307.       .ZOrder := 4
  308.       .Move(900, 5865, 600, 600)
  309.     End With  'ListForm.PictureBox2
  310.     With .PictureBox3
  311.       .Caption := "PictureBox3"
  312.       .ZOrder := 3
  313.       .Move(1650, 5865, 600, 600)
  314.     End With  'ListForm.PictureBox3
  315.     With .cbView
  316.       .ZOrder := 2
  317.       .Move(5415, 5865, 1950, 360)
  318.       .Sorted := False
  319.     End With  'ListForm.cbView
  320.     With .BmpLGAudio
  321.       .LoadType := "MemoryBased"
  322.       .FileName := "listview.ero"
  323.       .ResId := 0
  324.     End With  'ListForm.BmpLGAudio
  325.     With .BmpLGArtwrx
  326.       .LoadType := "MemoryBased"
  327.       .FileName := "listview.ero"
  328.       .ResId := 628
  329.     End With  'ListForm.BmpLGArtwrx
  330.     With .BmpLGBinary
  331.       .LoadType := "MemoryBased"
  332.       .FileName := "listview.ero"
  333.       .ResId := 1256
  334.     End With  'ListForm.BmpLGBinary
  335.     With .BmpLGText
  336.       .LoadType := "MemoryBased"
  337.       .FileName := "listview.ero"
  338.       .ResId := 1884
  339.     End With  'ListForm.BmpLGText
  340.     With .BmpSMText
  341.       .LoadType := "MemoryBased"
  342.       .FileName := "listview.ero"
  343.       .ResId := 2512
  344.     End With  'ListForm.BmpSMText
  345.     With .BmpSMBinary
  346.       .LoadType := "MemoryBased"
  347.       .FileName := "listview.ero"
  348.       .ResId := 2760
  349.     End With  'ListForm.BmpSMBinary
  350.     With .BmpSMAudio
  351.       .LoadType := "MemoryBased"
  352.       .FileName := "listview.ero"
  353.       .ResId := 3004
  354.     End With  'ListForm.BmpSMAudio
  355.     With .BmpSMArtwrx
  356.       .LoadType := "MemoryBased"
  357.       .FileName := "listview.ero"
  358.       .ResId := 3248
  359.     End With  'ListForm.BmpSMArtwrx
  360.     With .FakeFile
  361.       .FileName := ""
  362.       .Size := 0
  363.       .Date := ""
  364.     End With  'ListForm.FakeFile
  365.     With .FalseDirectory
  366.       With .FakeFile1
  367.         .FileName := "Readme.txt"
  368.         .Size := 314
  369.         .Date := "05/06/1996"
  370.       End With  'ListForm.FalseDirectory.FakeFile1
  371.       With .FakeFile2
  372.         .FileName := "Thoughts.txt"
  373.         .Size := 38016
  374.         .Date := "05/03/1996"
  375.       End With  'ListForm.FalseDirectory.FakeFile2
  376.       With .FakeFile3
  377.         .FileName := "TheTruth.txt"
  378.         .Size := 10
  379.         .Date := "03/18/1996"
  380.       End With  'ListForm.FalseDirectory.FakeFile3
  381.       With .FakeFile4
  382.         .FileName := "Gambit.txt"
  383.         .Size := 2965
  384.         .Date := "04/18/1995"
  385.       End With  'ListForm.FalseDirectory.FakeFile4
  386.       With .FakeFile5
  387.         .FileName := "GCanyon.bmp"
  388.         .Size := 168594
  389.         .Date := "11/14/1995"
  390.       End With  'ListForm.FalseDirectory.FakeFile5
  391.       With .FakeFile6
  392.         .FileName := "Muppets.bmp"
  393.         .Size := 216859
  394.         .Date := "12/25/1995"
  395.       End With  'ListForm.FalseDirectory.FakeFile6
  396.       With .FakeFile7
  397.         .FileName := "Nagel14.bmp"
  398.         .Size := 94853
  399.         .Date := "02/23/1996"
  400.       End With  'ListForm.FalseDirectory.FakeFile7
  401.       With .FakeFile8
  402.         .FileName := "Geekie.bin"
  403.         .Size := 16855
  404.         .Date := "05/07/1996"
  405.       End With  'ListForm.FalseDirectory.FakeFile8
  406.       With .FakeFile9
  407.         .FileName := "Adecodr.bin"
  408.         .Size := 11526
  409.         .Date := "01/06/1994"
  410.       End With  'ListForm.FalseDirectory.FakeFile9
  411.       With .FakeFile10
  412.         .FileName := "Tim2Rock.wav"
  413.         .Size := 32994
  414.         .Date := "02/18/1996"
  415.       End With  'ListForm.FalseDirectory.FakeFile10
  416.       With .FakeFile11
  417.         .FileName := "Splitch.wav"
  418.         .Size := 66794
  419.         .Date := "05/18/1996"
  420.       End With  'ListForm.FalseDirectory.FakeFile11
  421.       With .FakeFile12
  422.         .FileName := "NotToday.wav"
  423.         .Size := 108649
  424.         .Date := "05/19/1996"
  425.       End With  'ListForm.FalseDirectory.FakeFile12
  426.     End With  'ListForm.FalseDirectory
  427.     With .PictureBox4
  428.       .Caption := "PictureBox4"
  429.       .ZOrder := 1
  430.       .Move(2400, 5865, 600, 600)
  431.     End With  'ListForm.PictureBox4
  432.     With .helpfile
  433.       .FileName := "C:\Current\listview\listview.hlp"
  434.     End With  'ListForm.helpfile
  435.   End With  'ListForm
  436. End Code
  437.