Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[350] [답변] QKRGUD/cmart2님 find dialog 메일 부탁 Please.
cmart2 [ ] 2340 읽음    1997-12-16 21:10
안안녕하세요. 초웁니다.

저 경고 먹었나봐요...흑흑~  히히...

메일로 보내지 않고 여기에 소스를 전부 올려 놓겠습니다.

음 우선 간단하게 폼에 RichEdit를 하나올려 놓고 버튼을 두개,

OpenDialog하나하고, FindDialog하나를 올려 놓은다음 시작하죠.

다음 소스를 보세요.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    FindDialog1: TFindDialog;
    OpenDialog1: TOpenDialog;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure FindDialog1Find(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
  if OpenDialog1.Execute then
    RichEdit1.Lines.LoadFromFile(OpenDialog1.FileName);
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
  FindDialog1.Position := Point(RichEdit1.Left + RichEdit1.Width, RichEdit1.Top);
  FindDialog1.Execute;
end;

procedure TForm1.FindDialog1Find(Sender: TObject);
var
  FoundAt: LongInt;
  StartPos, ToEnd: integer;
begin
  with RichEdit1 do
  begin
    { begin the search after the current selection if there is one }
    { otherwise, begin at the start of the text }

    if SelLength <> 0 then
      StartPos := SelStart + SelLength
    else

      StartPos := 0;

    { ToEnd is the length from StartPos to the end of the text in the rich edit control }

    ToEnd := Length(Text) - StartPos;

    FoundAt := FindText(FindDialog1.FindText, StartPos, ToEnd, [stMatchCase]);
    if FoundAt <> -1 then
    begin
      SetFocus;
      SelStart := FoundAt;
      SelLength := Length(FindDialog1.FindText);
    end;
  end;
end;
end.

이 내용은 도움말에 있는 내용을 그대로 한줄도 안빼고 단지 ;(세미콜론)하나

지워버린거 밖에 없어요. (도움말에 버그가?~~ ^^)

그럼 도움이 되길 바랍니다.

좋은 코딩하시구여.....

그럼 이만.


+ -

관련 글 리스트
350 [답변] QKRGUD/cmart2님 find dialog 메일 부탁 Please. cmart2 2340 1997/12/16
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.