home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD (UK) 1995 October / SUPERCD.BIN / PCPLUS / VBWK / VBSPY / VBSPY.ZIP / VBSPY.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-07-03  |  31.5 KB  |  979 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "VB-SPY"
  5.    ClientHeight    =   4212
  6.    ClientLeft      =   96
  7.    ClientTop       =   2028
  8.    ClientWidth     =   7716
  9.    Height          =   4956
  10.    Icon            =   VBSPY.FRX:0000
  11.    Left            =   48
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4212
  14.    ScaleWidth      =   7716
  15.    Tag             =   "Loading"
  16.    Top             =   1332
  17.    Width           =   7812
  18.    Begin PictureBox pctStatusBar 
  19.       Align           =   2  'Align Bottom
  20.       Height          =   300
  21.       Left            =   0
  22.       ScaleHeight     =   276
  23.       ScaleWidth      =   7692
  24.       TabIndex        =   12
  25.       Top             =   3912
  26.       Width           =   7710
  27.       Begin Shape Shape1 
  28.          BorderColor     =   &H00FFFFFF&
  29.          Height          =   225
  30.          Left            =   30
  31.          Top             =   30
  32.          Width           =   7620
  33.       End
  34.       Begin Label lblStatus 
  35.          AutoSize        =   -1  'True
  36.          FontBold        =   0   'False
  37.          FontItalic      =   0   'False
  38.          FontName        =   "MS Sans Serif"
  39.          FontSize        =   7.8
  40.          FontStrikethru  =   0   'False
  41.          FontUnderline   =   0   'False
  42.          Height          =   195
  43.          Left            =   55
  44.          TabIndex        =   13
  45.          Top             =   40
  46.          Width           =   45
  47.       End
  48.    End
  49.    Begin PictureBox Picture1 
  50.       Align           =   1  'Align Top
  51.       BackColor       =   &H00C0C0C0&
  52.       Height          =   540
  53.       Left            =   0
  54.       ScaleHeight     =   516
  55.       ScaleWidth      =   7692
  56.       TabIndex        =   7
  57.       Top             =   0
  58.       Width           =   7710
  59.       Begin SSCommand btnToolbar 
  60.          AutoSize        =   1  'Adjust Picture Size To Button
  61.          Enabled         =   0   'False
  62.          Font3D          =   0  'None
  63.          Height          =   495
  64.          Index           =   4
  65.          Left            =   2205
  66.          TabIndex        =   14
  67.          TabStop         =   0   'False
  68.          Top             =   0
  69.          Width           =   555
  70.       End
  71.       Begin SSCommand btnToolbar 
  72.          AutoSize        =   1  'Adjust Picture Size To Button
  73.          Font3D          =   0  'None
  74.          Height          =   495
  75.          Index           =   3
  76.          Left            =   1650
  77.          TabIndex        =   11
  78.          TabStop         =   0   'False
  79.          Top             =   0
  80.          Width           =   555
  81.       End
  82.       Begin CommonDialog CMDialog1 
  83.          CancelError     =   -1  'True
  84.          DefaultExt      =   ".mak"
  85.          DialogTitle     =   "Open project file"
  86.          Filename        =   "D:\VB\GORAN\VBSPY10\VBSPY10.MAK"
  87.          Filter          =   "Project (*.mak)|*.mak|All files (*.*)|*.*"
  88.          FilterIndex     =   1
  89.          Flags           =   1028
  90.          Left            =   7200
  91.          Top             =   30
  92.       End
  93.       Begin SSCommand btnToolbar 
  94.          AutoSize        =   1  'Adjust Picture Size To Button
  95.          Font3D          =   0  'None
  96.          Height          =   495
  97.          Index           =   2
  98.          Left            =   1095
  99.          TabIndex        =   10
  100.          TabStop         =   0   'False
  101.          Top             =   0
  102.          Width           =   555
  103.       End
  104.       Begin SSCommand btnToolbar 
  105.          Font3D          =   0  'None
  106.          Height          =   495
  107.          Index           =   1
  108.          Left            =   540
  109.          TabIndex        =   9
  110.          TabStop         =   0   'False
  111.          Top             =   0
  112.          Width           =   555
  113.       End
  114.       Begin SSCommand btnToolbar 
  115.          Font3D          =   0  'None
  116.          Height          =   495
  117.          Index           =   0
  118.          Left            =   0
  119.          TabIndex        =   8
  120.          TabStop         =   0   'False
  121.          Top             =   0
  122.          Width           =   555
  123.       End
  124.    End
  125.    Begin IFRAME IFrame1 
  126.       BackColor       =   &H00C0C0C0&
  127.       Height          =   2874
  128.       Index           =   6
  129.       Left            =   0
  130.       Top             =   1360
  131.       Visible         =   0   'False
  132.       Width           =   7758
  133.       Begin TextBox txtInfo 
  134.          BorderStyle     =   0  'None
  135.          Height          =   2874
  136.          HelpContextID   =   2700
  137.          Index           =   6
  138.          Left            =   0
  139.          MultiLine       =   -1  'True
  140.          ScrollBars      =   3  'Both
  141.          TabIndex        =   6
  142.          Top             =   0
  143.          Width           =   7758
  144.       End
  145.    End
  146.    Begin IFRAME IFrame1 
  147.       BackColor       =   &H00C0C0C0&
  148.       Height          =   2874
  149.       Index           =   5
  150.       Left            =   0
  151.       Top             =   1360
  152.       Visible         =   0   'False
  153.       Width           =   7758
  154.       Begin TextBox txtInfo 
  155.          BorderStyle     =   0  'None
  156.          Height          =   2874
  157.          HelpContextID   =   2600
  158.          Index           =   5
  159.          Left            =   0
  160.          MultiLine       =   -1  'True
  161.          ScrollBars      =   3  'Both
  162.          TabIndex        =   5
  163.          Top             =   0
  164.          Width           =   7758
  165.       End
  166.    End
  167.    Begin IFRAME IFrame1 
  168.       BackColor       =   &H00C0C0C0&
  169.       Height          =   2874
  170.       Index           =   4
  171.       Left            =   0
  172.       Top             =   1360
  173.       Visible         =   0   'False
  174.       Width           =   7758
  175.       Begin TextBox txtInfo 
  176.          BorderStyle     =   0  'None
  177.          Height          =   2874
  178.          HelpContextID   =   2500
  179.          Index           =   4
  180.          Left            =   0
  181.          MultiLine       =   -1  'True
  182.          ScrollBars      =   3  'Both
  183.          TabIndex        =   4
  184.          Top             =   0
  185.          Width           =   7758
  186.       End
  187.    End
  188.    Begin IFRAME IFrame1 
  189.       BackColor       =   &H00C0C0C0&
  190.       Height          =   2874
  191.       Index           =   3
  192.       Left            =   0
  193.       Top             =   1360
  194.       Visible         =   0   'False
  195.       Width           =   7758
  196.       Begin TextBox txtInfo 
  197.          BorderStyle     =   0  'None
  198.          Height          =   2874
  199.          HelpContextID   =   2400
  200.          Index           =   3
  201.          Left            =   0
  202.          MultiLine       =   -1  'True
  203.          ScrollBars      =   3  'Both
  204.          TabIndex        =   3
  205.          Top             =   0
  206.          Width           =   7758
  207.       End
  208.    End
  209.    Begin IFRAME IFrame1 
  210.       BackColor       =   &H00C0C0C0&
  211.       Height          =   2874
  212.       Index           =   2
  213.       Left            =   0
  214.       Top             =   1360
  215.       Visible         =   0   'False
  216.       Width           =   7758
  217.       Begin TextBox txtInfo 
  218.          BorderStyle     =   0  'None
  219.          Height          =   2874
  220.          HelpContextID   =   2300
  221.          Index           =   2
  222.          Left            =   0
  223.          MultiLine       =   -1  'True
  224.          ScrollBars      =   3  'Both
  225.          TabIndex        =   2
  226.          Top             =   0
  227.          Width           =   7758
  228.       End
  229.    End
  230.    Begin IFRAME IFrame1 
  231.       BackColor       =   &H00C0C0C0&
  232.       Height          =   2874
  233.       Index           =   1
  234.       Left            =   0
  235.       Top             =   1360
  236.       Visible         =   0   'False
  237.       Width           =   7758
  238.       Begin TextBox txtInfo 
  239.          BorderStyle     =   0  'None
  240.          Height          =   2874
  241.          HelpContextID   =   2200
  242.          Index           =   1
  243.          Left            =   0
  244.          MultiLine       =   -1  'True
  245.          ScrollBars      =   3  'Both
  246.          TabIndex        =   1
  247.          Top             =   0
  248.          Width           =   7758
  249.       End
  250.    End
  251.    Begin IFRAME IFrame1 
  252.       BackColor       =   &H00C0C0C0&
  253.       Height          =   2874
  254.       Index           =   0
  255.       Left            =   0
  256.       Top             =   1360
  257.       Width           =   7758
  258.       Begin TextBox txtInfo 
  259.          BorderStyle     =   0  'None
  260.          Height          =   2874
  261.          HelpContextID   =   2100
  262.          Index           =   0
  263.          Left            =   0
  264.          MultiLine       =   -1  'True
  265.          ScrollBars      =   3  'Both
  266.          TabIndex        =   0
  267.          Top             =   0
  268.          Width           =   7758
  269.       End
  270.    End
  271.    Begin TABBED Tabbed1 
  272.       ActiveTab       =   0
  273.       Captions        =   "&Subs,&Functions,&Global Var.,&Module Var.,&Local Var.,&Declarations,&Summary"
  274.       Height          =   3234
  275.       Left            =   0
  276.       NumberOfTabs    =   7
  277.       Rows            =   2
  278.       TabHeight       =   360
  279.       TabPosition     =   0  'Top
  280.       Top             =   615
  281.       Width           =   7730
  282.    End
  283.    Begin Image imgStop 
  284.       Height          =   480
  285.       Left            =   2205
  286.       Top             =   3720
  287.       Visible         =   0   'False
  288.       Width           =   480
  289.    End
  290.    Begin Image imgNotOnTop 
  291.       Height          =   480
  292.       Left            =   0
  293.       Top             =   0
  294.       Visible         =   0   'False
  295.       Width           =   480
  296.    End
  297.    Begin Image imgOnTop 
  298.       Height          =   480
  299.       Left            =   0
  300.       Top             =   0
  301.       Visible         =   0   'False
  302.       Width           =   480
  303.    End
  304.    Begin Image imgNoStop 
  305.       Height          =   480
  306.       Left            =   1545
  307.       Top             =   3615
  308.       Visible         =   0   'False
  309.       Width           =   480
  310.    End
  311.    Begin Menu mnuArkiv 
  312.       Caption         =   "&File"
  313.       HelpContextID   =   110
  314.       Begin Menu mnuFile_Open 
  315.          Caption         =   "&Open..."
  316.          HelpContextID   =   110
  317.          Shortcut        =   ^O
  318.       End
  319.       Begin Menu mnuFile_Update 
  320.          Caption         =   "&Update Project"
  321.          HelpContextID   =   110
  322.          Shortcut        =   ^U
  323.       End
  324.       Begin Menu mnuzz 
  325.          Caption         =   "-"
  326.       End
  327.       Begin Menu mnuFile_Exit 
  328.          Caption         =   "&Exit"
  329.          HelpContextID   =   110
  330.       End
  331.    End
  332.    Begin Menu mnuAlternativ 
  333.       Caption         =   "O&ptions"
  334.       HelpContextID   =   200
  335.       Begin Menu mnuA_LoadLast 
  336.          Caption         =   "&Load Last File On Start "
  337.          HelpContextID   =   200
  338.       End
  339.       Begin Menu mnuAllways_On_Top 
  340.          Caption         =   "&On Top"
  341.          HelpContextID   =   200
  342.       End
  343.    End
  344.    Begin Menu mnuhelp 
  345.       Caption         =   "&Help"
  346.       HelpContextID   =   300
  347.       Begin Menu mnuHcontents 
  348.          Caption         =   "&Contents"
  349.          HelpContextID   =   300
  350.       End
  351.       Begin Menu mnuHsearch 
  352.          Caption         =   "&Search Help On..."
  353.          HelpContextID   =   300
  354.       End
  355.       Begin Menu mnuz 
  356.          Caption         =   "-"
  357.       End
  358.       Begin Menu mnuH_About 
  359.          Caption         =   "&About VB SPY"
  360.          HelpContextID   =   300
  361.       End
  362.    End
  363. Option Explicit
  364. DefInt A-Z
  365. '---This is the main form for VB-Spy 1.00
  366. '---API declaration for the 'On Top' function
  367. Declare Function SetWindowPos Lib "user" (ByVal h%, ByVal hb%, ByVal x%, ByVal Y%, ByVal cx%, ByVal cy%, ByVal f%) As Integer
  368. Const SWP_NOMOVE = 2
  369. Const SWP_NOSIZE = 1
  370. Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
  371. Const HWND_TOPMOST = -1
  372. Const HWND_NOTOPMOST = -2
  373. Dim NL As String 'New Line
  374. '---IFrame and txtInfo constants
  375. Const SUBS = 0
  376. Const FUNCTIONS = 1
  377. Const GLOBAL_VAR = 2
  378. Const MODULE_VAR = 3
  379. Const VARIABLES = 4
  380. Const DECLARATIONS = 5
  381. Const SUMMARY = 6
  382. '---Search$ constants
  383. Const SUB_S = 0
  384. Const FUNCTION_S = 1
  385. Const DIMS = 2
  386. Const STATICS = 3
  387. Const CONSTANTS = 4
  388. Const DECLARATION_S = 5
  389. Const GLOBALS = 6
  390. '---Array for search string e.g. "Sub "
  391. Dim Search$(6)
  392. '---Flag to keep module and procedure-
  393. '---level variables apart
  394. Dim IsVarModuleLevel
  395. '---Summary Info variables.
  396. Dim Total_Number_Of_Lines
  397. Dim Nr_Of_Subs
  398. Dim Total_Nr_Of_Subs
  399. Dim Nr_Of_Functions
  400. Dim Total_Nr_Of_Functions
  401. Dim Nr_Of_Module_Vars
  402. Dim Total_Nr_Of_Module_Vars
  403. Dim Nr_Of_Vars
  404. Dim Total_Nr_Of_Vars
  405. Dim Total_Nr_Of_Declarations
  406. Dim Nr_Of_Declarations
  407. Dim Nr_Of_Global_Vars
  408. Dim Total_Nr_Of_Global_Vars
  409. '---String for *.Mak file in Summary
  410. Dim Mak_File_In_Summary$
  411. Sub btnToolbar_Click (Index As Integer)
  412. '---Toolbar buttons has corresponding
  413. '---menus, except the stop button.
  414.                            
  415. Select Case Index
  416.    Case 0
  417.       mnuFile_Open_click
  418.    Case 1
  419.       mnuFile_Exit_Click
  420.    Case 2 '---Stop button is using the tag property
  421.       btnToolbar(2).Enabled = Not btnToolbar(2).Enabled
  422.       btnToolbar(2).Tag = "STOP"
  423.       lblStatus = "OPERATION CANCELED!"
  424.    Case 3
  425.       mnuAllways_On_Top_click
  426.    Case 4
  427.       mnuFile_Update_Click
  428. End Select
  429. End Sub
  430. Sub btnToolbar_MouseMove (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  431. '---Status bar text
  432. Select Case Index
  433.    Case 0
  434.    lblStatus = "Open a new file"
  435.    Case 1
  436.    lblStatus = "Exit"
  437.    Case 2
  438.    lblStatus = "Interrupt the reading of files"
  439.    Case 3
  440.    lblStatus = "Window always on top, toggle"
  441.    Case 4
  442.    lblStatus = "Update current project"
  443. End Select
  444. End Sub
  445. Sub DrawLineIntxtVar (cl$, Category)
  446. '---Draws a line to keep the different
  447. '   procedures apart
  448. Dim SubName$, Pos
  449. '---Find the second space
  450. Pos = InStr(Len(Search$(Category)) + 2, cl$, " ")
  451. SubName$ = Left$(cl$, Pos)
  452. '---We have to use mid$ to avoid the linefeed at the end of the row.
  453. If Mid$(txtInfo(VARIABLES), Len(txtInfo(VARIABLES)) - 15, 4) <> "----" Then
  454.    txtInfo(VARIABLES) = txtInfo(VARIABLES) & NL & String$(20, "-") & " " & SubName$ & " " & String$(20, "-") & NL
  455. End If
  456. End Sub
  457. Sub Form_Load ()
  458. '---New Line
  459. NL = Chr$(13) & Chr$(10)
  460. '---Init keyword Array
  461. Search$(0) = "Sub "
  462. Search$(1) = "Function "
  463. Search$(2) = "Dim "
  464. Search$(3) = "Static "
  465. Search$(4) = "Const "
  466. Search$(5) = "Declare "
  467. Search$(6) = "Global "
  468. '---Read window positions from last session
  469. ReadFromIni
  470. '---We start with Activetab SUBS
  471. tabbed1.ActiveTab = SUBS
  472. IFrame1(SUBS).Visible = True
  473. GetToolbarPictures
  474. '---Helpsystem
  475. app.HelpFile = app.Path & "\vbspy.hlp"
  476. '---Putting a backspace in front of the menu caption,
  477. '---puts it at the rightmost position on the menubar
  478. mnuHelp.Caption = Chr(8) + mnuHelp.Caption
  479. Form1.Show
  480. DoEvents
  481. '---Run the openfile dialog
  482. mnuFile_Open_click
  483. '---Update button enable
  484. btnToolbar(4).Enabled = True
  485. End Sub
  486. Sub Form_Paint ()
  487. '---Shape1 gives a little 3-D look to the statusbar
  488. Shape1.Width = pctStatusBar.Width - 100
  489. End Sub
  490. Sub Form_Resize ()
  491. '---Here we adjust frame,Tab and textboxes
  492. '---with values'fr
  493. n form width.
  494. Dim i, ScreenW, ScreenH, ResW!, ResH!
  495. '---No adjustment when minimized
  496. If Me.WindowState <> MINIMIZED Then
  497.    '---The text box scrollbars will end up outside the form
  498.    '---if we don't adjust
  499.    '---SVGA-VGA
  500.    If screen.Height <= 7200 Then
  501.       ResW! = 55  '---VGA
  502.       ResH! = 4.2
  503.    Else
  504.       ResW! = 60 '---SVGA
  505.       ResH! = 5.2
  506.    End If
  507.    ScreenW = screen.Width / ResW!
  508.    ScreenH = screen.Height / ResH!
  509.    tabbed1.Width = Form1.Width - ScreenW
  510.    tabbed1.Height = Form1.Height - ScreenH
  511.    For i = 0 To tabbed1.NumberOfTabs - 1
  512.       '---The value '280' is found with the trial & error method!
  513.       IFrame1(i).Width = tabbed1.Width + Form1.Width / 280
  514.       IFrame1(i).Height = tabbed1.Height - tabbed1.TabHeight
  515.       txtInfo(i).Width = IFrame1(i).Width
  516.       txtInfo(i).Height = IFrame1(i).Height - pctStatusBar.Height
  517.    Next
  518.    Shape1.Width = pctStatusBar.Width - 100
  519. End If
  520. End Sub
  521. Sub Form_Unload (Cancel As Integer)
  522. '---Quit
  523. '---Write ini functions
  524. writeToIni
  525. HelpQuit
  526. End Sub
  527. Sub GetToolbarPictures ()
  528. '---This sub loads the pictures in the toolbar.
  529. '---The LoadPicture provides a easier way to handle pictures
  530. '---when using VB in design mode.
  531. '---If I loaded the pictures in designmode, You would get an
  532. '---error message because you have a diffrent path!
  533. '---This is no problem when distributing only the exefile!
  534. imgNostop.Picture = LoadPicture(app.Path & "\nostop.ico")
  535. btnToolbar(2).Picture = imgNostop.Picture
  536. imgstop.Picture = LoadPicture(app.Path & "\trffc14.ico")
  537. imgNotOnTop.Picture = LoadPicture(app.Path & "\notontop.bmp")
  538. imgOnTop.Picture = LoadPicture(app.Path & "\ontop.bmp")
  539. '---On top toolbar button have two different pictures
  540. If mnuAllways_On_Top.Checked Then
  541.    btnToolbar(3).Picture = imgOnTop.Picture
  542.    btnToolbar(3).Picture = imgNotOnTop.Picture
  543. End If
  544. btnToolbar(0).Picture = LoadPicture(app.Path & "\folder02.ico")
  545. btnToolbar(1).Picture = LoadPicture(app.Path & "\folder01.ico")
  546. btnToolbar(4).Picture = LoadPicture(app.Path & "\litening.ico")
  547. End Sub
  548. Sub IFrame1_Click (Index As Integer)
  549. '---Set focus to the appropriate textbox
  550. '---according to the tab clicked
  551. txtInfo(Index).SetFocus
  552. End Sub
  553. Function IsKeyWordInString (st$, KeyIdx) As Integer
  554. '---8.10.94
  555. '---Check if keyword is in string.
  556. '---This to avoid hardcoded strings to be taken for subs,functions or whatever.
  557. '---'RETURN: False = Outside string
  558. '            True  = Inside string
  559. Dim ApoPos, Apo$, i, NumOfApo, ch$, KeyWordPos
  560. Apo$ = Chr$(34)
  561. '---Check if there are any strings in the codeline
  562. If InStr(st$, Apo$) = 0 Then
  563.    IsKeyWordInString = False
  564.    Exit Function
  565. End If
  566. '---Where is Keyword? Discard the string to the right of KeyWord
  567. KeyWordPos = InStr(st$, Search$(KeyIdx))
  568. ApoPos = InStr(Left$(st$, KeyWordPos), Apo$)
  569. '---Count apostrophe's
  570. For i = ApoPos To 1 Step -1
  571.     ch = Mid$(st$, i, 1)
  572.     If ch = Apo$ Then
  573.       NumOfApo = NumOfApo + 1
  574.     End If
  575. '---If we get a uneven number then the
  576. '---keyword has to be in a string!
  577. Select Case NumOfApo
  578.    Case 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29
  579.          IsKeyWordInString = True
  580.    Case Else
  581.          IsKeyWordInString = False
  582. End Select
  583. End Function
  584. Sub mnuA_LoadLast_Click ()
  585. '---Toggle the 'load last file on start' option
  586. mnuA_LoadLast.Checked = Not mnuA_LoadLast.Checked
  587. End Sub
  588. Sub mnuAllways_On_Top_click ()
  589. '---Always on top function
  590. '---Using the API SetWindowPos call
  591. Dim success
  592. If mnuAllways_On_Top.Checked Then
  593.    success = SetWindowPos(Form1.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, FLAGS)
  594.    '---Change picture
  595.    btnToolbar(3).Picture = imgNotOnTop.Picture
  596.    success = SetWindowPos(Form1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
  597.    btnToolbar(3).Picture = imgOnTop.Picture
  598. End If
  599. 'Toggle Checked
  600. mnuAllways_On_Top.Checked = Not mnuAllways_On_Top.Checked
  601. End Sub
  602. Sub mnuFile_Exit_Click ()
  603. Unload Me
  604. End Sub
  605. Sub mnuFile_Open_click ()
  606. '---Open a MAK file for processing
  607. Dim pt, FileAction, Fname$, i
  608. '---Reset global variables
  609. Nr_Of_Subs = 0
  610. Total_Number_Of_Lines = 0
  611. Total_Nr_Of_Subs = 0
  612. Total_Nr_Of_Functions = 0
  613. Total_Nr_Of_Module_Vars = 0
  614. Total_Nr_Of_Vars = 0
  615. Total_Nr_Of_Declarations = 0
  616. Total_Nr_Of_Global_Vars = 0
  617. Nr_Of_Global_Vars = 0
  618. Nr_Of_Declarations = 0
  619. Nr_Of_Module_Vars = 0
  620. Nr_Of_Vars = 0
  621. Nr_Of_Functions = 0
  622. Nr_Of_Subs = 0
  623. On Error GoTo CMDialogerr
  624. '---8.10.94  Activate Stop button
  625. btnToolbar(2).Tag = ""
  626. btnToolbar(2).Enabled = True
  627. btnToolbar(2).Picture = imgstop.Picture
  628. screen.MousePointer = HOURGLASS
  629. '---Load last used file in previous session
  630. '---or open dialog
  631. '---The Form1.tag is put to loading in design mode.
  632. If Form1.Tag = "Loading" And mnuA_LoadLast.Checked Then
  633.    '---Get the last filename
  634.    Fname$ = ReadIni("Last File", "")
  635.    Form1.Tag = "" '---reset tag
  636.    '---If we dont get a filename (=No INI file)
  637.    '---We run this procedure recursively WITHOUT
  638.    '---the Form1.tag
  639.    If Len(Dir$(Fname$)) = 0 Then mnuFile_Open_click
  640.    '---Open filedialog
  641.    CMdialog1.Action = 1
  642.    '---Mak files don't tell the path when in default directory
  643.    '---Instead we have to change to the directory were the
  644.    '---mak file is.
  645.    pt = InStr(CMdialog1.Filename, CMdialog1.Filetitle)
  646.    ChDir Left$(CMdialog1.Filename, pt - 2)
  647.    Fname$ = CMdialog1.Filename
  648. End If
  649. '---Clear possible old info
  650. For i = 0 To SUMMARY
  651.    txtInfo(i) = ""
  652. '---Write the filename to the VBSPY.INI file
  653. writeIni "Last File", Fname$
  654. Form1.Caption = "VB-SPY: " & Fname$
  655. OpenMakFile (Fname$)
  656. '---Deactivate Stop button
  657. btnToolbar(2).Enabled = False
  658. btnToolbar(2).Picture = imgNostop.Picture
  659. lblStatus = "OK"
  660. '---30.10.94 Summary info
  661. txtInfo(SUMMARY) = txtInfo(SUMMARY) & String$(60, "-") & " TOTAL " & String$(150, "-") & NL
  662. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Code Lines : " & Total_Number_Of_Lines & NL
  663. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Sub : " & Total_Nr_Of_Subs & NL
  664. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Function : " & Total_Nr_Of_Functions & NL
  665. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Declare : " & Total_Nr_Of_Declarations & NL
  666. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Global Var. : " & Total_Nr_Of_Global_Vars & NL
  667. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Module Var. : " & Total_Nr_Of_Module_Vars & NL
  668. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Local Var. : " & Total_Nr_Of_Vars & NL
  669. txtInfo(SUMMARY) = txtInfo(SUMMARY) & String$(60, "-") & " Project File " & String$(150, "-") & NL
  670. '---Simply append the variable
  671. txtInfo(SUMMARY) = txtInfo(SUMMARY) & Mak_File_In_Summary$
  672. screen.MousePointer = DEFAULT
  673. Exit Sub
  674. 'Cancel pressed
  675. CMDialogerr:
  676. screen.MousePointer = DEFAULT
  677. '---Deactivate Stop button
  678. btnToolbar(2).Enabled = False
  679. btnToolbar(2).Picture = imgNostop.Picture
  680. FileAction = FileErrors(Err)
  681. Select Case FileAction
  682.    Case 0
  683.       Resume
  684.    Case Else
  685.     Close
  686.     Exit Sub
  687. End Select
  688. Exit Sub
  689. End Sub
  690. Sub mnuFile_Update_Click ()
  691. '---Update current .mak file
  692. Dim Chk
  693. '---Current value of the checked menu
  694. Chk = mnuA_LoadLast.Checked
  695. '---This is fooling the mnuFile_Open procedure
  696. '---to belive that we started the program with the
  697. '---Load last file option active (Yes...that's cheating!)
  698. mnuA_LoadLast.Checked = True
  699. Form1.Tag = "Loading"
  700. mnuFile_Open_click
  701. '---The old value back
  702. mnuA_LoadLast.Checked = Chk
  703. End Sub
  704. Sub mnuH_About_Click ()
  705. AboutBox.Show MODAL
  706. End Sub
  707. Sub mnuHcontents_Click ()
  708. '---Help contents
  709. Help 0
  710. 'MsgBox "Hj
  711. lp-Systemet inte gjort 
  712. nnu!", 64, "VB Spy"
  713. End Sub
  714. Sub mnuHsearch_Click ()
  715. '---TODO
  716. 'MsgBox "Hj
  717. lp-Systemet inte gjort 
  718. nnu!", 64, "VB Spy"
  719. HelpSearch
  720. End Sub
  721. Function Nr_Of_Commas (s As String)
  722. '---Counting number of commas
  723. Dim i, Num_Of_Comma, ch As String
  724. For i = Len(s) To 1 Step -1
  725.     ch = Mid$(s, i, 1)
  726.     If ch = "," Then
  727.       Num_Of_Comma = Num_Of_Comma + 1
  728.     End If
  729. Nr_Of_Commas = Num_Of_Comma
  730. End Function
  731. Sub OpenCodeFile (Filename$)
  732. '---Open Your Code-file (.frm,.bas...) FileName$ and reads it one row at a time
  733. '---and checks if we have someting from Search$
  734. Dim CodeLine$, FileAction, FileNum, i, Check, x
  735. '---Reset variables
  736. Nr_Of_Module_Vars = 0
  737. Nr_Of_Vars = 0
  738. Nr_Of_Global_Vars = 0
  739. Nr_Of_Functions = 0
  740. Nr_Of_Subs = 0
  741. Nr_Of_Declarations = 0
  742. On Error GoTo openCodeFileErr
  743. For i = 0 To SUMMARY '---SUMMARY is the highest constant
  744.    '---Cosmetics
  745.    If Len(txtInfo(i)) = 0 Then
  746.       txtInfo(i) = txtInfo(i) & "<<<<  " & Filename$ & "  >>>>" & NL
  747.    Else
  748.       txtInfo(i) = txtInfo(i) & NL & "<<<<  " & Filename$ & "  >>>>" & NL
  749.    End If
  750. FileNum = FreeFile
  751. Open Filename$ For Input As #FileNum
  752. '---Module-level variables comes before any sub or function so...
  753. '---Set flag
  754. IsVarModuleLevel = True
  755. '---If it is a form-file then we loop thru the control definitions
  756. If Right$(UCase$(Filename$), 3) = "FRM" Then
  757.    Do
  758.       Line Input #FileNum, CodeLine$
  759.    '---Control definitions end with a END in the first column
  760.    Loop Until Left$(UCase$(CodeLine$), 3) = "END"
  761. End If
  762. '---One row at a time
  763. Do While Not EOF(FileNum)
  764.    DoEvents
  765.    '---Interrupt the process
  766.    If btnToolbar(2).Tag = "STOP" Then
  767.       Close #FileNum
  768.       Exit Sub
  769.    End If
  770.    Line Input #FileNum, CodeLine$
  771.    lblStatus = "Reading File:  " & Filename$ & " Row nr:  " & x & NL & NL
  772.    '---We have no use for strings shorter the 4 letters
  773.    If Len(Trim$(CodeLine$)) > 4 Then
  774.       '---Never mind about comment lines
  775.       If Left$(LTrim$(CodeLine$), 1) <> "'" Then
  776.       For i = 0 To GLOBALS '---Globals is the highest constant
  777.          Check = InStr(CodeLine$, Search$(i))
  778.          If Check <> 0 Then
  779.             '---Yes, we have a valid keyword in the string
  780.             ParseCodeLine CodeLine$, i
  781.          End If
  782.       Next
  783.       End If
  784.    End If
  785.    x = x + 1
  786. '---When the whole file is processed we can present the
  787. '---statistics for the file
  788. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Codelines : " & x & NL
  789. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Subs : " & Nr_Of_Subs & NL
  790. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Functions : " & Nr_Of_Functions & NL
  791. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Declarations : " & Nr_Of_Declarations & NL
  792. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Global Vars. : " & Nr_Of_Global_Vars & NL
  793. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Module Vars. : " & Nr_Of_Module_Vars & NL
  794. txtInfo(SUMMARY) = txtInfo(SUMMARY) & "Num. of Local Vars. : " & Nr_Of_Vars & NL
  795. '---Add up the number of total code lines
  796. Total_Number_Of_Lines = Total_Number_Of_Lines + x
  797. Close #FileNum
  798. Exit Sub
  799. openCodeFileErr:
  800. FileAction = FileErrors(Err)
  801. Select Case FileAction
  802.    Case 0
  803.       Resume
  804.    Case Else
  805.     Exit Sub
  806. End Select
  807. End Sub
  808. Sub OpenMakFile (Makfile$)
  809. '---Opens the .MAK file and checks if it is
  810. '---a valid file(extension)
  811. Dim TextLine$, FileAction, Check, i, FileNum
  812. On Error GoTo openMakFileErr
  813. Mak_File_In_Summary$ = ""
  814. FileNum = FreeFile
  815. Open Makfile$ For Input As #FileNum
  816. Do While Not EOF(FileNum)
  817.    '---STOP button pushed
  818.    If btnToolbar(2).Tag = "STOP" Then
  819.       btnToolbar(2).Tag = ""
  820.       Close #FileNum
  821.       Exit Sub
  822.    End If
  823.    Line Input #FileNum, TextLine$
  824.    '---Reads in the whole project file in the string for viewing in
  825.    '---the summary section.
  826.    Mak_File_In_Summary$ = Mak_File_In_Summary$ & TextLine$ & NL
  827.    Select Case Right$(UCase$(TextLine$), 3)
  828.      '---Reading only files with these extensions.
  829.      '---You can add more if You like, but I didnt want to read
  830.      '---CONSTANTS.TXT so...
  831.       Case "FRM", "BAS", "GLB", "GBL"
  832.          OpenCodeFile TextLine$
  833.    End Select
  834. Close #FileNum
  835. Exit Sub
  836. openMakFileErr:
  837. FileAction = FileErrors(Err)
  838. Select Case FileAction
  839.    Case 0
  840.       Resume
  841.    Case Else
  842.     Exit Sub
  843. End Select
  844. End Sub
  845. Sub ParseCodeLine (CodeLine$, cat)
  846. '---Peal away unnecessary info
  847. '---Codeline$ = current line in process
  848. '---Cat = category
  849. Dim txt$, EndChar, dta$, CancelLine, Nr_Comma
  850. '---Take away remarks
  851. CodeLine$ = TakeAwayRem(CodeLine$)
  852. '--Check if keyword is in string
  853. CancelLine = IsKeyWordInString(CodeLine$, cat)
  854. If Not CancelLine Then
  855.    Select Case cat
  856.       
  857.       Case SUB_S
  858.          '---To avoid GOSUB...Yes, people are still using that! (I've heard)
  859.          '---All sub declarations ends with a ')'
  860.          EndChar = InStr(CodeLine$, ")")
  861.          If EndChar <> 0 Then
  862.             '---'Declare Sub' dont belong here
  863.             If InStr(Left$(CodeLine$, EndChar), "Declare ") = 0 Then
  864.                txtInfo(SUBS) = txtInfo(SUBS) & Left$(CodeLine$, EndChar) & NL
  865.                DrawLineIntxtVar CodeLine$, cat
  866.                Nr_Of_Subs = Nr_Of_Subs + 1
  867.                Total_Nr_Of_Subs = Total_Nr_Of_Subs + 1
  868.                '---When we have reached a sub or function we can't
  869.                '---have any more modul-level variables
  870.                IsVarModuleLevel = False
  871.             End If
  872.          End If
  873.          
  874.       Case FUNCTION_S
  875.             '---'Declare function' dont belong here
  876.             If InStr(CodeLine$, "Declare ") = 0 Then
  877.                txtInfo(FUNCTIONS) = txtInfo(FUNCTIONS) & CodeLine$ & NL
  878.                '---When we have reached a sub or function we can't
  879.                '---have any more modul-level variables
  880.                IsVarModuleLevel = False
  881.                DrawLineIntxtVar CodeLine$, cat
  882.                Nr_Of_Functions = Nr_Of_Functions + 1
  883.                Total_Nr_Of_Functions = Total_Nr_Of_Functions + 1
  884.             End If
  885.       Case DIMS, STATICS, CONSTANTS
  886.             '---Put module level in the right section
  887.             If IsVarModuleLevel Then
  888.                '---No Globals here
  889.                If InStr(CodeLine, "Global ") = 0 Then
  890.                   txtInfo(MODULE_VAR) = txtInfo(MODULE_VAR) & CodeLine & NL
  891.                   '---Count commas: One comma means two variables...
  892.                   Nr_Comma = Nr_Of_Commas(CodeLine) + 1
  893.                   Nr_Of_Module_Vars = Nr_Of_Module_Vars + Nr_Comma
  894.                   Total_Nr_Of_Module_Vars = Total_Nr_Of_Module_Vars + Nr_Comma
  895.                End If
  896.             Else
  897.                '---Local variables
  898.                txtInfo(VARIABLES) = txtInfo(VARIABLES) & CodeLine & NL
  899.                Nr_Comma = Nr_Of_Commas(CodeLine) + 1
  900.                Nr_Of_Vars = Nr_Of_Vars + Nr_Comma
  901.                Total_Nr_Of_Vars = Total_Nr_Of_Vars + Nr_Comma
  902.             End If
  903.       Case DECLARATION_S
  904.            txtInfo(DECLARATIONS) = txtInfo(DECLARATIONS) & CodeLine$ & NL
  905.            Nr_Of_Declarations = Nr_Of_Declarations + 1
  906.            Total_Nr_Of_Declarations = Total_Nr_Of_Declarations + 1
  907.            
  908.       Case GLOBALS
  909.            txtInfo(GLOBAL_VAR) = txtInfo(GLOBAL_VAR) & CodeLine$ & NL
  910.            Nr_Comma = Nr_Of_Commas(CodeLine) + 1
  911.            Nr_Of_Global_Vars = Nr_Of_Global_Vars + Nr_Comma
  912.            Total_Nr_Of_Global_Vars = Total_Nr_Of_Global_Vars + Nr_Comma
  913.    End Select
  914. End If
  915. End Sub
  916. Sub Picture1_MouseMove (Button As Integer, Shift As Integer, x As Single, Y As Single)
  917. lblStatus = ""
  918. End Sub
  919. Sub ReadFromIni ()
  920. '---Read ini-file
  921. '---Last window positions
  922. ReadFromIni_Window_Pos Form1
  923. mnuA_LoadLast.Checked = ReadIni_Int("Last File Checked", 0)
  924. If ReadIni_Int("Allways On Top", 0) Then
  925.    mnuAllways_On_Top_click
  926. End If
  927. End Sub
  928. Sub Tabbed1_MouseMove (Button As Integer, Shift As Integer, x As Single, Y As Single)
  929. lblStatus = ""
  930. End Sub
  931. Sub Tabbed1_TabChange (ActiveTab As Integer)
  932. '---This is dealing w
  933. th the tab.vbx
  934. '---ActiveTab is the one clicked
  935. Dim i As Integer
  936.     For i = 0 To tabbed1.NumberOfTabs - 1
  937.         If i = ActiveTab Then
  938.             IFrame1(i).Visible = True
  939.         Else
  940.             IFrame1(i).Visible = False
  941.         End If
  942.     Next
  943. txtInfo(ActiveTab).SetFocus
  944. End Sub
  945. Function TakeAwayRem (st$) As String
  946. '---Takes away text to the right of the remark sign
  947. '---RETURN: The shortened string
  948. Dim SearchCh
  949. '---PLEASE NOTE:
  950. '---If we have a codeline like this -> Dim x: Dim xx <- then the variable
  951. '---xx will NOT be noted!
  952. '---If You use this kind of notation you have to work out a solution for it!
  953. SearchCh = InStr(st$, ":")
  954. If SearchCh <> 0 Then
  955.    st$ = Left$(st$, SearchCh - 1)
  956. End If
  957. 'Comments with '
  958. SearchCh = InStr(st$, "'")
  959. If SearchCh <> 0 Then
  960.    st$ = Left$(st$, SearchCh - 1)
  961. End If
  962. 'Comments with Rem
  963. SearchCh = InStr(UCase$(st$), " REM ")
  964. If SearchCh <> 0 Then
  965.    st$ = Left$(st$, SearchCh - 1)
  966. End If
  967. TakeAwayRem = st$
  968. End Function
  969. Sub txtInfo_MouseMove (Index As Integer, Button As Integer, Shift As Integer, x As Single, Y As Single)
  970. lblStatus = ""
  971. End Sub
  972. Sub writeToIni ()
  973. '---Ini file writing
  974. '---Current window positions
  975. writeToIni_Window_pos Form1
  976. writeIni "Last File Checked", Str$(mnuA_LoadLast.Checked)
  977. writeIni "Allways On Top", Str$(mnuAllways_On_Top.Checked)
  978. End Sub
  979.