Q&A

  • 찾은 문자열을 한번만 뿌리고 싶은데용 ^|^
찾은 문자가 한줄에 두개가 존재 하더라도 richedit박스에 한번만 부리고 싶은데요 자꾸 두번 씩 나와요.

그리고 스피드버튼 말고 한번 클릭에 찾은문자를 포함한 모든 줄을 뿌릴순없겠습니까.여기 소스 가요.



좀 봐주실래요.올려놔도 왕초보라 실행 않되면 불안함.



unit Unit1;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

StdCtrls, ComCtrls;



type

TForm1 = class(TForm)

Memo1: TMemo;

Edit1: TEdit;

Button1: TButton;

CheckBox1: TCheckBox;

RichEdit1: TRichEdit;

procedure Button1Click(Sender: TObject);

function FindMemoStr(SrchStr: string; CaseSensitive: Boolean): integer;

function PasCount(const s,delimiters : string) :boolean ;

private

{ Private declarations }

public

{ Public declarations }

end;



var

Form1: TForm1;

CB_CaseSensitive:boolean;

j,k:integer;



implementation



{$R *.DFM}



function PasCount(const s,delimiters : string) :boolean ;

var

delimiter,count : Boolean;

i: integer;



begin

count := false;

delimiter := True;

if Length(s) > 0 then

begin

i := 1;

while (Pos(s[i],delimiters) <> 0) and (i <= Length(s)) do

inc(i);

for i := i to length(s) do

if Pos(s[i],delimiters) <> 0 then

delimiter := True

else

begin

if delimiter = True then inc(Count);

delimiter := False;

end;

end;

PasCount := Count;

end;

function TForm1.FindMemoStr(SrchStr: string; CaseSensitive: Boolean):integer ;

function Replichar(c: char; n: integer):string;

var

i: integer;

o: string;

begin

o := '';

for i := 1 to n do AppendStr(o,c);

Replichar := o;

end;



var

CRow, CCol, SRow, SCol: longint;

located: Boolean;

s, t, p: string;

begin

FindMemoStr := 0;

if length(SrchStr) < 1 then

exit;



// 아래 문장은 Memo의 맨 위부터 찾기의해 넣음

Memo1.SelStart := 0;



located := False;

if CaseSensitive then

s := SrchStr

else

s := Uppercase(SrchStr);



with Memo1 do

begin

if lines.count < 1 then

exit;

{현재 row and column을 얻는다}

CRow := SendMessage(Memo1.Handle, EM_LineFromChar, Memo1.SelStart, 0);

CCol := Memo1.SelStart - SendMessage(Memo1.Handle, EM_LineIndex, CRow, 0);



SRow := CRow; {검색시작 row}

while (SRow < lines.count) and not located do

begin

if CaseSensitive then

t := lines[SRow]

else

t := UpperCase(lines[SRow]);



if SRow = CRow then

begin

Delete(t,1,CCol+1);

p := Replichar(' ', CCol+1);

AppendStr(p, t);

t := p;

end;



SCol := pos(s, t);

if SCol > 0 then

begin

k:=k+1;

richedit1.lines[k-1]:=t;

located := True;

end

else

inc(SRow);

end;



if located then

begin

SelStart := SendMessage(Memo1.Handle, EM_LineIndex, SRow, 0) + SCol - 1;

SelLength := length(s);

FindMemoStr := selstart;

end

else

begin

j := j+1;

end;

end;

end;



procedure TForm1.Button1Click(Sender: TObject);

var

//i:integer;

k:boolean;

begin

// 두번째 파라미터는 대소문자 구별 여부



k:=false;

//for i:=1 to 7 do

j:=FindMemoStr(Edit1.Text, CB_CaseSensitive);

if pascount(memo1.text,'#') = true then

begin

MessageBeep(MB_ICONHAND);

MessageDlg('검색 실패', mtInformation, [mbOK],0);

end

else

begin

Memo1.SetFocus ;

end;





end;



end.



0  COMMENTS
    • 이호선
    • 1999.06.16 07:06
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 안치봉
      1999.06.16 18:48
      이호선 께서 말씀하시기를... > 안녕하세요 > 한 폼에서 ShowModal로 폼을 띄웠습니다. 이 Modal폼에서 ...
    • 신인재
      1999.06.17 01:08
      테이블이 어떤 테이블인지..... 만약 파일시스템에서 사용하는 파라독스같은 것이면 delzip을 이용하...
    • 초보
      1999.06.17 03:14
      감사합니다. 근데 바쁘신가봐요 자료실에 확인해 봤는데 없더라구요 빨리 올려주세요 그럼.. 신인...
    • 이주흥
    • 1999.06.16 06:04
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 안치봉
      1999.06.16 18:54
      이주흥 께서 말씀하시기를... > 이거 여기 질문해도 되나 모르겠습니다.. > 다름이 아니고 레지스트리에 ...
    • 홍성원
    • 1999.06.16 05:27
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 안치봉
      1999.06.16 18:57
      홍성원 께서 말씀하시기를... > 델파이에서의 '폼 디자인'을 그대로 > 모사할 수 있는 방법을 알고 싶습...
    • 최기훈
    • 1999.06.16 03:10
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 조복기
      1999.06.16 03:45
      최기훈 께서 말씀하시기를... > System Menu에서 X로 표시된 버튼을 누르면 User에서 물어본다면 해당 > ...
    • 최선기
    • 1999.06.16 02:08
    • 2 COMMENTS
    • /
    • 0 LIKES
    • 김우철
      1999.06.16 09:35
      고수님의 답변에 덧붙여 몇자 적습니다. 일반적으로 Application을 만들때 젤 먼저 결정해야할 문제중 하...
    • 안치봉
      1999.06.16 03:55
      최선기 께서 말씀하시기를... > Project메뉴/option의 Forms 페이지의 기능에 대해 자세히 알고 싶습니다....
    • 이영범
    • 1999.06.16 01:44
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 신호성
      1999.06.17 17:42
      이영범 께서 말씀하시기를... > 안녕하십니까?... > 퀵리포트에서는 Query컴포넌트(이후 Query)를 1개밖...
    • 서영환
    • 1999.06.16 01:23
    • 3 COMMENTS
    • /
    • 0 LIKES
    • 안치봉
      1999.06.16 03:31
      서영환 께서 말씀하시기를... > Active Form에서 다운 받은 OCX를 설치하면, > 버전업을 해도 다시 다운...
    • 서영환
      1999.06.16 04:52
      안치봉 께서 말씀하시기를... > 서영환 께서 말씀하시기를... > > Active Form에서 다운 받은 OCX를 설치...
    • 공대규
      1999.06.29 17:18
      > codebase="http://210.116.3.220/t3/tProj1.cab"#version=1,0,0,0 위 부분의 따옴표가 혹시 "htt...
    • 하명훈
    • 1999.06.16 01:16
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 조복기
      1999.06.16 01:27
      하명훈 께서 말씀하시기를... > procedure TSearch.Button1Click(Sender: TObject); > 쿼리를 엑세스하...
    • 박성훈
    • 1999.06.16 01:10
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 안치봉
      1999.06.16 04:16
      박성훈 께서 말씀하시기를... > procedure Button1Click(Sender: TObject); > begin > Self.Close; ...
    • 강미라
    • 1999.06.16 00:55
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 김우철
      1999.06.16 02:23
      고수는 아니지만, 기냥 써볼랍니다. 날짜에 대한 자료를 처리할수 있는 클래스를 만들어서 윤년계산, 해당...
    • 김진성
    • 1999.06.16 00:42
    • 3 COMMENTS
    • /
    • 0 LIKES
    • 김태균
      1999.06.16 00:49
      김진성 께서 말씀하시기를... > ORACLE에서는 ROWNUM을 이용하여 존재하는 레코드에 대한 > 각각의 번호...
    • 김진성
      1999.06.16 06:22
      김태균 께서 말씀하시기를... > 김진성 께서 말씀하시기를... > > ORACLE에서는 ROWNUM을 이용하여 존재...
    • 김태균
      1999.06.16 18:23
      음..... 테이블을 만들때 포함시키는 것입니다. SQLServer에서 테이블을 생성할 때 순서가 다음과 같...
    • 최기훈
    • 1999.06.16 00:31
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 최기훈
      1999.06.16 03:05
      최기훈 께서 말씀하시기를... > 안녕하세요. 염치를 불구하고 이렇게 또 메일을 올립니다. > Delphi에서 ...
    • 장일
    • 1999.06.15 22:58
    • 0 COMMENTS
    • /
    • 0 LIKES
    • 이주흥
    • 1999.06.15 22:55
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 최석기
      1999.06.16 01:27
      > TrayIcon에서요.. 팝업메뉴를 만드는 방법좀 알려주세요.. > 그러니까 Icon에서 오른쪽 마우스클릭 했을...
    • 디제이
    • 1999.06.15 20:59
    • 1 COMMENTS
    • /
    • 0 LIKES
    • 안치봉
      1999.06.15 21:07
      디제이 께서 말씀하시기를... > > 비베에서는 On Error goto문이 있습니다만 > 델파이에서는 어떤식으...