trichview and olevariant
trichview and olevariant
Good day.
Using the tips found in http://www.trichview.com/forums/viewtop ... ight=email, get email using the component TRichViewEdit and looked great. But this example sends the email client side and I'm adapting to the routine sending is done server side and how I use Delphi XE, the object must be passed as type OleVariant. My question is: how to send the client-side object and how can I read it on the server side (remote)?
Li also the topic that guides http://www.trichview.com/forums/viewtop ... olevariant send as SaveRTFToStream using the RTF TStringStream and receive through Stream.DataString, but server-side I could not turn on the type OleVariant Stream, someone could put an example? Thank you and sorry for language mistakes.
Using the tips found in http://www.trichview.com/forums/viewtop ... ight=email, get email using the component TRichViewEdit and looked great. But this example sends the email client side and I'm adapting to the routine sending is done server side and how I use Delphi XE, the object must be passed as type OleVariant. My question is: how to send the client-side object and how can I read it on the server side (remote)?
Li also the topic that guides http://www.trichview.com/forums/viewtop ... olevariant send as SaveRTFToStream using the RTF TStringStream and receive through Stream.DataString, but server-side I could not turn on the type OleVariant Stream, someone could put an example? Thank you and sorry for language mistakes.
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Dear Sergey, below is the code of the sending email server side (remote). Note that it is identical to the examples you've cited, but the error occurs in the use of variable OleVariant.
If you find it necessary, I can send you the two routines (client-side and server-side remote). Thank you.
function TDSServerSolERP.EnviaEmail2(const Destinatario, Assunto, Corpo,
Arquivo: string; InsereLogotipo: boolean; Anexos: OleVariant; ComCopia: string; RichViewEdit1: OleVariant): String;
var
FServidorSMTP: TIdSMTP;
FSSLHandlerSMTP: TIdSSLIOHandlerSocketOpenSSL;
FIdMessage: TIdMessage;
procedure BuildEmail;
var
Stream : TMemoryStream;
ws : String;
s : TRVRawByteString;
i : Integer;
txtpart, htmpart, txthtmpart, txthtmlimgpart : TIdText;
imgpart : TIdAttachmentMemory;
begin
// saving text
TxtPart := TIdText.Create( FIdMessage.MessageParts );
Stream := TMemoryStream.Create;
//RichViewEdit1.SaveTextToStreamW('', Stream, 80, False, False); //Original line...
TCustomRichViewEdit(RichViewEdit1).SaveTextToStreamW('', Stream, 80, False, False); This was my attempt to type cast,, but generates the error: E2089 Invalid typecast.
If you find it necessary, I can send you the two routines (client-side and server-side remote). Thank you.
function TDSServerSolERP.EnviaEmail2(const Destinatario, Assunto, Corpo,
Arquivo: string; InsereLogotipo: boolean; Anexos: OleVariant; ComCopia: string; RichViewEdit1: OleVariant): String;
var
FServidorSMTP: TIdSMTP;
FSSLHandlerSMTP: TIdSSLIOHandlerSocketOpenSSL;
FIdMessage: TIdMessage;
procedure BuildEmail;
var
Stream : TMemoryStream;
ws : String;
s : TRVRawByteString;
i : Integer;
txtpart, htmpart, txthtmpart, txthtmlimgpart : TIdText;
imgpart : TIdAttachmentMemory;
begin
// saving text
TxtPart := TIdText.Create( FIdMessage.MessageParts );
Stream := TMemoryStream.Create;
//RichViewEdit1.SaveTextToStreamW('', Stream, 80, False, False); //Original line...
TCustomRichViewEdit(RichViewEdit1).SaveTextToStreamW('', Stream, 80, False, False); This was my attempt to type cast,, but generates the error: E2089 Invalid typecast.
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
That's what I tried initially Sergey, creating a server application with component TRichView have no problems on the server side, what happens is that the problem goes to the client side because the Delphi XE can not send a component TRichView remotely (and not send other objects like ClientDataSet), so I tried send using a type OleVariant (as I did with the ClientDataSet), but I will not take more your time. I'll try to send him into a blob field through ClientDataSet and read it through ClientDataSet.Data propety. Thank you, have a nice day and congratulations for the great component that helps me so much. Hugs.
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
How to convert document in TRichView to OleVariant and back:
Code: Select all
function RVToVariant(rv: TCustomRichViewEdit): OleVariant;
var Stream: TMemoryStream;
begin
Stream := TMemoryStream.Create;
rv.SaveRVFToStream(Stream, False);
Result := VarArrayCreate([0, Stream.Size-1], varByte);
Move(Stream.Memory^, VarArrayLock(Result)^, Stream.Size);
VarArrayUnlock(Result);
Stream.Free;
end;
function VariantToRV(rv: TCustomRichView; v: OleVariant): Boolean;
var Stream: TMemoryStream;
Size: Integer;
begin
Result := False;
if VarArrayDimCount(v)<>1 then
exit;
Stream := TMemoryStream.Create;
Size := VarArrayHighBound(v,1)-VarArrayLowBound(v,1)+1;
Stream.WriteBuffer(VarArrayLock(v)^, Size);
VarArrayUnlock(v);
Stream.Position := 0;
rv.LoadRVFFromStream(Stream);
Stream.Free;
rv.Format;
Result := True;
end;
Sergei, I eliminated the line "rv.Format;" because it created two errors: 1. - The content sent to the memory was read only when a second email was sent 2. - 'Canvas does not allow drawing'. The error number 2 only occurred when I closed the client application and called it again. So I had to restart the application server to send the email. Somewhat confusing is not it? After several tests I saw that was enough to eliminate the rv.Format line, this problem may be the same as reported DavideCase (http://www.trichview.com/forums/viewtopic.php?t=5479). Searching the internet and read something about Canvas.Lock Canvas.Unlock. I was tested and the system worked with these lines and also without them. What do you think ?
Below like it is:
VariantToRV function (rv: TCustomRichView, v: OleVariant): Boolean;
var Stream: TMemoryStream;
Size: Integer;
begin
Result: = False;
if VarArrayDimCount (v) <> 1 then
exit;
Stream: = TMemoryStream.Create;
Size: VarArrayHighBound = (v 1) VarArrayLowBound (v, 1) +1;
Stream.WriteBuffer (VarArrayLock (v) ^, Size);
VarArrayUnlock (v);
Stream.Position: = 0;
rv.Canvas.Lock;
rv.LoadRVFFromStream (Stream);
Stream.Free;
/ / rv.Format;
rv.Canvas.UnLock;
Result: = True;
end;
Thanks.
Below like it is:
VariantToRV function (rv: TCustomRichView, v: OleVariant): Boolean;
var Stream: TMemoryStream;
Size: Integer;
begin
Result: = False;
if VarArrayDimCount (v) <> 1 then
exit;
Stream: = TMemoryStream.Create;
Size: VarArrayHighBound = (v 1) VarArrayLowBound (v, 1) +1;
Stream.WriteBuffer (VarArrayLock (v) ^, Size);
VarArrayUnlock (v);
Stream.Position: = 0;
rv.Canvas.Lock;
rv.LoadRVFFromStream (Stream);
Stream.Free;
/ / rv.Format;
rv.Canvas.UnLock;
Result: = True;
end;
Thanks.
-
- Site Admin
- Posts: 17571
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: