home *** CD-ROM | disk | FTP | other *** search
/ Dan Appleman's Visual Bas…s Guide to the Win32 API / Dan.Applmans.Visual.Basic.5.0.Programmers.Guide.To.The.Win32.API.1997.Ziff-Davis.Press.CD / VB5PG32.mdf / desaware / apitools / listapi.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-02-13  |  29.0 KB  |  855 lines

  1. VERSION 5.00
  2. Object = "{FAEEE763-117E-101B-8933-08002B2F4F5A}#1.1#0"; "DBLIST32.OCX"
  3. Begin VB.Form frmAPI 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "API Copier"
  6.    ClientHeight    =   6690
  7.    ClientLeft      =   1275
  8.    ClientTop       =   1680
  9.    ClientWidth     =   7755
  10.    Icon            =   "LISTAPI.frx":0000
  11.    KeyPreview      =   -1  'True
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    PaletteMode     =   1  'UseZOrder
  15.    ScaleHeight     =   6690
  16.    ScaleWidth      =   7755
  17.    Begin VB.CommandButton cmdQuery 
  18.       Caption         =   "&Select..."
  19.       Height          =   495
  20.       Left            =   6540
  21.       TabIndex        =   9
  22.       Top             =   2220
  23.       Width           =   1095
  24.    End
  25.    Begin VB.CommandButton cmdCopy 
  26.       Caption         =   "&Insert"
  27.       Height          =   495
  28.       Index           =   1
  29.       Left            =   6540
  30.       TabIndex        =   12
  31.       Top             =   5760
  32.       Visible         =   0   'False
  33.       Width           =   1095
  34.    End
  35.    Begin VB.CommandButton cmdClear 
  36.       Caption         =   "C&lear All"
  37.       Height          =   495
  38.       Left            =   6540
  39.       TabIndex        =   10
  40.       Top             =   4080
  41.       Width           =   1095
  42.    End
  43.    Begin VB.CommandButton cmdOptions 
  44.       Caption         =   "&Options..."
  45.       Height          =   495
  46.       Left            =   6540
  47.       TabIndex        =   8
  48.       Top             =   900
  49.       Width           =   1095
  50.    End
  51.    Begin VB.ComboBox cmbCategory 
  52.       Height          =   300
  53.       Left            =   2880
  54.       Sorted          =   -1  'True
  55.       Style           =   2  'Dropdown List
  56.       TabIndex        =   4
  57.       Top             =   420
  58.       Width           =   2175
  59.    End
  60.    Begin VB.PictureBox pctStatus 
  61.       Height          =   255
  62.       Left            =   180
  63.       ScaleHeight     =   225
  64.       ScaleWidth      =   7425
  65.       TabIndex        =   16
  66.       TabStop         =   0   'False
  67.       Top             =   6360
  68.       Width           =   7455
  69.       Begin VB.Label Status 
  70.          BackStyle       =   0  'Transparent
  71.          Height          =   255
  72.          Left            =   0
  73.          TabIndex        =   0
  74.          Top             =   0
  75.          Width           =   7455
  76.       End
  77.    End
  78.    Begin VB.Timer Timer1 
  79.       Enabled         =   0   'False
  80.       Interval        =   1750
  81.       Left            =   5700
  82.       Top             =   1020
  83.    End
  84.    Begin VB.TextBox txtSearch 
  85.       Height          =   375
  86.       Left            =   180
  87.       TabIndex        =   6
  88.       Top             =   1080
  89.       Width           =   3375
  90.    End
  91.    Begin VB.Data dataAPI2 
  92.       Caption         =   "dataAPI2"
  93.       Connect         =   "Access"
  94.       DatabaseName    =   ""
  95.       DefaultCursorType=   0  'DefaultCursor
  96.       DefaultType     =   2  'UseODBC
  97.       Exclusive       =   -1  'True
  98.       Height          =   300
  99.       Left            =   5400
  100.       Options         =   0
  101.       ReadOnly        =   -1  'True
  102.       RecordsetType   =   1  'Dynaset
  103.       RecordSource    =   "SELECT * FROM [WIN32 Functions] ORDER BY NAME"
  104.       Top             =   420
  105.       Visible         =   0   'False
  106.       Width           =   2295
  107.    End
  108.    Begin VB.Data dataAPI 
  109.       Caption         =   "dataAPI Data Control"
  110.       Connect         =   "Access"
  111.       DatabaseName    =   ""
  112.       DefaultCursorType=   0  'DefaultCursor
  113.       DefaultType     =   2  'UseODBC
  114.       EOFAction       =   1  'EOF
  115.       Exclusive       =   -1  'True
  116.       Height          =   300
  117.       Left            =   5400
  118.       Options         =   0
  119.       ReadOnly        =   -1  'True
  120.       RecordsetType   =   1  'Dynaset
  121.       RecordSource    =   "SELECT * FROM [WIN32 Functions] ORDER BY Name"
  122.       Top             =   60
  123.       Visible         =   0   'False
  124.       Width           =   2295
  125.    End
  126.    Begin VB.CommandButton cmdCopy 
  127.       Caption         =   "&Copy"
  128.       Height          =   495
  129.       Index           =   0
  130.       Left            =   6540
  131.       TabIndex        =   13
  132.       Top             =   5220
  133.       Width           =   1095
  134.    End
  135.    Begin VB.CommandButton cmdAdd 
  136.       Caption         =   "&Add"
  137.       Default         =   -1  'True
  138.       Height          =   495
  139.       Left            =   6540
  140.       TabIndex        =   7
  141.       Top             =   1620
  142.       Width           =   1095
  143.    End
  144.    Begin VB.CommandButton cmdRemove 
  145.       Caption         =   "&Remove"
  146.       Height          =   495
  147.       Left            =   6540
  148.       TabIndex        =   11
  149.       Top             =   4620
  150.       Width           =   1095
  151.    End
  152.    Begin VB.ListBox lstSelected 
  153.       Height          =   2175
  154.       Left            =   180
  155.       MultiSelect     =   2  'Extended
  156.       Sorted          =   -1  'True
  157.       TabIndex        =   15
  158.       Top             =   4080
  159.       Width           =   6255
  160.    End
  161.    Begin VB.ComboBox cmbType 
  162.       Height          =   300
  163.       ItemData        =   "LISTAPI.frx":030A
  164.       Left            =   240
  165.       List            =   "LISTAPI.frx":0317
  166.       Style           =   2  'Dropdown List
  167.       TabIndex        =   2
  168.       Top             =   420
  169.       Width           =   2055
  170.    End
  171.    Begin MSDBCtls.DBList lstAPI 
  172.       Bindings        =   "LISTAPI.frx":0338
  173.       DataField       =   "NAME"
  174.       DataSource      =   "dataAPI2"
  175.       Height          =   2205
  176.       Left            =   180
  177.       TabIndex        =   17
  178.       Top             =   1620
  179.       Width           =   6255
  180.       _ExtentX        =   11033
  181.       _ExtentY        =   3889
  182.       _Version        =   327680
  183.       MatchEntry      =   -1  'True
  184.       BackColor       =   -2147483643
  185.       ForeColor       =   -2147483640
  186.       ListField       =   "Name"
  187.       BoundColumn     =   "NAME"
  188.    End
  189.    Begin VB.Label lblType 
  190.       Caption         =   "&API Functions:"
  191.       Height          =   195
  192.       Left            =   180
  193.       TabIndex        =   5
  194.       Top             =   840
  195.       Width           =   3015
  196.       WordWrap        =   -1  'True
  197.    End
  198.    Begin VB.Label lblSelected 
  199.       Caption         =   "S&elected Definitions:"
  200.       Height          =   195
  201.       Left            =   180
  202.       TabIndex        =   14
  203.       Top             =   3840
  204.       Width           =   1695
  205.    End
  206.    Begin VB.Label Label2 
  207.       Caption         =   "View &Type:"
  208.       Height          =   195
  209.       Left            =   240
  210.       TabIndex        =   1
  211.       Top             =   180
  212.       Width           =   975
  213.    End
  214.    Begin VB.Label lblCategory 
  215.       Caption         =   "&Declare Category: "
  216.       Height          =   195
  217.       Left            =   3000
  218.       TabIndex        =   3
  219.       Top             =   180
  220.       Width           =   1335
  221.    End
  222.    Begin VB.Menu mnuFile 
  223.       Caption         =   "&File"
  224.       Begin VB.Menu mnuFileOptions 
  225.          Caption         =   "&Options..."
  226.          Shortcut        =   ^O
  227.       End
  228.       Begin VB.Menu mnuSep1 
  229.          Caption         =   "-"
  230.          Index           =   0
  231.       End
  232.       Begin VB.Menu mnuFileAddin 
  233.          Caption         =   "&Make ListAPI an Add-In"
  234.          Shortcut        =   ^M
  235.       End
  236.       Begin VB.Menu mnuSep2 
  237.          Caption         =   "-"
  238.       End
  239.       Begin VB.Menu mnuFileExit 
  240.          Caption         =   "E&xit"
  241.          Shortcut        =   ^X
  242.       End
  243.    End
  244.    Begin VB.Menu mnuEdit 
  245.       Caption         =   "&Edit"
  246.       Begin VB.Menu mnuEditAdd 
  247.          Caption         =   "A&dd"
  248.          Shortcut        =   ^D
  249.       End
  250.       Begin VB.Menu mnuEditSelect 
  251.          Caption         =   "&Select..."
  252.          Shortcut        =   ^S
  253.       End
  254.       Begin VB.Menu mnuSep3 
  255.          Caption         =   "-"
  256.       End
  257.       Begin VB.Menu mnuEditCopy 
  258.          Caption         =   "&Copy"
  259.          Shortcut        =   ^C
  260.       End
  261.       Begin VB.Menu mnuEditInsert 
  262.          Caption         =   "&Insert"
  263.          Shortcut        =   ^I
  264.          Visible         =   0   'False
  265.       End
  266.       Begin VB.Menu mnuSep 
  267.          Caption         =   "-"
  268.       End
  269.       Begin VB.Menu mnuEditRemove 
  270.          Caption         =   "&Remove"
  271.          Shortcut        =   ^R
  272.       End
  273.       Begin VB.Menu mnuEditClear 
  274.          Caption         =   "C&lear All"
  275.          Shortcut        =   ^A
  276.       End
  277.    End
  278.    Begin VB.Menu mnuHelp 
  279.       Caption         =   "&Help"
  280.       Begin VB.Menu mnuHelpAbout 
  281.          Caption         =   "&About"
  282.       End
  283.    End
  284.    Begin VB.Menu mnuRightButton 
  285.       Caption         =   "Right button"
  286.       Visible         =   0   'False
  287.       Begin VB.Menu mnuRightAdd 
  288.          Caption         =   "&Add"
  289.       End
  290.       Begin VB.Menu mnuRightSelect 
  291.          Caption         =   "&Select"
  292.       End
  293.       Begin VB.Menu mnuRightSep1 
  294.          Caption         =   "-"
  295.       End
  296.       Begin VB.Menu mnuRightRemove 
  297.          Caption         =   "&Remove"
  298.       End
  299.       Begin VB.Menu mnuRightClear 
  300.          Caption         =   "C&lear All"
  301.       End
  302.       Begin VB.Menu mnuRightSep2 
  303.          Caption         =   "-"
  304.       End
  305.       Begin VB.Menu mnuRightCopy 
  306.          Caption         =   "&Copy"
  307.       End
  308.       Begin VB.Menu mnuRightInsert 
  309.          Caption         =   "&Insert"
  310.       End
  311.    End
  312. Attribute VB_Name = "frmAPI"
  313. Attribute VB_GlobalNameSpace = False
  314. Attribute VB_Creatable = False
  315. Attribute VB_PredeclaredId = True
  316. Attribute VB_Exposed = False
  317. ' Copyright 
  318.  1996 by Desaware Inc.
  319. ' Part of the Desaware API Toolkit
  320. ' All Rights Reserved
  321. Option Explicit
  322. Option Compare Text
  323. Public Sub Initialize()
  324.     Dim tableName$
  325.     which% = cmbType.ListIndex ' Figure out which type the user selected.
  326.     Select Case cmbType.ListIndex
  327.     Case CMB_TYPES:
  328.         lblCategory.Visible = False
  329.         cmbCategory.Visible = False
  330.         lblType = "Windows Types:" ' Set the listbox label.
  331.         ' Get the end of the table name. The WIN32/16 will be filled in later.
  332.         tableName$ = "Types]"
  333.         ReloadSelectedList TypesSelected(), TypesNo& ' Reload the lstSelected box.
  334.     Case CMB_CONSTANTS:
  335.         lblCategory.Visible = False
  336.         cmbCategory.Visible = False
  337.         lblType = "Windows Constants:"
  338.         tableName$ = "Constants]"
  339.         ReloadSelectedList ConstantsSelected(), ConstantsNo&
  340.     Case Else: 'CMB_DECLARES
  341.         lblCategory.Visible = True
  342.         cmbCategory.Visible = True
  343.         lblType = "API Functions:"
  344.         tableName$ = "Functions]"
  345.         ReloadSelectedList DeclaresSelected(), DeclaresNo&
  346.         ' Query the database to show only entries of the selected category.
  347.         If cmbCategory.ItemData(cmbCategory.ListIndex) > 0 Then
  348.             tableName$ = tableName$ + "WHERE CATEGORY = " & cmbCategory.ItemData(cmbCategory.ListIndex)
  349.         End If
  350.     End Select
  351.     'Check if it's WIN16 or WIN32 stuff we're copying.
  352.     If options% = OPT_WIN16 Then
  353.         tableName$ = "[WIN16 " + tableName$
  354.     Else
  355.         tableName$ = "[WIN32 " + tableName$
  356.     End If
  357.     dataAPI.RecordSource = "SELECT * FROM " + tableName$ + " ORDER BY Name"
  358.     dataAPI2.RecordSource = "SELECT * FROM " + tableName$ + " ORDER BY Name"
  359.     dataAPI.Refresh
  360.     dataAPI2.Refresh
  361. End Sub
  362. Public Sub cmbCategory_Click()
  363.     Initialize
  364. End Sub
  365. Public Sub cmbType_Click()
  366.     Initialize
  367. End Sub
  368. ' Runs the AAddItem function with the correct array and count as an argument.
  369. ' Sets the alreadycopied flag to false because the selected items have changed.
  370. Public Sub cmdAdd_Click()
  371.     AlreadyCopied% = False
  372.     Select Case which%
  373.     Case CMB_DECLARES:
  374.         AAddItem DeclaresSelected(), DeclaresNo&
  375.     Case CMB_TYPES:
  376.         AAddItem TypesSelected(), TypesNo&
  377.     Case CMB_CONSTANTS:
  378.        AAddItem ConstantsSelected, ConstantsNo&
  379.     End Select
  380. End Sub
  381. Private Sub cmdAdd_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  382.     Status = "Click to add the currently selected item to the lower listbox."
  383. End Sub
  384. Public Sub cmdClear_Click()
  385.     Dim i&
  386.     Screen.MousePointer = 11
  387.     Me.Enabled = False
  388.     'Remove every single item in the list box
  389.     While lstSelected.ListCount
  390.         lstSelected.RemoveItem 0
  391.     Wend
  392.     'set every element of every array as free
  393.     For i& = 0 To TypesNo& - 1
  394.         TypesSelected(i&).Free = True
  395.     Next i&
  396.     For i& = 0 To ConstantsNo& - 1
  397.         ConstantsSelected(i&).Free = True
  398.     Next i&
  399.     For i& = 0 To DeclaresNo& - 1
  400.         DeclaresSelected(i&).Free = True
  401.     Next i&
  402.     AlreadyCopied% = True
  403.     Screen.MousePointer = 0
  404.     Me.Enabled = True
  405. End Sub
  406. Public Sub cmdClear_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  407.     Status = "Click to clear ALL select items."
  408. End Sub
  409. ' Runs through all of the FOOBARselected() arrays and copies all the selected
  410. ' types, functions, and constants to the clipboard.
  411. Public Sub cmdCopy_Click(Index As Integer)
  412.     Dim clipstring$, i&, j%, pstring$, smthCopied%, fStatus%, tstring$
  413.     Dim tableName$
  414.     Me.Enabled = False
  415.     Status.Visible = False
  416.     On Error GoTo handler:
  417.     If TypesNo& = 0 And DeclaresNo& = 0 And ConstantsNo& = 0 Then
  418.         Beep
  419.         MsgBox "Nothing to copy!", 0 + 48, "API Copier Error"
  420.         Exit Sub
  421.     End If
  422.     Screen.MousePointer = 11
  423.     Me.Enabled = True
  424.     If options% = OPT_WIN16 Then
  425.         tableName$ = "WIN16"
  426.     Else
  427.         tableName$ = "WIN32"
  428.     End If
  429. '**************************************************
  430. '*** WINDOWS TYPES
  431.     If Comments% Then
  432.         tstring$ = tstring$ & NL & "'**********************************" & NL
  433.         tstring$ = tstring$ & "'**  Type Definitions: " & NL & NL
  434.     End If
  435.     tstring$ = tstring$ & "#if " & tableName$ & " Then" & NL
  436.     fStatus% = CopyTypes%(tableName$, tstring$)
  437.     If options% = OPT_BOTH Then
  438.         tstring$ = tstring$ & "#else " & NL
  439.         If fStatus% Or CopyTypes%("WIN16", tstring$) Then
  440.             smthCopied% = True
  441.             tstring$ = tstring$ + "#endif 'WIN32 Types" & NL
  442.             clipstring$ = clipstring$ + tstring$
  443.         End If
  444.     Else
  445.         If fStatus% Then
  446.             smthCopied% = True
  447.             tstring$ = tstring$ + "#endif '" & tableName$ & " Types" & NL
  448.             clipstring$ = clipstring$ + tstring$
  449.         End If
  450.     End If
  451. '**************************************************
  452. '*** WINDOWS Constants
  453.     tstring$ = ""
  454.     If Comments% Then
  455.         tstring$ = tstring$ & NL & "'**********************************" & NL
  456.         tstring$ = tstring$ & "'**  Constant Definitions: " & NL & NL
  457.     End If
  458.     tstring$ = tstring$ & "#if " & tableName$ & " Then " & NL
  459.     fStatus% = CopyConstants%(tableName$, tstring$)
  460.     If options% = OPT_BOTH Then
  461.         tstring$ = tstring$ & "#else " & NL
  462.         If fStatus% Or CopyConstants%("WIN16", tstring$) Then
  463.             smthCopied% = True
  464.             clipstring$ = clipstring$ + tstring$
  465.             clipstring$ = clipstring$ + "#endif 'WIN32 " & NL
  466.         End If
  467.     Else
  468.         If fStatus% Then
  469.             smthCopied% = True
  470.             tstring$ = tstring$ + "#endif '" & tableName$ & NL
  471.             clipstring$ = clipstring$ + tstring$
  472.         End If
  473.     End If
  474. '**************************************************
  475. '*** WINDOWS Functions
  476.     tstring$ = ""
  477.     If Comments% Then
  478.         tstring$ = tstring$ & NL & "'**********************************" & NL
  479.         tstring$ = tstring$ & "'**  Function Declarations: " & NL & NL
  480.     End If
  481.     tstring$ = tstring$ & "#if " & tableName$ & " Then" & NL
  482.     fStatus% = CopyFunctions%(tableName$, tstring$)
  483.     If options% = OPT_BOTH Then
  484.         tstring$ = tstring$ & "#else " & NL
  485.         If fStatus% Or CopyFunctions%("WIN16", tstring$) Then
  486.             smthCopied% = True
  487.             tstring$ = tstring$ + "#endif 'WIN32" & NL
  488.             clipstring$ = clipstring$ + tstring$
  489.         End If
  490.     Else
  491.         If fStatus% Then
  492.             smthCopied% = True
  493.             tstring$ = tstring$ + "#endif '" & tableName$ & NL
  494.             clipstring$ = clipstring$ + tstring$
  495.         End If
  496.     End If
  497.  ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  498. ''''''' Copy The actual text to the clipboard.
  499.     If smthCopied = False Then
  500.         Beep
  501.         MsgBox "Nothing to copy!", 0 + 48, "API Copier Error"
  502.         Screen.MousePointer = 0
  503.         Me.Enabled = True
  504.         Status.Visible = True
  505.         Status = ""
  506.         Exit Sub
  507.     Else
  508.         If IsAddin% And Index = 1 Then 'Insert Button
  509.             Status = "Inserting Declarations..."
  510.             j% = FreeFile
  511.             Open App.Path & "\temp.txt" For Output As j%
  512.             Print #j%, clipstring$
  513.             Close #j%
  514.             objVBInst.ActiveProject.SelectedComponents(0).InsertFile App.Path & "\temp.txt"
  515.             Kill App.Path & "\temp.txt"
  516.             pctStatus.Line (0, 0)-(pctStatus.Width, pctStatus.Height), QBColor(9), BF
  517.             Screen.MousePointer = 0
  518.         Else 'Copy Button
  519.             Status = "Copying Declarations..."
  520.             Clipboard.Clear
  521.             Clipboard.SetText clipstring$
  522.             pctStatus.Line (0, 0)-(pctStatus.Width, pctStatus.Height), QBColor(9), BF
  523.             Screen.MousePointer = 0
  524.         End If
  525.         AlreadyCopied% = True
  526.         Beep
  527.         If IsAddin% And Index = 1 Then 'Insert Button
  528.             MsgBox "Inserted Declarations into " & objVBInst.ActiveProject.SelectedComponents(0).Name & ".", 0 + 64, "API Copier"
  529.         Else 'Copy Button
  530.             MsgBox "Copying finished.", 0 + 64, "API Copier"
  531.         End If
  532.     End If
  533.     Me.Enabled = True
  534.     Status.Visible = True
  535.     Status = ""
  536.     Exit Sub
  537. handler:
  538. MsgBox Error$
  539. Screen.MousePointer = 0
  540. Exit Sub
  541. End Sub
  542. Public Sub cmdCopy_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
  543.     Select Case Index
  544.         Case 0:
  545.             Status = "Click to copy all lower listbox items to clipboard."
  546.         Case 1:
  547.             Status = "Click to insert all lower listbox items into the current form."
  548.     End Select
  549. End Sub
  550. Public Sub cmdOptions_Click()
  551.     frmOptions.Show 1
  552. End Sub
  553. Public Sub cmdOptions_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  554.     Status = "Click to select options..."
  555. End Sub
  556. ' Selects all entries from the database that match the criteria for the "NAME"
  557. ' field. The criteria are supplied by the user and the "like" operator is used
  558. ' to compare the name and the criteria.
  559. Public Sub cmdQuery_Click()
  560.     Dim s$, t$
  561.     Dim myRecSet As Recordset
  562.     Me.Enabled = False
  563.     'Find out from which part of the database we are selecting.
  564.     Select Case which%
  565.     Case CMB_DECLARES:
  566.         t$ = "Functions"
  567.     Case CMB_TYPES:
  568.         t$ = "Types"
  569.     Case CMB_CONSTANTS:
  570.         t$ = "Constants"
  571.     End Select
  572.     s$ = "Please enter the NAME criteria for all the functions you want to select:" & NL
  573.     s$ = s$ & NL & "Wilcards:" & NL & NL
  574.     s$ = s$ & "*                      Any number of any characters" & NL
  575.     s$ = s$ & "?                      Any One Character" & NL
  576.     s$ = s$ & "#                      Any one Digit" & NL
  577.     s$ = s$ & "[a-zA-Z12]       Any character in the range 'A'-'Z', 'a'-'z', " & NL
  578.     s$ = s$ & "                             and the characters '1' and '2'" & NL
  579.     s$ = s$ & "[!a-zA-Z12]      Any character NOT matching above" & NL
  580.     s$ = s$ & "                             criteria" & NL
  581.     s$ = InputBox(s$, "Enter Criteria", "")
  582.     Screen.MousePointer = 11
  583.     If s$ = "" Then
  584.         Screen.MousePointer = 0
  585.         Me.Enabled = True
  586.         Exit Sub
  587.     End If
  588.     s$ = "SELECT * FROM [Win32 " & t$ & "] WHERE NAME LIKE """ & s$ & """"
  589.     Set myRecSet = dataAPI2.Database.OpenRecordset(s$, dbOpenDynaset, 0)
  590.     While Not myRecSet.EOF
  591.         AlreadyCopied% = False
  592.         Select Case which%
  593.         Case CMB_DECLARES:
  594.             QueryAddItem DeclaresSelected(), DeclaresNo&, myRecSet("NAME")
  595.         Case CMB_TYPES:
  596.             QueryAddItem TypesSelected(), TypesNo&, myRecSet("NAME")
  597.         Case CMB_CONSTANTS:
  598.             QueryAddItem ConstantsSelected, ConstantsNo&, myRecSet("NAME")
  599.         End Select
  600.         myRecSet.MoveNext
  601.     Wend
  602.     Screen.MousePointer = 0
  603.     Me.Enabled = True
  604. End Sub
  605. Private Sub cmdQuery_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  606.     Status = "Click to selected all entries matching a criteria..."
  607. End Sub
  608. ' Runs the ARemoveItem function with the correct array and count as argument.
  609. ' Sets the alreadycopied flag to false because the selected items have changed.
  610. Public Sub cmdRemove_Click()
  611.     Dim i&, j&
  612.     AlreadyCopied% = False
  613.     j& = lstSelected.ListCount - 1
  614.     Select Case which%
  615.         Case CMB_DECLARES:
  616.             While i& <= j&
  617.                 If lstSelected.Selected(i&) Then
  618.                     ARemoveItem DeclaresSelected(), DeclaresNo&, i&
  619.                     j& = j& - 1
  620.                 Else
  621.                     i& = i& + 1
  622.                 End If
  623.             Wend
  624.         Case CMB_TYPES:
  625.             While i& <= j&
  626.                 If lstSelected.Selected(i&) Then
  627.                     ARemoveItem TypesSelected(), TypesNo&, i&
  628.                     j& = j& - 1
  629.                 Else
  630.                     i& = i& + 1
  631.                 End If
  632.             Wend
  633.         Case CMB_CONSTANTS:
  634.             While i& <= j&
  635.                 If lstSelected.Selected(i&) Then
  636.                     ARemoveItem ConstantsSelected, ConstantsNo&, i&
  637.                     j& = j& - 1
  638.                 Else
  639.                     i& = i& + 1
  640.                 End If
  641.             Wend
  642.     End Select
  643.     If lstSelected.ListCount = 0 Then
  644.         AlreadyCopied% = True
  645.     End If
  646. End Sub
  647. Private Sub cmdRemove_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  648.     Status = "Click to remove the selected item(s) from the listbox."
  649. End Sub
  650. Public Sub Form_Load()
  651.     Dim tblCat As Object
  652.     Load frmAbout
  653.     Me.Top = (Screen.Height - Me.Height) / 2
  654.     Me.Left = (Screen.Width - Me.Width) / 2
  655.     frmAbout.Caption = ""
  656.     frmAbout!Command1.Visible = False
  657.     frmAbout.Show
  658.     frmAbout.MousePointer = 11
  659.     DoEvents
  660.     dataAPI.DatabaseName = App.Path & "\apidata.mdb"
  661.     dataAPI2.DatabaseName = dataAPI.DatabaseName
  662.     NL = Chr$(13) + Chr$(10)  ' Make a NewLine string.
  663.     '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  664.     ''''''' Set status bar
  665.     Status = "Choose the 'Add' Button to select an item."
  666.     '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  667.     ''''''' Update the data controls, open the database, and load the Categories
  668.     ''''''' Combo box
  669.     dataAPI.Refresh
  670.     dataAPI2.Refresh
  671.     Set tblCat = dataAPI.Database.OpenTable("CATEGORIES")
  672.     While Not tblCat.EOF
  673.         cmbCategory.AddItem tblCat("DESCRIPTION")
  674.         cmbCategory.ItemData(cmbCategory.NewIndex) = tblCat("ID")
  675.         tblCat.MoveNext
  676.     Wend
  677.     cmbCategory.AddItem "All Categories", 0
  678.     '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  679.     ''''''' Restore the previous settings.
  680.     options% = Val(GetSetting("ListAPI", "Copying", "Options", OPT_BOTH))
  681. '    options% = OPT_BOTH
  682.     Comments% = Val(GetSetting("ListAPI", "Copying", "Comments", -1))
  683. '    Comments% = True
  684.     Glbl% = Val(GetSetting("ListAPI", "Copying", "Global", -1))
  685. '    Glbl% = False
  686.     AlreadyCopied% = True
  687.     '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  688.     ''''''' Set the beginning values of the TYPES combo and the CATEGORY combo.
  689.     cmbCategory.ListIndex = 0  ' All categories
  690.     cmbType.ListIndex = CMB_DECLARES
  691.     If IsAddin% Then
  692.         mnuEditInsert.Enabled = True
  693.     End If
  694.     Load frmOptions
  695.     Me.Show
  696.     frmAbout.MousePointer = 0
  697.     Unload frmAbout
  698.     lstAPI.SetFocus
  699.     lstHwnd = GetFocus&()
  700. End Sub
  701. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  702.     If Button And vbRightButton Then
  703.         mnuRightRemove.Visible = True
  704.         mnuRightClear.Visible = True
  705.         mnuRightAdd.Visible = True
  706.         mnuRightSelect.Visible = True
  707.         mnuRightSep2.Visible = True
  708.         mnuRightSep1.Visible = True
  709.         PopupMenu mnuRightButton, vbPopupMenuRightButton, X, Y
  710.     End If
  711. End Sub
  712. Public Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  713. '    If Y < 4000 Then
  714. '        status = "Choose the 'Add' Button to select an item."
  715. '    Else
  716. '        status = "Choose the 'Remove' Button de-select an item or press the 'Copy' Button to send it all to the clipboard."
  717. '    End If
  718.     Status = ""
  719. End Sub
  720. Public Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  721.     If Not AlreadyCopied% Then ' If the information wasn't saved....
  722.         Beep
  723.         Select Case MsgBox("Copy selected items to Clipboard?", 3 + 32, "API Copier")
  724.         Case 7: 'No
  725.         Case 6: 'yes
  726.             cmdCopy_Click 0
  727.         Case 2: 'cancel
  728.             Cancel = True
  729.             Exit Sub
  730.         End Select
  731.     End If
  732.     SaveSetting "ListAPI", "Copying", "Options", "" & options%
  733.     SaveSetting "ListAPI", "Copying", "Global", "" & Glbl%
  734.     SaveSetting "ListAPI", "Copying", "Comments", "" & Comments%
  735.     End
  736. End Sub
  737. Public Sub lstAPI_Click()
  738.     ' UpdateBoundField lstAPI.Text
  739.     ' Changed to defer the update, since updating immediately
  740.     ' causes the keyboard matching to fail 4/14/96 DSA
  741. End Sub
  742. Public Sub lstAPI_DblClick()
  743.     cmdAdd_Click
  744. End Sub
  745. Public Sub lstAPI_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  746.     Status = "Choose the 'Add' Button to select an item."
  747. End Sub
  748. Public Sub lstSelected_DblClick()
  749.     cmdRemove_Click
  750. End Sub
  751. Private Sub lstSelected_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  752.     If Button And vbRightButton Then
  753.         mnuRightRemove.Visible = True
  754.         mnuRightClear.Visible = True
  755.         mnuRightAdd.Visible = False
  756.         mnuRightSelect.Visible = True
  757.         mnuRightSep2.Visible = True
  758.         mnuRightSep1.Visible = True
  759.         PopupMenu mnuRightButton, vbPopupMenuRightButton, X + lstSelected.Left, Y + lstSelected.Top
  760.     End If
  761. End Sub
  762. Public Sub lstSelected_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  763.     Status = "Choose the 'Remove' Button de-select an item or press the 'Copy' Button to send it all to the clipboard."
  764. End Sub
  765. Public Sub mnuEditClear_Click()
  766.     cmdClear_Click
  767. End Sub
  768. Public Sub mnuEditCopy_Click()
  769.     cmdCopy_Click 0
  770. End Sub
  771. Public Sub mnuEditInsert_Click()
  772.     cmdCopy_Click 1
  773. End Sub
  774. Public Sub mnuEditRemove_Click()
  775.     cmdRemove_Click
  776. End Sub
  777. Public Sub mnuEditSelect_Click()
  778.     cmdQuery_Click
  779. End Sub
  780. Public Sub mnuFileAddin_Click()
  781.   On Error Resume Next
  782.   Dim sOSVer As String
  783. #If Win16 Then
  784.   sOSVer = "16"
  785.   Dim X As Integer
  786. #Else
  787.   sOSVer = "32"
  788.   Dim X As Long
  789. #End If
  790.   'try to register the ListAPI add-in stub
  791.   X = Shell(App.Path & "\LSTADDIN.EXE /regserver")
  792.   If Err Then
  793.     MsgBox "Error: " & Error$
  794.     Exit Sub
  795.   End If
  796.   'try to register VisData
  797.   X = Shell(App.Path & "\" & App.EXEName & ".EXE /regserver")
  798.   If Err Then
  799.     MsgBox "You must run this from an EXE!", 48
  800.     Exit Sub
  801.   End If
  802.   'only add it if the registration was successful
  803.   ' VB4 here
  804.   X = OSWritePrivateProfileString("Add-Ins" & sOSVer, "lstaddin.ListAPIAddInClass", "1", "VB.INI")
  805.   ' VB5 here
  806.   X = OSWritePrivateProfileString("Add-Ins32" & sOSVer, "lstaddin.ListAPIAddInClass", "1", "VBADDIN.INI")
  807. End Sub
  808. Public Sub mnuFileExit_Click()
  809.     Unload Me
  810. End Sub
  811. Public Sub mnuFileOptions_Click()
  812.     frmOptions.Show 1
  813. End Sub
  814. Public Sub mnuHelpAbout_Click()
  815.     frmAbout.Show 1
  816. End Sub
  817. Private Sub mnuRightAdd_Click()
  818.     cmdAdd_Click
  819. End Sub
  820. Private Sub mnuRightClear_Click()
  821.     cmdClear_Click
  822. End Sub
  823. Private Sub mnuRightCopy_Click()
  824.     cmdCopy_Click 0
  825. End Sub
  826. Private Sub mnuRightInsert_Click()
  827.     cmdCopy_Click 1
  828. End Sub
  829. Private Sub mnuRightRemove_Click()
  830.     cmdRemove_Click
  831. End Sub
  832. Private Sub mnuRightSelect_Click()
  833.     cmdQuery_Click
  834. End Sub
  835. ' 1.75 seconds after the last keystroke was entered, reset the textbox
  836. '      and the search string.
  837. Public Sub Timer1_Timer()
  838.      txtSearch = ""
  839.      Timer1.Enabled = False
  840. End Sub
  841. Public Sub txtSearch_KeyPress(KeyAscii As Integer)
  842.     Dim dl&
  843.     If KeyAscii <> 8 Then
  844. '        KeyAscii = 0
  845. '        txtSearch = ""
  846.         dl& = SendMessage&(lstHwnd, WM_CHAR, KeyAscii, 0)
  847.     End If
  848.     ' Restart the timer
  849.     Timer1.Enabled = False
  850.     Timer1.Enabled = True
  851. End Sub
  852. Public Sub txtSearch_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  853.         Status = "Enter the text to search for. Text will reset after 1.75 seconds."
  854. End Sub
  855.