home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / activex / demos / oletrial / samples / vb / mhdriv / mhdriv_a.frm (.txt) next >
Encoding:
Visual Basic Form  |  1995-11-09  |  15.7 KB  |  486 lines

  1. VERSION 4.00
  2. Begin VB.Form fMain 
  3.    Caption         =   "MicroHelp VBTools 5 - Mh3dDrive Example"
  4.    ClientHeight    =   5340
  5.    ClientLeft      =   1668
  6.    ClientTop       =   876
  7.    ClientWidth     =   6552
  8.    Height          =   5724
  9.    Left            =   1620
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    ScaleHeight     =   5340
  13.    ScaleWidth      =   6552
  14.    Top             =   540
  15.    Width           =   6648
  16.    Begin VB.Frame frmDrive 
  17.       Caption         =   "frmDrive(3)"
  18.       Height          =   1230
  19.       Index           =   3
  20.       Left            =   135
  21.       TabIndex        =   7
  22.       Top             =   1980
  23.       Width           =   3570
  24.       Begin VB.CommandButton cmdAction 
  25.          Caption         =   "cmdAction(3)"
  26.          Height          =   375
  27.          Index           =   3
  28.          Left            =   2070
  29.          TabIndex        =   11
  30.          Top             =   720
  31.          Width           =   1365
  32.       End
  33.       Begin VB.CheckBox chkSearch 
  34.          Caption         =   "chkSearch"
  35.          Height          =   240
  36.          Left            =   180
  37.          TabIndex        =   10
  38.          Top             =   765
  39.          Width           =   1770
  40.       End
  41.       Begin VB.TextBox txtSearch 
  42.          Height          =   285
  43.          Left            =   1305
  44.          TabIndex        =   9
  45.          Text            =   "txtSearch"
  46.          Top             =   315
  47.          Width           =   2085
  48.       End
  49.       Begin VB.Label lblSearch 
  50.          Caption         =   "lblSearch"
  51.          Height          =   195
  52.          Left            =   180
  53.          TabIndex        =   8
  54.          Top             =   360
  55.          Width           =   1050
  56.       End
  57.    End
  58.    Begin VB.Frame frmDrive 
  59.       Caption         =   "frmDrive(2)"
  60.       Height          =   1680
  61.       Index           =   2
  62.       Left            =   135
  63.       TabIndex        =   0
  64.       Top             =   135
  65.       Width           =   3570
  66.       Begin VB.TextBox txtAdd 
  67.          Height          =   285
  68.          Left            =   1620
  69.          TabIndex        =   6
  70.          Text            =   "txtAdd"
  71.          Top             =   1170
  72.          Width           =   1770
  73.       End
  74.       Begin VB.CommandButton cmdAction 
  75.          Caption         =   "cmdAction(0)"
  76.          Height          =   375
  77.          Index           =   0
  78.          Left            =   180
  79.          TabIndex        =   1
  80.          Top             =   450
  81.          Width           =   1365
  82.       End
  83.       Begin VB.CommandButton cmdAction 
  84.          Caption         =   "cmdAction(1)"
  85.          Height          =   375
  86.          Index           =   1
  87.          Left            =   180
  88.          TabIndex        =   4
  89.          Top             =   1080
  90.          Width           =   1365
  91.       End
  92.       Begin VB.Label lblRemove 
  93.          BorderStyle     =   1  'Fixed Single
  94.          Caption         =   "lblRemove"
  95.          Height          =   285
  96.          Left            =   1620
  97.          TabIndex        =   3
  98.          Top             =   540
  99.          Width           =   1770
  100.       End
  101.       Begin VB.Label lblItem 
  102.          Caption         =   "lblItem(0)"
  103.          Height          =   195
  104.          Index           =   0
  105.          Left            =   1620
  106.          TabIndex        =   2
  107.          Top             =   315
  108.          Width           =   1770
  109.       End
  110.       Begin VB.Label lblItem 
  111.          Caption         =   "lblItem(1)"
  112.          Height          =   195
  113.          Index           =   1
  114.          Left            =   1620
  115.          TabIndex        =   5
  116.          Top             =   945
  117.          Width           =   1770
  118.       End
  119.    End
  120.    Begin VB.CommandButton cmdAction 
  121.       Caption         =   "cmdAction(2)"
  122.       Height          =   375
  123.       Index           =   2
  124.       Left            =   5040
  125.       TabIndex        =   24
  126.       Top             =   4815
  127.       Width           =   1365
  128.    End
  129.    Begin VB.Frame frmDrive 
  130.       Caption         =   "frmDrive(1)"
  131.       Height          =   1815
  132.       Index           =   1
  133.       Left            =   2385
  134.       TabIndex        =   18
  135.       Top             =   3375
  136.       Width           =   2490
  137.       Begin VB.OptionButton optDrive 
  138.          Caption         =   "optDrive(2)"
  139.          Height          =   240
  140.          Index           =   2
  141.          Left            =   180
  142.          TabIndex        =   21
  143.          Top             =   945
  144.          Width           =   1095
  145.       End
  146.       Begin VB.OptionButton optDrive 
  147.          Caption         =   "optDrive(1)"
  148.          Height          =   240
  149.          Index           =   1
  150.          Left            =   180
  151.          TabIndex        =   20
  152.          Top             =   630
  153.          Value           =   -1  'True
  154.          Width           =   1140
  155.       End
  156.       Begin VB.OptionButton optDrive 
  157.          Caption         =   "optDrive(0)"
  158.          Height          =   240
  159.          Index           =   0
  160.          Left            =   180
  161.          TabIndex        =   19
  162.          Top             =   315
  163.          Width           =   1140
  164.       End
  165.       Begin VB.Label lblDrive 
  166.          Caption         =   "lblDrive(1)"
  167.          Height          =   195
  168.          Index           =   1
  169.          Left            =   945
  170.          TabIndex        =   23
  171.          Top             =   1485
  172.          Width           =   1320
  173.       End
  174.       Begin VB.Label lblDrive 
  175.          Caption         =   "lblDrive(0)"
  176.          Height          =   195
  177.          Index           =   0
  178.          Left            =   945
  179.          TabIndex        =   22
  180.          Top             =   1215
  181.          Width           =   1320
  182.       End
  183.       Begin VB.Image imgDrive 
  184.          Height          =   192
  185.          Index           =   0
  186.          Left            =   456
  187.          Picture         =   "mhdriv_a.frx":0000
  188.          Top             =   1212
  189.          Width           =   336
  190.       End
  191.       Begin VB.Image imgDrive 
  192.          Height          =   192
  193.          Index           =   1
  194.          Left            =   456
  195.          Picture         =   "mhdriv_a.frx":0182
  196.          Top             =   1488
  197.          Width           =   336
  198.       End
  199.    End
  200.    Begin VB.Frame frmDrive 
  201.       Caption         =   "frmDrive(0)"
  202.       Height          =   1815
  203.       Index           =   0
  204.       Left            =   135
  205.       TabIndex        =   12
  206.       Top             =   3375
  207.       Width           =   2085
  208.       Begin VB.CheckBox chkDrive 
  209.          Caption         =   "chkDrive(4)"
  210.          Height          =   240
  211.          Index           =   4
  212.          Left            =   180
  213.          TabIndex        =   17
  214.          Top             =   1395
  215.          Value           =   1  'Checked
  216.          Width           =   1725
  217.       End
  218.       Begin VB.CheckBox chkDrive 
  219.          Caption         =   "chkDrive(3)"
  220.          Height          =   240
  221.          Index           =   3
  222.          Left            =   180
  223.          TabIndex        =   16
  224.          Top             =   1125
  225.          Value           =   1  'Checked
  226.          Width           =   1500
  227.       End
  228.       Begin VB.CheckBox chkDrive 
  229.          Caption         =   "chkDrive(2)"
  230.          Height          =   240
  231.          Index           =   2
  232.          Left            =   180
  233.          TabIndex        =   15
  234.          Top             =   855
  235.          Value           =   1  'Checked
  236.          Width           =   1545
  237.       End
  238.       Begin VB.CheckBox chkDrive 
  239.          Caption         =   "chkDrive(1)"
  240.          Height          =   240
  241.          Index           =   1
  242.          Left            =   180
  243.          TabIndex        =   14
  244.          Top             =   585
  245.          Value           =   1  'Checked
  246.          Width           =   1500
  247.       End
  248.       Begin VB.CheckBox chkDrive 
  249.          Caption         =   "chkDrive(0)"
  250.          Height          =   240
  251.          Index           =   0
  252.          Left            =   180
  253.          TabIndex        =   13
  254.          Top             =   315
  255.          Value           =   1  'Checked
  256.          Width           =   1545
  257.       End
  258.    End
  259.    Begin VB.Label lblDescription 
  260.       Alignment       =   2  'Center
  261.       BackStyle       =   0  'Transparent
  262.       Caption         =   "lblDescription"
  263.       Height          =   1455
  264.       Left            =   3870
  265.       TabIndex        =   26
  266.       Top             =   135
  267.       Width           =   2535
  268.    End
  269.    Begin MhgdrlLib.Mh3dDrive drlSample 
  270.       Height          =   372
  271.       Left            =   3876
  272.       TabIndex        =   25
  273.       Top             =   1668
  274.       Width           =   2580
  275.       _Version        =   65536
  276.       _ExtentX        =   4551
  277.       _ExtentY        =   656
  278.       _StockProps     =   77
  279.       BackColor       =   12632256
  280.       TintColor       =   16711935
  281.       BevelStyleInner =   0
  282.       BevelSizeInner  =   0
  283.       BorderStyle     =   1
  284.       BorderColor     =   0
  285.       Case            =   0
  286.       DividerStyle    =   0
  287.       FillColor       =   12632256
  288.       FontStyle       =   0
  289.       LightColor      =   16777215
  290.       PictureHeight   =   16
  291.       PictureWidth    =   28
  292.       ShadowColor     =   8421504
  293.       WallPaper       =   0
  294.       TextColor       =   0
  295.       MaxDrop         =   8
  296.       DefaultPics     =   -1  'True
  297.       DriveFixed      =   -1  'True
  298.       DriveRemote     =   -1  'True
  299.       DriveRemovable  =   -1  'True
  300.       HighColor       =   16777215
  301.       SelectedColor   =   8388608
  302.       Transparent     =   0   'False
  303.       TransparentColor=   1
  304.       DriveCDRom      =   -1  'True
  305.       DriveRamDisk    =   -1  'True
  306.    End
  307. Attribute VB_Name = "fMain"
  308. Attribute VB_Creatable = False
  309. Attribute VB_Exposed = False
  310. Sub LoadCaptions()
  311. Dim sCaption As String
  312.     sCaption = "The drive control has the functionality of both "
  313.     sCaption = sCaption & "a drive list box and a combo box.  You can add, "
  314.     sCaption = sCaption & "delete, and search for items.  Also, you can "
  315.     sCaption = sCaption & "control what drive types will be displayed and "
  316.     sCaption = sCaption & "the image that will be displayed with them."
  317.     lblDescription.Caption = sCaption
  318.     ' Frames.
  319.     frmDrive(0).Caption = "Drive Types Displayed"
  320.     frmDrive(1).Caption = "Drive Icons"
  321.     frmDrive(2).Caption = "Adding and Removing Items"
  322.     frmDrive(3).Caption = "Searching for Items"
  323.     ' Drive types.
  324.     chkDrive(0).Caption = "CD-ROM Drives"
  325.     chkDrive(1).Caption = "Fixed Drives"
  326.     chkDrive(2).Caption = "RAM-Disks"
  327.     chkDrive(3).Caption = "Remote Drives"
  328.     chkDrive(4).Caption = "Removable Drives"
  329.     ' Drive icons.
  330.     optDrive(0).Caption = "None."
  331.     optDrive(1).Caption = "Default."
  332.     optDrive(2).Caption = "Custom:"
  333.     lblDrive(0).Caption = ".Picture"
  334.     lblDrive(1).Caption = ".PictureSel"
  335.     ' Adding and removing.
  336.     lblRemove.Caption = drlSample.Drive
  337.     txtAdd.Text = "(enter new item)"
  338.     lblItem(0).Caption = "Item to be removed:"
  339.     lblItem(1).Caption = "String to be added:"
  340.     ' Searching.
  341.     lblSearch.Caption = "Search String"
  342.     txtSearch.Text = "(enter search string)"
  343.     chkSearch.Caption = "Use InString Search."
  344.     ' Command buttons.
  345.     cmdAction(0).Caption = "&RemoveItem"
  346.     cmdAction(1).Caption = "&AddItem"
  347.     cmdAction(2).Caption = "E&xit"
  348.     cmdAction(3).Caption = "&Search"
  349. End Sub
  350. Private Sub chkDrive_Click(Index As Integer)
  351. Dim iValue As Integer
  352.     iValue = chkDrive(Index).Value
  353.     ' Defer redrawing the control until after
  354.     ' all pictures have been loaded or unloaded.
  355.     drlSample.Screenupdate = False
  356.     ' Toggle the specific drive type to display.
  357.     Select Case Index
  358.         Case 0
  359.             drlSample.DriveCDRom = iValue
  360.         Case 1
  361.             drlSample.DriveFixed = iValue
  362.         Case 2
  363.             drlSample.DriveRamDisk = iValue
  364.         Case 3
  365.             drlSample.DriveRemote = iValue
  366.         Case 4
  367.             drlSample.DriveRemovable = iValue
  368.     End Select
  369.     ' Redraw control now that all pictures
  370.     ' have been changed.
  371.     drlSample.Screenupdate = True
  372. End Sub
  373. Private Sub cmdAction_Click(Index As Integer)
  374. Dim iListIndex As Integer
  375. Dim sItem As String
  376.     iListIndex = drlSample.ListIndex
  377.     Select Case Index
  378.         ' Remove current item.
  379.         Case 0
  380.             If iListIndex > -1 Then
  381.                 drlSample.RemoveItem iListIndex
  382.                 ' select a new item
  383.                 If drlSample.ListCount > -1 Then drlSample.ListIndex = 0
  384.             End If
  385.         ' Add new item after current item.
  386.         Case 1
  387.             sItem = txtAdd.Text
  388.             drlSample.AddItem sItem, iListIndex + 1
  389.             drlSample.ListIndex = iListIndex + 1
  390.             
  391.         ' Exit.
  392.         Case 2
  393.             Unload Me
  394.         
  395.         ' Search.
  396.         Case 3
  397.             sItem = txtSearch.Text
  398.             ' InString search -
  399.             ' Finds text anywhere within string.
  400.             If chkSearch.Value Then
  401.                 drlSample.FindInstr = sItem
  402.             ' Regular search -
  403.             ' Finds text only at beginning of string.
  404.             Else
  405.                 drlSample.FindString = sItem
  406.             End If
  407.             
  408.             ' Move to item if found.
  409.             iListIndex = drlSample.FoundIndex
  410.             If iListIndex <> -1 Then
  411.                 drlSample.ListIndex = iListIndex
  412.             Else
  413.                 MsgBox "No match found.", 0, "Search"
  414.             End If
  415.             
  416.     End Select
  417. End Sub
  418. Private Sub drlSample_Change()
  419.     ' Display current item in label
  420.     ' denoting item to remove.
  421.     lblRemove.Caption = drlSample.Drive
  422. End Sub
  423. Private Sub drlSample_Click()
  424.     drlSample_Change
  425. End Sub
  426. Private Sub Form_Load()
  427.     LoadCaptions
  428.     ' center form to screen
  429.     Move Abs(Screen.Width - Width) \ 2, Abs(Screen.Height - Height) \ 2
  430. End Sub
  431. Private Sub optDrive_Click(Index As Integer)
  432. Dim iCount As Integer
  433. Dim iListCount As Integer
  434.     iListCount = drlSample.ListCount
  435.     ' Defer redrawing the control until after
  436.     ' all pictures have been loaded or unloaded.
  437.     drlSample.Screenupdate = False
  438.     Select Case Index
  439.         ' No pictures.
  440.         Case 0
  441.             drlSample.DefaultPics = 0
  442.             For iCount = 0 To iListCount - 1
  443.                 drlSample.ListPicture(iCount) = LoadPicture("")
  444.                 drlSample.ListPictureSel(iCount) = LoadPicture("")
  445.             Next
  446.         ' Default pictures.
  447.         Case 1
  448.             drlSample.DefaultPics = 1
  449.         ' Custom pictures (same for each list item).
  450.         Case 2
  451.             drlSample.DefaultPics = 0
  452.             drlSample.PictureHeight = 16
  453.             drlSample.PictureWidth = 28
  454.             For iCount = 0 To iListCount - 1
  455.                 drlSample.ListPicture(iCount) = imgDrive(0).Picture
  456.                 drlSample.ListPictureSel(iCount) = imgDrive(1).Picture
  457.             Next
  458.     End Select
  459.         
  460.     ' Redraw control now that all pictures
  461.     ' have been changed.
  462.     drlSample.Screenupdate = True
  463. End Sub
  464. Private Sub txtAdd_GotFocus()
  465.     ' Select all text.
  466.     txtAdd.SelStart = 0
  467.     txtAdd.SelLength = Len(txtAdd.Text)
  468.     ' Make search button default.
  469.     cmdAction(1).Default = True
  470. End Sub
  471. Private Sub txtAdd_LostFocus()
  472.     ' Search button no longer default.
  473.     cmdAction(1).Default = False
  474. End Sub
  475. Private Sub txtSearch_GotFocus()
  476.     ' Select all text.
  477.     txtSearch.SelStart = 0
  478.     txtSearch.SelLength = Len(txtSearch.Text)
  479.     ' Make search button default.
  480.     cmdAction(3).Default = True
  481. End Sub
  482. Private Sub txtSearch_LostFocus()
  483.     ' Search button no longer default.
  484.     cmdAction(3).Default = False
  485. End Sub
  486.