• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

Embedding MS Word

Hi...

I am embedding MS Word into a Delphi Application. The problem that i have is when i resize the form  when Word is not activated... The OLE component does not change its size.

I want to be able to change the size of the Ole Container, and have Word change its size automatically.

Does somebody know how?

José Araujo
0
jiaf
Asked:
jiaf
1 Solution
 
mfhobbsCommented:
Hi, yeh, it's not an ideal situation.  In an OnResize event you have to do call a proc which does:

  if (...it is not active...) then
    if IsFullyVisible(...the container... or containing panel...) then
    begin
      ...activate...
      ...deactivate...
    end;

:)

Good luck,
-Mat

NB:

function IsFullyVisible(pWinControl: TWinControl): boolean;
begin
  Result := True;
  while (pWinControl <> nil) do
  begin
    if not pWinControl.Visible then
    begin
      Result := False;
      exit;
    end; //if
    pWinControl := pWinControl.Parent;
  end; //while
end; //IsFullyVisible
0
 
jiafAuthor Commented:
The problem is that if i activate the OLE object (using ole.DoVerb(ovShow)) then the window if resized again,because the OLE object add a menu (i don't have a regular menu), and then it enters in a loop... I solved that with a flag variable... but i don't like it that way.

I know Outlook XP uses Word for writing emails, and it does not seem to have those problem. I am wondering where i can find information about how outlook interacts with word.
0
 
mfhobbsCommented:
It's an arcane art.  I think Microsoft know all the tricks but as far as I know, they haven't released the details.  Perhaps Word is now like an Active-X control in XP?! Or now a base component... TWordEdit :)

In our app we have the ability to have 2 word windows open on the same form (upper and lower panels).  It works but, as you know, its not going to be as clean as it could be.

Good luck,
-Mat
0
 
JDuncanCommented:

Try this

The resize wvent is for the panel or form that word is embedded into.

procedure TForm.PanelResize(Sender: TObject);
begin
  OleContainer1.Align:=alClient;
  OleContainer1.Refresh;
end;


JD

0
 
CleanupPingCommented:
jiaf:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Tackle projects and never again get stuck behind a technical roadblock.
Join Now