JStan
asked on
Olecontainer to richedit
I am doing a program in which various objects are displayed in ole containers
for insertion in a richedit.
The richedit part of the program will paste objects with no problem and will
accept drag-drop objects with no problem. and it will
open them for editing via the doverb functions. All is AOK
However, when I insert them via the insertobject function,
they seem to be inserted ok. You can edit them whatever.
But when the file is saved and reopened, the object is no longer there.
Well if you click around on the page you can find the object but it is empty.
The verb menu comes up but errors out.
If the object is manually dragged with mouse after I insert it,it will be saved .
Does it sound like I missed a lot of code or is it a small matter.
BTW: If the object is inserted as a link, everything works perfect.
I really don't want to use a 3rd party richedit.
Thanks Jim
for insertion in a richedit.
The richedit part of the program will paste objects with no problem and will
accept drag-drop objects with no problem. and it will
open them for editing via the doverb functions. All is AOK
However, when I insert them via the insertobject function,
they seem to be inserted ok. You can edit them whatever.
But when the file is saved and reopened, the object is no longer there.
Well if you click around on the page you can find the object but it is empty.
The verb menu comes up but errors out.
If the object is manually dragged with mouse after I insert it,it will be saved .
Does it sound like I missed a lot of code or is it a small matter.
BTW: If the object is inserted as a link, everything works perfect.
I really don't want to use a 3rd party richedit.
Thanks Jim
How does your "Insert Object" into the RichEdit work ?
ASKER
hOW ABOUT IF i SEND YOU THE CODE??
OR SHOULD i POST IT HERE.
tHIS IS MY FIRST TIME USING THIS BOARD
OR SHOULD i POST IT HERE.
tHIS IS MY FIRST TIME USING THIS BOARD
Yo,
if it is not too much code, post it here. Some other experts can work on it then, too.
Slash/d003303
if it is not too much code, post it here. Some other experts can work on it then, too.
Slash/d003303
ASKER
Here it is. This problems seems to me to be an interface problem.
But if I really knew, I might be able to fix it.
I think I sent it all.
Some of the code is in the Richedit1 which is an inherited creation of mine
because I added several functions ( linescroll, topline, curpos etc.)
If it looks like I missed some, I will post it. (If I have it)
procedure TForm1.InsertObject1Click( Sender: TObject);
begin
with MyOle do {////This is a hidden ole container. User never sees this}
if InsertObjectDialog then
begin
Richedit1.InsertMyObject;
end;
end;
end;
procedure TForm1.InsertMyObject;
var
ReObject:TReObject;
MyStg:IStorage;
ClientSite: IOleClientSite;
H: THandle;
R: TRect;
ID:Tclsid;
begin
szAppName := StringToOleStr(Paramstr(0) );
with Richedit1 do
begin
FRichEditOle.SetHostNames( szAppName, StringToOl eStr(Riche dit1.Hint) );
Olecheck(FRichEditOle.GetC lientSite( ClientSite ));
ReObject.cbStruct := sizeof(ReObject);
ReObject.cp := REO_CP_SELECTION;
FRichEditOleCallback.GetNe wStorage(M yStg);
MyOle.OleObjectInterface.G etUserClas sId(ID);
ReObject.clsid := ID;
ReObject.oleobj := MyOle.OleObjectInterface;
ReObject.stg := MyStg;
ReObject.olesite := ClientSite;
ReObject.sizel.cx := 0;
ReObject.sizel.cy := 0;
If MyOle.Iconic then
ReObject.dvAspect := DVASPECT_ICON Else
ReObject.dvAspect := DVASPECT_CONTENT;
ReObject. dwFlags := REO_RESIZABLE OR REO_BELOWBASELINE;
ReObject.dwUser := 0;
FRicheditOle.InsertObject( ReObject);
R := ClientRect;
H := Handle;
ReObject.oleobj.DoVerb(ovS how, NIL, ClientSite, 0, H, R);
end;
end;
{/////////////This function is called when the richedit is created}
constructor TRichEditOleCallback.Creat e(AOwner: TMyRich);
begin
inherited Create;
FOwner:= AOwner;
end;
procedure TMyRich.CreateWnd;
begin
inherited CreateWnd;
if not RichEdit_GetOleInterface(H andle, FRichEditOle) then
raise Exception.Create('Unable to get interface');
if not RichEdit_SetOleCallback(Ha ndle, FRichEditOlecallback) then
raise Exception.Create('Unable to set callback');
end;
function TRichEditOleCallback.GetNe wStorage(o ut stg: IStorage): HRESULT;
var LockBytes: ILockBytes;
begin
Result:= S_OK;
try
OleCheck(CreateILockBytesO nHGlobal(0 , True, LockBytes));
OleCheck(StgCreateDocfileO nILockByte s(LockByte s, STGM_READWRITE
or STGM_SHARE_EXCLUSIVE or STGM_CREATE, 0, stg));
except
Result:= E_OUTOFMEMORY;
end;
end;
But if I really knew, I might be able to fix it.
I think I sent it all.
Some of the code is in the Richedit1 which is an inherited creation of mine
because I added several functions ( linescroll, topline, curpos etc.)
If it looks like I missed some, I will post it. (If I have it)
procedure TForm1.InsertObject1Click(
begin
with MyOle do {////This is a hidden ole container. User never sees this}
if InsertObjectDialog then
begin
Richedit1.InsertMyObject;
end;
end;
end;
procedure TForm1.InsertMyObject;
var
ReObject:TReObject;
MyStg:IStorage;
ClientSite: IOleClientSite;
H: THandle;
R: TRect;
ID:Tclsid;
begin
szAppName := StringToOleStr(Paramstr(0)
with Richedit1 do
begin
FRichEditOle.SetHostNames(
Olecheck(FRichEditOle.GetC
ReObject.cbStruct := sizeof(ReObject);
ReObject.cp := REO_CP_SELECTION;
FRichEditOleCallback.GetNe
MyOle.OleObjectInterface.G
ReObject.clsid := ID;
ReObject.oleobj := MyOle.OleObjectInterface;
ReObject.stg := MyStg;
ReObject.olesite := ClientSite;
ReObject.sizel.cx := 0;
ReObject.sizel.cy := 0;
If MyOle.Iconic then
ReObject.dvAspect := DVASPECT_ICON Else
ReObject.dvAspect := DVASPECT_CONTENT;
ReObject. dwFlags := REO_RESIZABLE OR REO_BELOWBASELINE;
ReObject.dwUser := 0;
FRicheditOle.InsertObject(
R := ClientRect;
H := Handle;
ReObject.oleobj.DoVerb(ovS
end;
end;
{/////////////This function is called when the richedit is created}
constructor TRichEditOleCallback.Creat
begin
inherited Create;
FOwner:= AOwner;
end;
procedure TMyRich.CreateWnd;
begin
inherited CreateWnd;
if not RichEdit_GetOleInterface(H
raise Exception.Create('Unable to get interface');
if not RichEdit_SetOleCallback(Ha
raise Exception.Create('Unable to set callback');
end;
function TRichEditOleCallback.GetNe
var LockBytes: ILockBytes;
begin
Result:= S_OK;
try
OleCheck(CreateILockBytesO
OleCheck(StgCreateDocfileO
or STGM_SHARE_EXCLUSIVE or STGM_CREATE, 0, stg));
except
Result:= E_OUTOFMEMORY;
end;
end;
a bunch of declarations is missing:
TReObject, FRichEditOle, RichEdit_SetOleCallback, Richedit1.InsertMyObject and a few more.
TReObject, FRichEditOle, RichEdit_SetOleCallback, Richedit1.InsertMyObject and a few more.
ASKER
Yea, The prog uses :
The mainform
TMyRich which is the inherited richedit
and Richole.pas
Do you think that is too much to post??
Let me know Jim
The mainform
TMyRich which is the inherited richedit
and Richole.pas
Do you think that is too much to post??
Let me know Jim
ASKER
I will try to pull out the pertinent info and post it
Hum, best would be you mail it to me.
andreas.hahn@sap-ag.de
andreas.hahn@sap-ag.de
ASKER
Alright it is kinda bit.
I E-Mailed it to you.
Thanks
If anyone else would try to figure it out, let me know
and I will E-Mail it to you also.
Thanks- Jim
I E-Mailed it to you.
Thanks
If anyone else would try to figure it out, let me know
and I will E-Mail it to you also.
Thanks- Jim
Yo,
I got your EMail and took a look at the code. Not that easy, I have to work into it this weekend.
Slash/d003303
I got your EMail and took a look at the code. Not that easy, I have to work into it this weekend.
Slash/d003303
ASKER
OK I appreciate it. I am STILL working on it also.
I bumped the points to 150.
If I had any more points I would raise it more.
Thanks for any help You can give me. It is beating me down.
Jim
I bumped the points to 150.
If I had any more points I would raise it more.
Thanks for any help You can give me. It is beating me down.
Jim
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey Man, You got it!!! ;-) ;-) ;-)
Do you have any idea how long I have benn pulling my hair out with this.
What you say makes perfect sense. But that's that HindSight people
talk about.
If I had more points, I would gladly give them to you.
Great work and Great Timing.
Jim
Do you have any idea how long I have benn pulling my hair out with this.
What you say makes perfect sense. But that's that HindSight people
talk about.
If I had more points, I would gladly give them to you.
Great work and Great Timing.
Jim
No prob. Always the same if you look at your coding over and over.
Slash/d003303
Slash/d003303
ASKER
the same thing happens. It is there but it isn't.