home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / borland / cb / setup / cbuilder / data.z / CODEPAGE.PAS < prev    next >
Pascal/Delphi Source File  |  1997-02-28  |  3KB  |  114 lines

  1. //---------------------------------------------------------------------------
  2. // Borland C++Builder
  3. // Copyright (c) 1987, 1997 Borland International Inc.  All Rights Reserved.
  4. //---------------------------------------------------------------------------
  5. // Codepage.pas
  6. //
  7. // VCL Class Browser
  8. //---------------------------------------------------------------------------
  9. unit CodePage;
  10.  
  11. interface
  12.  
  13. uses
  14.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  15.   StdCtrls, ComCtrls, Menus,Registry;
  16.  
  17. type
  18.   TCodePageForm = class(TForm)
  19.     CodePage: TRichEdit;
  20.     SourceRichEdit1: TRichEdit;
  21.     PopupMenu1: TPopupMenu;
  22.     FindText1: TMenuItem;
  23.     FindDialog1: TFindDialog;
  24.     Exit1: TMenuItem;
  25.     procedure FindText1Click(Sender: TObject);
  26.     procedure FindDialog1Find(Sender: TObject);
  27.     procedure Exit1Click(Sender: TObject);
  28.   private
  29.      I:Integer;
  30.   public
  31.     { Public declarations }
  32.   end;
  33.  
  34. var
  35.   CodePageForm: TCodePageForm;
  36.  
  37. implementation
  38.  
  39. {$R *.DFM}
  40.  
  41. procedure TCodePageForm.FindText1Click(Sender: TObject);
  42.    begin
  43.    I:=0;
  44.    FindDialog1.Execute;
  45.    end;
  46.  
  47. procedure TCodePageForm.FindDialog1Find(Sender: TObject);
  48.    var
  49.    FoundOne:Boolean;
  50.    J, PosReturn, SkipChars: Integer;
  51.    begin
  52.    FoundOne:=false;
  53.  
  54.    if CodePage.Visible=true then
  55.    begin
  56.       while I < (CodePage.Lines.Count+1) do
  57.          begin
  58.          PosReturn := Pos(FindDialog1.FindText,CodePage.Lines[I]);
  59.          if PosReturn <> 0 then {found!}
  60.             begin
  61.             FoundOne:=true;
  62.             Skipchars := 0;
  63.             for J := 0 to I - 1 do
  64.             Skipchars := Skipchars + Length(CodePage.Lines[J]);
  65.             SkipChars := SkipChars + (I*2);
  66.             SkipChars := SkipChars + PosReturn - 1;
  67.             CodePage.SetFocus;
  68.             CodePage.SelStart := SkipChars;
  69.             CodePage.SelLength := Length(FindDialog1.FindText);
  70.             Inc(I);
  71.             Exit;
  72.             end;
  73.          Inc(I);
  74.          end;
  75.       end;
  76.  
  77.    if SourceRichEdit1.Visible=true then
  78.    begin
  79.       while I < (SourceRichEdit1.Lines.Count+1) do
  80.          begin
  81.          PosReturn := Pos(FindDialog1.FindText,SourceRichEdit1.Lines[I]);
  82.          if PosReturn <> 0 then {found!}
  83.             begin
  84.             FoundOne:=true;
  85.             Skipchars := 0;
  86.             for J := 0 to I - 1 do
  87.             Skipchars := Skipchars + Length(SourceRichEdit1.Lines[J]);
  88.             SkipChars := SkipChars + (I*2);
  89.             SkipChars := SkipChars + PosReturn - 1;
  90.             SourceRichEdit1.SetFocus;
  91.             SourceRichEdit1.SelStart := SkipChars;
  92.             SourceRichEdit1.SelLength := Length(FindDialog1.FindText);
  93.             Inc(I);
  94.             Exit;
  95.             end;
  96.          Inc(I);
  97.          end;
  98.       end;
  99.  
  100.    if FoundOne=false then
  101.       begin
  102.       MessageDlg('No Match Found!!' ,mtError, [mbOk], 0);
  103.       Exit;
  104.       end;
  105.  
  106.    end;
  107.  
  108. procedure TCodePageForm.Exit1Click(Sender: TObject);
  109.    begin
  110.    Hide;
  111.    end;
  112.  
  113. end.
  114.