⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 calcvb.pas

📁 vVC显示图片 VC显示图片 VC显示图片 VC显示图片 VC显示图片
💻 PAS
字号:
unit CalcVb;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics,
  Forms, Controls, Calculate;

type
  TCalcVb = class(TCalculate)
  private
    function GetLineCountForFrmFile(Lines: TStrings): integer;
  public
    constructor Create; 
    destructor Destroy; override;

    function GetFileList(List: TStrings): boolean; override;
    function GetLineCount(List: TStrings; Ret: TStrings): integer; override;    
  end;

implementation

constructor TCalcVb.Create;
begin
  inherited Create;
end;

destructor TCalcVb.Destroy;
begin
  inherited Destroy;
end;

function TCalcVb.GetLineCountForFrmFile(Lines: TStrings): integer;
var
  i: integer;
begin
  for i := Lines.Count - 1 downto 0 do
  begin
    if Pos('Attribute VB_', Lines[i]) = 1 then
    begin
      Result := Lines.Count - i;
      exit;
    end;
  end;
  Result := 0;
end;

function TCalcVb.GetFileList(List: TStrings): boolean;
var
  Lines: TStrings;
  i, j: integer;
  LineStr, FileName: string;
  Path: string;
begin
  Result := true;
  Path := ExtractFilePath(FPrjFilename);
  List.Clear;
  Lines := TStringList.Create;
  try
    Lines.LoadFromFile(FPrjFileName);
    for i := 0 to Lines.Count - 1 do
    begin
      LineStr := UpperCase(Lines[i]);
      j := Pos('FORM=', LineStr);
      if j = 1 then
      begin
        FileName := '';
        j := j + 5;
        FileName := Path + Copy(Lines[i], j, 999);
        FileName := ExpandFileName(FileName);
        if FileName <> '' then
          List.Add(FileName);
      end;

      j := Pos('CLASS=', LineStr);
      if j = 1 then
      begin
        FileName := '';
        j := j + 6;
        FileName := Copy(Lines[i], j, 999);
        FileName := Copy(FileName, Pos(';', FileName) + 1, 999);
        FileName := Path + Trim(FileName);
        FileName := ExpandFileName(FileName);
        if FileName <> '' then
          List.Add(FileName);
      end;

      j := Pos('MODULE=', LineStr);
      if j = 1 then
      begin
        FileName := '';
        j := j + 7;
        FileName := Copy(Lines[i], j, 999);
        FileName := Copy(FileName, Pos(';', FileName) + 1, 999);
        FileName := Path + Trim(FileName);
        FileName := ExpandFileName(FileName);
        if FileName <> '' then
          List.Add(FileName);
      end;
    end;
  except
    Result := false;
  end;
  Lines.Free;
end;

function TCalcVb.GetLineCount(List: TStrings; Ret: TStrings): integer;
var
  i, j: integer;
  Lines: TStrings;
  Ext: string;
begin
  Screen.Cursor := crHourGlass;
  Lines := TStringList.Create;
  Result := 0;
  Ret.Clear;
  for i := 0 to List.Count - 1 do
  begin
    try
      Ext := UpperCase(ExtractFileExt(List[i]));
      Lines.LoadFromFile(List[i]);
      if Ext = '.FRM' then
        j := GetLineCountForFrmFile(Lines)
      else j := Lines.Count;
      Inc(Result, j);
      Ret.Add(IntToStr(j));
    except
    end;
  end;
  Lines.Free;
  Screen.Cursor := crDefault;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -