, Borland C++ Builder Windows 98, 2000, XP NT.
6:
1. Borland C++ Builder. , File|New Application. D:/VMSS/U41(U42)/<user>, File|Project As. <user>, .
2. . 6.1. . .
![]() |
6.1 - |
3. . . OpenDialog. Filter FilterIndex . . Execute . ʻ FileName. RichEdit RichEdit1->Lines->LoadFromFile(OpenDialog1->FileName).
4. FileName RichEdit1->Lines->Text.Length().
5. .
6. , DOS, RichEdit. OEM Ansi, API OemToChar(txt,txt). , : RichEdit txt strcpy(); API OemToChar(txt,txt); RichEdit.
7. .
8. Edit1 RichEdit. RTF-, . RTF- , RTF-. :
// RTF
#define TXTCOLOR "\\plain\\fs20\\cf1 " //
#define TXTNOCOLOR "\\plain\\fs20 " //
#define TXTSTART "{\\rtf1\\ansi\\deff0\\deftab720 {\\fonttbl {\\f0\\fmodern Courier} } \r\n {\\colortbl\\red0\\green0\\blue0;\\red255\\green0\\blue0;}\r\n" //
|
|
#define TXTEND "}\\par" //
#define TXTPAR "\\par " //
#define TXTCR "\r\n" // .
9. :
1 - RTF- ( );
2 \r\n \par;
3 TXTCOLOR TXTNOCOLOR;
4 .
10. RTF- . :
//-------------------------------------------------------
void __fastcall TForm1::RtfIns(int n, char *txtbuf, char *str)
// RTF
// n ( )
// txtbuf
// str
{
char buff[0xffff]; // c
memset(buff,0,strlen(txtbuf));
strcpy(buff,txtbuf); //
txtbuf[n]=0; //
strcat(txtbuf,str); // RTF
strcat(txtbuf,&buff[n]); //
}
11. RTF- n ( \r\n). :
//-------------------------------------------------------
void __fastcall TForm1::RtfDel(int n, char *txtbuf, int size)
// RTF
// n ( )
// txtbuf
// size
{
char buff[0xffff]; // c
strcpy(buff,txtbuf);
txtbuf[n]=0;
strcat(txtbuf,&buff[n+size-1]);
}
12. 1 . . :
strcpy(buf,RichEdit1->Lines->Text.c_str());
RTF-
RtfIns(0,buf,TXTSTART); // RTF
RtfIns(sizeof(TXTSTART)-1,buf,TXTNOCOLOR); //
strcat(buf,TXTEND); // RTF
strcat(buf,"\0\0\0"); //
char FileName[16]="123.rtf";
int handle = open(FileName, O_CREAT|O_TEXT|O_RDWR);
write(handle, buf, strlen(buf));
close(handle);
RichEdit
RichEdit1->Lines->LoadFromFile(FileName).
13. RTF-. ( RichEdit) , ( ).
14. 2 . RTF- \r\n \par.
|
|
//
ptr=strstr(buf,TXTCR);
while(ptr!= NULL)
{//
RtfDel((int)(ptr-buf),buf,sizeof(TXTCR));
RtfIns((int)(ptr-buf),buf,TXTPAR);
ptr=strstr(buf,TXTCR);
}
15. . ( RichEdit) .
16. 3 . .
strcpy(str,Edit1->Text.c_str()); //
ptr=strstr(buf,str); //
//
while(ptr!= NULL) {
RtfIns((int)(ptr-buf),,..); //
RtfIns((int)(ptr-buf)++-1,,); //
ptr=ptr+++; //
ptr=strstr(ptr,str); //
}
17. . ( RichEdit) .
18. 4 . .
Edit2->Text=IntToStr(count); //
19. . 6.2 .
![]() |
6.2 - |
:
1. ?
2. RtfIns() RtfDel() char buff[0xffff]. , ( ) .
3. RTF- RichEdit . , .
4. Ansi , .
5. ( ).
:
:
;
;
;
;
.
. . , , .