home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 3_2004-2005.ISO / Data / Zips / API_Viewer175250612004.psc / Form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2004-05-31  |  13.1 KB  |  415 lines

  1. VERSION 5.00
  2. Begin VB.Form APIV 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "API Viewer (Write by Visal)"
  5.    ClientHeight    =   8280
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   8985
  9.    BeginProperty Font 
  10.       Name            =   "MS Sans Serif"
  11.       Size            =   9.75
  12.       Charset         =   0
  13.       Weight          =   400
  14.       Underline       =   0   'False
  15.       Italic          =   0   'False
  16.       Strikethrough   =   0   'False
  17.    EndProperty
  18.    LinkTopic       =   "Form1"
  19.    MaxButton       =   0   'False
  20.    MinButton       =   0   'False
  21.    ScaleHeight     =   8280
  22.    ScaleWidth      =   8985
  23.    StartUpPosition =   3  'Windows Default
  24.    Begin VB.TextBox TextItem 
  25.       Height          =   3375
  26.       Left            =   120
  27.       MultiLine       =   -1  'True
  28.       ScrollBars      =   2  'Vertical
  29.       TabIndex        =   11
  30.       Top             =   4680
  31.       Width           =   8655
  32.    End
  33.    Begin VB.TextBox Text 
  34.       Height          =   375
  35.       Left            =   120
  36.       TabIndex        =   8
  37.       Top             =   1200
  38.       Width           =   8655
  39.    End
  40.    Begin VB.ListBox VType 
  41.       BeginProperty Font 
  42.          Name            =   "MS Sans Serif"
  43.          Size            =   8.25
  44.          Charset         =   0
  45.          Weight          =   400
  46.          Underline       =   0   'False
  47.          Italic          =   0   'False
  48.          Strikethrough   =   0   'False
  49.       EndProperty
  50.       Height          =   1425
  51.       Left            =   4320
  52.       Sorted          =   -1  'True
  53.       TabIndex        =   6
  54.       Top             =   6000
  55.       Visible         =   0   'False
  56.       Width           =   2535
  57.    End
  58.    Begin VB.ListBox VFunction 
  59.       BeginProperty Font 
  60.          Name            =   "MS Sans Serif"
  61.          Size            =   8.25
  62.          Charset         =   0
  63.          Weight          =   400
  64.          Underline       =   0   'False
  65.          Italic          =   0   'False
  66.          Strikethrough   =   0   'False
  67.       EndProperty
  68.       Height          =   2010
  69.       Left            =   5760
  70.       Sorted          =   -1  'True
  71.       TabIndex        =   5
  72.       Top             =   5640
  73.       Visible         =   0   'False
  74.       Width           =   2415
  75.    End
  76.    Begin VB.ComboBox TypeAPI 
  77.       Height          =   360
  78.       Left            =   120
  79.       TabIndex        =   3
  80.       Top             =   480
  81.       Width           =   2415
  82.    End
  83.    Begin VB.ListBox ListType 
  84.       Height          =   1260
  85.       Left            =   2640
  86.       Sorted          =   -1  'True
  87.       TabIndex        =   2
  88.       Top             =   6480
  89.       Visible         =   0   'False
  90.       Width           =   1695
  91.    End
  92.    Begin VB.ListBox ListConst 
  93.       Height          =   780
  94.       Left            =   960
  95.       Sorted          =   -1  'True
  96.       TabIndex        =   1
  97.       Top             =   7080
  98.       Visible         =   0   'False
  99.       Width           =   1815
  100.    End
  101.    Begin VB.ListBox ListFunction 
  102.       Height          =   2220
  103.       Left            =   120
  104.       Sorted          =   -1  'True
  105.       TabIndex        =   0
  106.       Top             =   2040
  107.       Width           =   8655
  108.    End
  109.    Begin VB.Label Label4 
  110.       Caption         =   "Selected Items :"
  111.       Height          =   255
  112.       Left            =   120
  113.       TabIndex        =   10
  114.       Top             =   4320
  115.       Width           =   2295
  116.    End
  117.    Begin VB.Label Label3 
  118.       Caption         =   "Available Items :"
  119.       Height          =   255
  120.       Left            =   120
  121.       TabIndex        =   9
  122.       Top             =   1680
  123.       Width           =   4815
  124.    End
  125.    Begin VB.Label Label2 
  126.       Caption         =   "Type the first few letters of the word you are looking for:"
  127.       Height          =   255
  128.       Left            =   120
  129.       TabIndex        =   7
  130.       Top             =   960
  131.       Width           =   5535
  132.    End
  133.    Begin VB.Label Label1 
  134.       Caption         =   "API Type :"
  135.       Height          =   255
  136.       Left            =   120
  137.       TabIndex        =   4
  138.       Top             =   240
  139.       Width           =   2295
  140.    End
  141. Attribute VB_Name = "APIV"
  142. Attribute VB_GlobalNameSpace = False
  143. Attribute VB_Creatable = False
  144. Attribute VB_PredeclaredId = True
  145. Attribute VB_Exposed = False
  146. ' ################################
  147. '  Write By Visal
  148. '  Email : visalemail@yahoo.com
  149. '  IRC : irc.uirc.net  in channel #uirc.services and #cambodia
  150. ' ################################
  151. ' ################################
  152. Dim FunctionChrPos(26) As Integer
  153. ' Descript : Store where function that start character A-Z located in list
  154. Dim FunctionCountChr(26) As Integer
  155. ' Descript : Count function that start with character A-Z
  156. Dim ConstChrPos(26) As Integer
  157. ' Descript : Store where constants that start character A-Z located in list
  158. Dim ConstCountChr(26) As Integer
  159. ' Descript : Count constants that start with character A-Z
  160. Dim TypeChrPos(26) As Integer
  161. ' Descript : Store where types that start character A-Z located in list
  162. Dim TypeCountChr(26) As Integer
  163. ' Descript : Count types that start with character A-Z
  164. Dim InType As Boolean
  165. ' Descript : Is in the type or out the type
  166. Dim TypeCode As String
  167. ' Descript : Get type
  168. ' ################################
  169. Private Sub Form_Load()
  170. InType = False
  171. ' Show the waiting form
  172. Form1.Show
  173. ' Load API File
  174. LoadData App.Path & "\WIN32API.TXT"
  175. '--------------------------
  176. ' Add type of API
  177. TypeAPI.AddItem "Constants"
  178. TypeAPI.AddItem "Declares"
  179. TypeAPI.AddItem "Types"
  180. TypeAPI.Text = "Declares"
  181. End Sub
  182. ' ##############################
  183. '  Sub For Loading The API Data
  184. ' ##############################
  185. Public Sub LoadData(Filename As String)
  186. Dim strData As String ' Get data in database file
  187. Dim strLine() As String ' Split data in line
  188. Dim LineSplit() As String ' Split line in space
  189. Dim GetConst As String ' Get Const name and variable
  190. Dim GetAsc As Integer ' Get first character asc
  191. 'Open File Database
  192. Open Filename For Input As #1
  193.     'Get all database
  194.     strData = StrConv(InputB(LOF(1), 1), vbUnicode)
  195. Close #1
  196. ' Split database in line
  197. strLine = Split(strData, vbCrLf)
  198. DoEvents
  199. ' Add in list
  200. For i = LBound(strLine) To UBound(strLine)
  201.     ' Remark not count in list
  202.     If Left(strLine(i), 1) = "'" Then
  203.         GoTo SkipFor
  204.     End If
  205.     ' If this line is in type
  206.     If InType = True Then
  207.         TypeCode = TypeCode & vbCrLf & strLine(i)
  208.     End If
  209.     If Len(strLine(i)) > 0 Then
  210.         ' Split this line in space
  211.         LineSplit = Split(strLine(i), " ")
  212.         
  213.         '  Check what API type they in
  214.         Select Case LCase(LineSplit(0))
  215.         
  216.             Case "declare"
  217.             
  218.                 ' Add it to list
  219.                 ListFunction.AddItem LineSplit(2)
  220.                 VFunction.AddItem strLine(i)
  221.                 
  222.                 ' Get first character asc
  223.                 GetAsc = Asc(Left(UCase(LineSplit(2)), 1)) - 64
  224.                 
  225.                 ' Count function that start with first character
  226.                 FunctionCountChr(GetAsc) = FunctionCountChr(GetAsc) + 1
  227.                 
  228.                 ' Reset position
  229.                 For j = GetAsc To 26
  230.                     FunctionChrPos(j) = FunctionChrPos(j - 1) + FunctionCountChr(j - 1)
  231.                 Next j
  232.                 
  233.             Case "const"
  234.                 
  235.                 ' Get Const name and variable
  236.                 GetConst = Right(strLine(i), Len(strLine(i)) - (InStr(strLine(i), " ")))
  237.                 
  238.                 ' Remove remark out from GetConst
  239.                 If InStr(1, GetConst, "'") > 0 Then
  240.                     GetConst = Left(GetConst, InStr(GetConst, "'") - 1)
  241.                 End If
  242.                 
  243.                 ' Add it to list
  244.                 ListConst.AddItem GetConst
  245.                 
  246.                 ' Get first character asc
  247.                 GetAsc = Asc(Left(UCase(LineSplit(1)), 1)) - 64
  248.                 
  249.                 ' Count const that start with first character
  250.                 ConstCountChr(GetAsc) = ConstCountChr(GetAsc) + 1
  251.                 
  252.                 ' Reset position
  253.                 For j = GetAsc To 26
  254.                     ConstChrPos(j) = ConstChrPos(j - 1) + ConstCountChr(j - 1)
  255.                 Next j
  256.                 
  257.             Case "type"
  258.                 
  259.                 'Add it to list
  260.                 ListType.AddItem LineSplit(1)
  261.                 
  262.                 ' Now we in the type
  263.                 InType = True
  264.                 
  265.                 ' Get Type
  266.                 TypeCode = strLine(i)
  267.                 
  268.                 ' Get first character asc
  269.                 GetAsc = Asc(Left(UCase(LineSplit(1)), 1)) - 64
  270.                 
  271.                 ' Count type that start with first character
  272.                 TypeCountChr(GetAsc) = TypeCountChr(GetAsc) + 1
  273.                 
  274.                 ' Reset position
  275.                 For j = GetAsc To 26
  276.                     TypeChrPos(j) = TypeChrPos(j - 1) + TypeCountChr(j - 1)
  277.                 Next j
  278.                 
  279.             Case "end"
  280.             
  281.                 'The type is end
  282.                 InType = False
  283.                 VType.AddItem TypeCode
  284.                 
  285.         End Select
  286.     End If
  287. SkipFor:
  288. Next i
  289. ' Hide waiting form
  290. Form1.Hide
  291. End Sub
  292. ' #############################
  293. Private Sub ListConst_DblClick()
  294.     ' Add const to Text item
  295.     TextItem.Text = TextItem.Text & vbCrLf & "Const " & ListConst.Text & vbCrLf
  296. End Sub
  297. ' #############################
  298. Private Sub ListFunction_DblClick()
  299.     ' Add function to Text item
  300.     TextItem.Text = TextItem.Text & vbCrLf & VFunction.List(ListFunction.SelCount) & vbCrLf
  301. End Sub
  302. ' #############################
  303. Private Sub ListType_DblClick()
  304.     ' Add type to Text item
  305.     TextItem.Text = TextItem.Text & vbCrLf & VType.List(ListType.SelCount) & vbCrLf
  306. End Sub
  307. ' ############################
  308. Private Sub Text_Change()
  309. ' Searching while typing
  310. Select Case LCase(TypeAPI.Text)
  311.     Case "constants"
  312.         Search ListConst, Text.Text, TypeAPI.Text
  313.     Case "declares"
  314.         Search ListFunction, Text.Text, TypeAPI.Text
  315.     Case "types"
  316.         Search ListType, Text.Text, TypeAPI.Text
  317. End Select
  318. End Sub
  319. ' #############################
  320. Private Sub TypeAPI_Click()
  321. ' Change API type
  322. Select Case LCase(TypeAPI.Text)
  323.     Case "constants"
  324.         ' Set Const list position and size
  325.         ListConst.Left = 120
  326.         ListConst.Top = 2040
  327.         ListConst.Visible = True
  328.         ListConst.Height = ListFunction.Height
  329.         ListConst.Width = ListFunction.Width
  330.         
  331.         ListFunction.Visible = False
  332.         ListType.Visible = False
  333.         
  334.         ' Searching
  335.         Search ListConst, Text.Text, TypeAPI.Text
  336.         
  337.     Case "declares"
  338.         ' Set function list position and size
  339.         ListFunction.Left = 120
  340.         ListFunction.Top = 2040
  341.         ListFunction.Visible = True
  342.         
  343.         ListType.Visible = False
  344.         ListConst.Visible = False
  345.         
  346.         ' Searching
  347.         Search ListFunction, Text.Text, TypeAPI.Text
  348.         
  349.     Case "types"
  350.         ' Set type list position and size
  351.         ListType.Left = 120
  352.         ListType.Top = 2040
  353.         ListType.Visible = True
  354.         ListType.Height = ListFunction.Height
  355.         ListType.Width = ListFunction.Width
  356.         ListFunction.Visible = False
  357.         ListConst.Visible = False
  358.         
  359.         ' Searching
  360.         Search ListType, Text.Text, TypeAPI.Text
  361.         
  362. End Select
  363. End Sub
  364. ' ###################################
  365. '  Searching
  366. ' ###################################
  367. Private Sub Search(List As ListBox, Word As String, APIType As String)
  368. Dim GetAsc As Integer ' Get first character asc from word you want search
  369. Dim GetPos As Integer ' Get start position of character
  370. Dim GetEnd As Integer ' Get end position of charcter
  371. Dim Found As Boolean ' Found word or not ?
  372. Found = False
  373. ' If word is nothing then select first item
  374. If Len(Word) < 1 Then
  375.     List.Selected(0) = True
  376.     Exit Sub
  377. End If
  378. ' Get first character asc
  379. GetAsc = Asc(UCase(Left(Word, 1))) - 64
  380. ' If in not alphabet then stop search
  381. If GetAsc < 1 Then
  382.     List.Selected(0) = True
  383.     Exit Sub
  384. End If
  385. If GetAsc > 26 Then
  386.     List.Selected(0) = True
  387.     Exit Sub
  388. End If
  389. ' Get start and end position by API type
  390. Select Case LCase(APIType)
  391.     Case "constants"
  392.         GetPos = ConstChrPos(GetAsc)
  393.         GetEnd = ConstCountChr(GetAsc) + GetPos
  394.     Case "declares"
  395.         GetPos = FunctionChrPos(GetAsc)
  396.         GetEnd = FunctionCountChr(GetAsc) + GetPos
  397.     Case "types"
  398.         GetPos = TypeChrPos(GetAsc)
  399.         GetEnd = TypeCountChr(GetAsc) + GetPos
  400. End Select
  401. ' If there are no item for it then stop search
  402. If GetPos = GetEnd Then
  403.     List.Selected(0) = True
  404.     Exit Sub
  405. End If
  406. 'Searching
  407. For i = GetPos To GetEnd
  408.     If InStr(1, UCase(List.List(i)), UCase(Word)) = 1 Then
  409.         List.Selected(i) = True
  410.         Found = True
  411.         Exit For
  412.     End If
  413. Next i
  414. End Sub
  415.