RichEdit, saving TTextAttributes in DBF/DBT memo's Apollo 
Author Message
 RichEdit, saving TTextAttributes in DBF/DBT memo's Apollo

RichEdit, saving TTextAttributes in DBF/DBT memo's Apollo

I can save TextAttributes in normal text files like this:

   RichEditMemo1.lines.SaveTofile('test.txt');
   RichEditMemo1.lines.LoadFromfile('test.txt');

BUT:

I am having trouble saving RichEdit settings in DBF/DBT memo
fields using Apollo. Has anybody done this successfully. What is the
matter, do we need to use the *.SMT (HyperSix) format, why won't it
save in *.DBT?

I find it simply "looses" colour and font changes within the text, as
though TRichEdit.plaintext was true, but it is set to false.

At first I thought that using TRichEdit.text property to read and
write the memo contents to and from file would loose the
TTextAttributes, but
even if I go back to the old PChar's (RichEdit.Get/SetTextBuf) it
seems
to lose those Richedit codes in the text. So the user
can make nice font changes, but when saving to file, they are lost.
Why?

Function
TMyForm.GetRawMemoDataString(ApolloItem:TApollo;MemoFieldItem:
String): string;
var
  cpMemoText: PChar;
begin
  if ApolloItem.Empty( 'NOTES' ) then begin
     {Memo1.Text := ''}
     Result:='';
  end ELSE begin
     cpMemoText := ApolloItem.GetMemo( 'NOTES', 0 );
     {Memo1.SetTextBuf( cpMemoText );}
     MainForm.MemoApollo.MemDealloc( cpMemoText );
     Result:=string(cpMemoText);
  end;
end;

Function TMyForm.GetRawMemoDataMemo(ApolloItem:TApollo;MemoFieldItem:
String;RichEditItem:TRichEdit): string;
var
  cpMemoText: PChar;
begin
  if ApolloItem.Empty( 'NOTES' ) then begin
     RichEditItem.Text := '';
     Result:='';
  end ELSE begin
     cpMemoText := ApolloItem.GetMemo( 'NOTES', 0 );
     RichEditItem.SetTextBuf( cpMemoText );
     MainForm.MemoApollo.MemDealloc( cpMemoText );
     Result:=''{string(cpMemoText)};
  end;
end;

Procedure TMyForm.SetRawMemoByString(MemoFieldName,TextItem:
String;ApolloItem: TApollo);
var cpNotes : Array[0..8000] of Char;
begin
   try
      begin

        StrPCopy( cpNotes, TextItem  );

        { Store them (Remember to use pointers to the values) }

       end;
   except
       ShowMessage( 'Record already in use!' );
   end;
end;

Procedure
TMyForm.SetRawMemoByMemo(MemoFieldName:string;RichEditItem:TRichEdit;ApolloItem:
TApollo);
var Buffer: PChar;
    Size: Byte;
    cpNotes : Array[0..8000] of Char;
begin
   try
      begin

         Size := RichEditItem.GetTextLen+1;       {Get length of
string in Edit1}
         GetMem(Buffer, Size);           {Creates Buffer dynamic
variable}
         RichEditItem.GetTextBuf(Buffer,Size);  {Puts Edit1.Text into
Buffer}

         caption:=StrPas(Buffer);
         StrPCopy( cpNotes, StrPas(Buffer) );


{doesn't work} ); *)

         {Edit2.Text := StrPas(Buffer);   {Converts Buffer to a
Pascal-style string}
         FreeMem(Buffer, Size);{Frees memory allocated to Buffer}

         { Store them (Remember to use pointers to the values) }

       end;
   except
       ShowMessage( 'Record already in use!' );
   end;
end;

procedure TMyForm.SpeedButton1Click(Sender: TObject);
var MyString: string;
begin
{   MyString:=GetRawMemoDataString(MainQuotesForm.MemoApollo,
                       'NOTES');
   Memo1.text:=MyString;
   caption:=MwLeft(MyString,100);
 }

   GetRawMemoDataMemo(MainQuotesForm.MemoApollo,'NOTES',Memo1);

end;

procedure TMyForm.SpeedButton4Click(Sender: TObject);
begin
   {SetRawMemoByString('NOTES',Memo1.text,MainQuotesForm.MemoApollo);}
   SetRawMemoByMemo('NOTES',Memo1,MainQuotesForm.MemoApollo);
end;

Please email me. I thankfully reply.

Sorry, I do not have a return address in my message header to avoid
the email gathering robots. Please cut and paste my email from here



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Converting *.DBT memo to HyperSix *.SMT memo

2. Help: Converting DOS Clipper DBF's to Windows DBF's

3. Searching in a RichEdit memo

4. Help with RichEdit and Formatted Memo fields please...

5. Help: The 'SaveToFile' method for RichEdits

6. Apollo CreateExec problem creating a new .dbf file

7. Promblems with Apollo 2.0 and conditional indexes (Foxpro 2.6 .DBF)

8. Apollo DBE, Add a field to existing DBF?

9. Some Apollo 'work-arounds'

10. DBF DBF DBF

11. Save Memo-Field with SQL

12. Saving array of real in a memo ?

 

 
Powered by phpBB® Forum Software