🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: cn.bbs.comp.program
1 messages
1 total messages Started by ���ܵ�Сʨ Thu, 07 May 1998 00:00
Delphiͨ�ñ༭�����ʾ��
#1072
Author: ���ܵ�Сʨ
Date: Thu, 07 May 1998 00:00
145 lines
7722 bytes
  ���Ӧ�ó���Ҫ����һ���õ�ͨ�ñ༭�����,���дͨ�ñ༭
��������һ���������ֺõĹ���������Delphi2.0�ṩ��һ���ܺõ�
�༭���ؼ�����TRICHEDIT,��֧��RTF(Ric Text Font)�ļ��洢��ʽ
,ʹ�������ʹ�༭��Ӧ�ó������ƹ������򻯡�
    ��Delphi2.0\demos\richeditĿ¼����һ���ܺõ�ʾ�����,��
�߿���ϸ�ж�,�������������Ϊһ��ͨ�ñ༭��ʹ��,���ܻ��Ӳ���
�����߿��ڴ�ʾ����ϰ����·������ԸĽ�

    ���ļ�
    ���Ҫ�򿪵��ļ���RTF��ʽ,��ֻ��ʹ����TRICHEDIT.LOADFROM
FILE�������ɡ���Ȼ��Trichedit.plaintext��Ϊ�������ʾӢ�Ĵ�
�ı��ļ�,������ֱ���ṩ�����Ĵ��ı��ļ�,���û���ĸ�ͨ����
���༭����"��ʶ"���ı��ļ�,���Ա����Լ�����ת�����򡣲�����
�Dz���Ҫ������ϸ�˽�RTF�ļ��洢��ʽ��������߽��ṩһ�ֽ���
���ļ�ת��Ϊ����RTF��ʽ�ļ��ķ���������༭����

    1.�������ᵽ��Tricheditʾ���������,Ȼ��ȱʡ�����Ϊ��
��,����һ�ַ�,��MOA L.TXT����,Ȼ���ڼ��±��е���MODAL.TXT,ɾ
ȥ������,����һ��:\pard\plain\f3\fs6\ cf0��

    2.��д���¹��:
    procedure convert;
    var txtchar:char;
    tmpstr:string;
    size:integer;
    tmpfile,txtfile:textfile;
    begin
    copyfile(��modal.txt',��convertf.tem',false);{�����ļ�ͷ
}
    assignfile(txtfile,opendialog.filename);{Ҫת�����ı���
��}
    assignfile(tmpfile,��convertf.tem');{��ʱ�ļ�}
    reset(txtfile);{�Զ���ʽ���ı��ļ�}
    append(tmpfile);{����ӷ�ʽ����ʱ�ļ�}
    while not eof(txtfile)do begin
       read(txtfile,txtchar);
       if ord(txtchar)=10 then read(txtfile,txtchar);
       write(tmpfile,��\par');{���׸�ʽ�ַ�}
       while (ord(txtchar)<>13)and (not eof(txtfile))do begi
n
         if ord(txtchar)>127 then{�Ժ��ָ�ʽ�洢�����ַ�}
            write(tmpfile,��\',char(39),bcdtohexhi(ord(txtch
ar)),bcdtohexlo(or( txtchar)))
         else write(tmpfile,txtchar);{����ͨ��ʽ�洢Ӣ���ַ�
}
            read(txtfile,txtchar);
      end;
      if ord(txtchar)=13 then
         begin writeln(tmpfile,"");end;
      else begin
         if ord(txtchar)>127 then
         writeln(tmpfile,��\',char(39),bcdtohexhi(ord(txtcha
r)),bcdtohexlo(ordt xtchar)))
     else writeln(tmpfile,txtchar);
      end;
      end;
      write(tmpfile,��\par}');
      system.close(tmpfile);
      system.close(txtfile);
    end;
    ����,ת����Ľ�����convertf.tem��,bcdtohexhi��bcdtohex
lo��ʮ������ת��Ϊ6 ������ظ�λ�͵�λ�ַ�

    �洢�ļ�
    �����ΪRTF��ʽ,��ֱ����Trichedit.savetofile��������;��
���Ϊ���ı���ʽ,������Լ����ʵ�֡�
    ��������:
    procedure saveastext;
    var buffer:pchar;
     filetosave:textfile;
     textlenth:integer;
    begin
     textlenth:=richedit1.gettextlen+1;
     getmem(buffer,textlenth);
     richedit1.gettextbuf(buffer,textlenth);
     assignfile(filetosave,��filename.txt');
     rewrite(filetosave);
     writeln(filetosave,buffer);
     system.close(filetosave);
    end;

    ��ӡ�ļ�
    Trichedit�ṩ��print������ӡ�ļ�����ӡʱֻ��ִ�����´���
����:
    if PrintDialog.Execute then   RichEdit1.Print(FFileName)
;
    Ϊ���ṩ�ḻ�Ĵ�ӡ����,�����Tprintdialog�ؼ����Խ���һ
����:
    Tprintdialog.options.popagenum:=true;{�ɴ�ӡѡ��ҳ��Χ
}
    Tprintdialog.options.poselection:=true;{�ɴ�ӡѡ���ı�}
    Tprintdialog.maxpage:=100;{��һ��ֵ����}
    Tprintdialog.collateΪ��,���ӡʱ�Զ�����ӡ��ֽ��������
��,��֮������Ļ��ʾΪ׼������������Ϊȱʡֵ���ɡ�
    ����,������Լ�����ҳ�߾�,�͵õ���Windows API�ˡ�
    �����ַ�
    TRICHEDIT�ṩ��һ��findtext����,��������:
    function FindText(const SearchStr:string;StartPos,Length
:Integer;Options:Te archTypes);Integer;
    TSearchType��������:
    TSearchType=set of (stWholeWord,stMatchCase);
    TSearchTypes=set of TSearchType;
    stWholeWord:ȫ��ƥ��;stMatchCase:��Сдƥ�䡣
    ����:��������ļ�ͷ����Сд����һ����abc�����ַ�,��
�������´���:
    strtosearch:��abc';{string type}
    selresult:=richedit1.findtext(strtosearch,1,richedit1.ge
ttextlen,[stMatchCs e]);
    if selresult<>-1 then
    begin
       richedit.selstart:=selresult;
       richedit.sellength:=length(strtosearch);
    end;
    ��ע�⽫HideSelection��ΪFalse��
    ����,Trichedit.wordwrap��Ϊ��,��֧���Զ��س�,��֮��֧
�֡�
    ���ƶ�̬���ӿ�
    Ϊ��ʹͨ�ñ༭����һ�����ݵ������������ʹ��,�������Ϊ
��̬���ӿ��DZ�Ҫ�ġ���Ϊû���κβ���,������һ��̬���ӿ�Ҳ��
�Ա�C�ȵ��á�
    ���巽������:
    �ٴ�File|new...,�ڶԻ�����ѡ��DLLģ�塣
    �ڽ��ѱ�����ɵı༭��FORM���빤���ļ���
    �۱༭��FORM��implementation�ϼ���һ�й��˵��:
    procedure showeditform export;
    �ܱ༭��FORM�ij���Ԫ�����岿�ּ������´���:
    procedure showeditform
    begin
        editform:teditform.create(self);
        editform.showmodal;
        editform.destroy;
    end;
    ���ڹ��̶����ļ���begin֮ǰ����:
    exports showeditform;

--
 ________ _____          _____        ______________  _____ 
 ___  __ \___(_)________ ___(_)       __  ___/___  /_ ___(_)
 __  /_/ /__  / ___  __ \__  /        _____ \ __  __ \__  / 
 _  ____/ _  /  __  /_/ /_  /         ____/ / _  / / /_  /  
 /_/      /_/   _  .___/ /_/          /____/  /_/ /_/ /_/   
                /_/                                         

�� ��Դ:���ϴ�С�ٺ���Ϣ����վ bbs.nju.edu.cn��[FROM: hsia.nju.edu.cn]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads