15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Help with OLE.

Andrew Rivett -- andrew@nexis.net
Thursday, January 09, 1997

Environment: VC++ 4.0, NT 4.0

	My problem right now, is that I am trying to embed Internet Explorer
as a Com Control, and I cann't find any documentation on how to do
this.  I have found lots on making com controls, and ActiveX controls,
but none on this.  If anybody can point me in the right direction I
would really appreciate it, and if anybody can recommend any books that
I should look at getting.

Thanx for the help,
andrew.

+------------------------------------------------------------------------+
| Andrew Rivett                                 email : arivett@ican.net |
| Software Developer                            phone :  +1 416 236-3636 |
| ACC/Netmedia                                  fax   :  +1 416 207-7125 |
+------------------------------------------------------------------------+



Erik Funkenbusch -- chucks@isd.net
Friday, January 10, 1997

[Mini-digest: 2 responses]

That's because (from my understanding, which i'll admit is a bit old at
this point) IE is not a control, it's an activeX document object.  I seem
to recall that there might have been a control which is a docobject
container for IE, but I can't remember if this was during the beta or not.

Unfortunately, MFC doesn't support (out of the box) being a docobject
container, it does support being a docobject server though.  You'll need to
do plenty of work to make MFC work as a container.

----------
> From: Andrew Rivett 
> Subject: Help with OLE.
> Date: Thursday, January 09, 1997 9:30 AM
> 
> Environment: VC++ 4.0, NT 4.0
> 
> 	My problem right now, is that I am trying to embed Internet Explorer
> as a Com Control, and I cann't find any documentation on how to do
> this.  I have found lots on making com controls, and ActiveX controls,
> but none on this.  If anybody can point me in the right direction I
> would really appreciate it, and if anybody can recommend any books that
> I should look at getting.

-----From: "Ronald D. Patton" 

Andrew,

This is actually quite simple if I understand your question
correctly. If you have installed IE 3.0 (or later) on your 
system you should have an OLE Control on the OLE
control page of Component Gallery entitled "Microsoft
Web Browser Control". 

I don't know the legalities of using this control outside
of IE however.

Good Luck....
Ron Patton
Informix Software

----------
> From: Andrew Rivett 
> To: mfc-l@netcom.com
> Subject: Help with OLE.
> Date: Thursday, January 09, 1997 9:30 AM
> 
> Environment: VC++ 4.0, NT 4.0
> 
> 	My problem right now, is that I am trying to embed Internet Explorer
> as a Com Control, and I cann't find any documentation on how to do
> this.  I have found lots on making com controls, and ActiveX controls,
> but none on this.  If anybody can point me in the right direction I
> would really appreciate it, and if anybody can recommend any books that
> I should look at getting.
> 
> Thanx for the help,
> andrew.
> 
>
+------------------------------------------------------------------------+
> | Andrew Rivett                                 email : arivett@ican.net
|
> | Software Developer                            phone :  +1 416 236-3636
|
> | ACC/Netmedia                                  fax   :  +1 416 207-7125
|
> +------------------------------------------------------------------------+



Alex Irazabal -- airazaba@cc.mcafee.com
Monday, January 13, 1997

[Mini-digest: 2 responses]

     Look for documentation on shdocvw.dll. It's a regular COM server with 
     events. It provides basic support for HTML viewing and URL 
     downloading.
     Alex


______________________________ Reply Separator _________________________________
Subject: Re: Help with OLE.
Author:  chucks@isd.net (Erik Funkenbusch) at MHS
Date:    1/10/97 1:34 PM


[Mini-digest: 2 responses]
     
That's because (from my understanding, which i'll admit is a bit old at 
this point) IE is not a control, it's an activeX document object.  I seem 
to recall that there might have been a control which is a docobject 
container for IE, but I can't remember if this was during the beta or not.
     
Unfortunately, MFC doesn't support (out of the box) being a docobject 
container, it does support being a docobject server though.  You'll need to 
do plenty of work to make MFC work as a container.
     
----------
> From: Andrew Rivett  
> Subject: Help with OLE.
> Date: Thursday, January 09, 1997 9:30 AM 
>
> Environment: VC++ 4.0, NT 4.0
>
>      My problem right now, is that I am trying to embed Internet Explorer 
> as a Com Control, and I cann't find any documentation on how to do
> this.  I have found lots on making com controls, and ActiveX controls, 
> but none on this.  If anybody can point me in the right direction I
> would really appreciate it, and if anybody can recommend any books that 
> I should look at getting.
     
-----From: "Ronald D. Patton" 
     
Andrew,
     
This is actually quite simple if I understand your question 
correctly. If you have installed IE 3.0 (or later) on your 
system you should have an OLE Control on the OLE
control page of Component Gallery entitled "Microsoft 
Web Browser Control".
     
I don't know the legalities of using this control outside 
of IE however.
     
Good Luck....
Ron Patton
Informix Software
     
----------
> From: Andrew Rivett  
> To: mfc-l@netcom.com
> Subject: Help with OLE.
> Date: Thursday, January 09, 1997 9:30 AM 
>
> Environment: VC++ 4.0, NT 4.0
>
>      My problem right now, is that I am trying to embed Internet Explorer 
> as a Com Control, and I cann't find any documentation on how to do
> this.  I have found lots on making com controls, and ActiveX controls, 
> but none on this.  If anybody can point me in the right direction I
> would really appreciate it, and if anybody can recommend any books that 
> I should look at getting.
>
> Thanx for the help,
> andrew.
>
>
+------------------------------------------------------------------------+ 
> | Andrew Rivett                                 email : arivett@ican.net 
|
> | Software Developer                            phone :  +1 416 236-3636 
|
> | ACC/Netmedia                                  fax   :  +1 416 207-7125 
|
> +------------------------------------------------------------------------+
-----From: "Mike Lechner" 

Try microsoft's web site, http:/www.microsoft.com/intdev.
The WebBrowser control has some documentation there.
Mike

----------
From: 	owner-mfc-l@majordomo.netcom.com on behalf of Andrew Rivett
Sent: 	Thursday, January 09, 1997 8:30 AM
To: 	mfc-l@netcom.com
Subject: 	Help with OLE.

Environment: VC++ 4.0, NT 4.0

	My problem right now, is that I am trying to embed Internet Explorer
as a Com Control, and I cann't find any documentation on how to do
this.  I have found lots on making com controls, and ActiveX controls,
but none on this.  If anybody can point me in the right direction I
would really appreciate it, and if anybody can recommend any books that
I should look at getting.

Thanx for the help,
andrew.

+------------------------------------------------------------------------+
| Andrew Rivett                                 email : arivett@ican.net |
| Software Developer                            phone :  +1 416 236-3636 |
| ACC/Netmedia                                  fax   :  +1 416 207-7125 |
+------------------------------------------------------------------------+




Mike Blaszczak -- mikeblas@nwlink.com
Tuesday, January 14, 1997

At 13:34 1/10/97 -0600, Erik Funkenbusch wrote:

>That's because (from my understanding, which i'll admit is a bit old at
>this point) IE is not a control, it's an activeX document object. 

IE is available as a control and as a document object.  The document object
version is slightly more full-featured, but both incarnations of the
browser are very easy to reuse and very robust.

>You'll need to do plenty of work to make MFC work as a container. 

It's not really very hard; you can subclass COleContainerItem and add on
the one extra interface you need. Menu merging is a little difficult,
mainly because the spec is weakly worded.

You'll probably notice containment functionality popping up in some future
version of MFC.

>-----From: "Ronald D. Patton" 

>I don't know the legalities of using this control outside
>of IE however.

The ActiveX SDK has documentation on the control. The ActiveX SDK also
includes a redistributables kit, which shows which components can
be redistrubted and explains the rules for redistributing them.


.B ekiM
http://www.nwlink.com/~mikeblas/
Why does the "new" Corvette look like a 1993 RX-7?
These words are my own. I do not speak on behalf of Microsoft.




waynet@blue-sky.com
Wednesday, January 15, 1997

MFC doesn't support DocObject container, but most of the requeired  =20
interfaces are
there and you just need to do a little thing. Here are the steps to  =20
create DocObject
container using MFC 4.2:

1. Use AppWizard to create OLE container. It doesn't matter whether is  =20
MDI or SDI.
2. Add the following code in the cntriterm.h:
 BEGIN_INTERFACE_PART(OleDocumentSite, IOleDocumentSite)
  INIT_INTERFACE_PART(CYourCntrItem, OleDocumentSite)
        STDMETHOD(ActivateMe)(IOleDocumentView *);
 END_INTERFACE_PART(OleDocumentSite)
 DECLARE_INTERFACE_MAP()
The IOleDocumentSite is required by DocObject and MFC just misses this  =20
one.

3. Add the following code in cntritem.cpp:
 BEGIN_INTERFACE_MAP(CYourCntrItem, COleClientItem)
  INTERFACE_PART(CYourCntrItem, IID_IOleDocumentSite, OleDocumentSite)
 END_INTERFACE_MAP()

 /////////////////////////////////////////////////////////////////////////=20=
=20
////

 STDMETHODIMP_(ULONG) CYourCntrItem::XOleDocumentSite::AddRef()
 {
  METHOD_PROLOGUE_EX(CYourCntrItem, OleDocumentSite)
  return pThis->ExternalAddRef();
 }

 STDMETHODIMP_(ULONG) CYourCntrItem::XOleDocumentSite::Release()
 {
  METHOD_PROLOGUE_EX(CYourCntrItem, OleDocumentSite)
  return pThis->ExternalRelease();
 }

 STDMETHODIMP CYourCntrItem::XOleDocumentSite::QueryInterface(REFIID iid, =20=
=20
LPVOID* ppvObj)
 {
  METHOD_PROLOGUE_EX(CYourCntrItem, OleDocumentSite)
  return pThis->ExternalQueryInterface(&iid, ppvObj);
 }

 STDMETHODIMP  =20
CYourCntrItem::XOleDocumentSite::ActivateMe(IOleDocumentView *pView)
 {
  RECT                rc;
      IOleDocument*       pDoc;
     =20

  METHOD_PROLOGUE_EX(CWord2CntrItem, OleDocumentSite)
  // TODO: Add more

  IOleInPlaceSite* pIOleInPlaceSite;
  pThis->InternalQueryInterface(&IID_IOleInPlaceSite, (void  =20
**)&pIOleInPlaceSite);
  if (NULL=3D=3DpView)
          {

   if (FAILED(pThis->m_lpObject->QueryInterface(IID_IOleDocument
               , (void **)&pDoc)))
               return E_FAIL;

   if (FAILED(pDoc->CreateView(pIOleInPlaceSite,
            NULL, 0, &pView)))
            return E_OUTOFMEMORY;

        // Release doc pointer since CreateView is a good com method that =20=
=20
addrefs
        pDoc->Release();
        }
    else
        {
        //Make sure that the view has our client site
        pView->SetInPlaceSite(pIOleInPlaceSite);

        //We're holding onto the pointer, so AddRef it.
        pView->AddRef();
        }


    /*
     * Activation steps, now that we have a view:
     *
     *  1.  Call IOleDocumentView::SetInPlaceSite (assume done since
     *      either the view already knows, or IOleDocument::CreateView
     *      has done it already.
     *
     *  2.  Call IOleDocumentView::SetRect to give a bunch of space to
     *      the view.  In our case this is the whole client area of
     *      the CPages window.  (Patron doesn't use SetRectComplex)
     *
     *  3.  Call IOleDocumentView::Show to make the thing visible.
     *
     *  4.  Call IOleDocumentView::UIActivate to finish the job.
     *
     */

/*
    m_pSite->m_fDocObj=3DTRUE;
    m_pSite->m_pIOleDocView=3DpView;
*/
    //This sets up toolbars and menus first
    pView->UIActivate(TRUE);

    //Set the window size sensitive to new toolbars
    pThis->GetActiveView()->GetClientRect(&rc);
    pView->SetRect(&rc);

 //Makes it all active
    pView->Show(TRUE);
    return NOERROR;
}

 (sorry about the messed format)

4. in your doc file, overwrite the OnNewDocument() like this:

BOOL CYourDoc::OnNewDocument()
{
 if (!COleDocument::OnNewDocument())
  return FALSE;

 // TODO: add reinitialization code here
 // (SDI documents will reuse this document)

 POSITION pos;
 pos =3D GetFirstViewPosition();
 CView* pView;
 pView =3D (CView*)GetNextView(pos);
 CWnd* pFrame =3D pView->GetParentFrame();
 ((CMDIFrameWnd*)AfxGetApp()->GetMainWnd())->MDIActivate(pFrame);

 // Here I'm using paint brush as an example
 // You can use any other clsid of docObject server application
 CLSID clsidWord;
 CLSIDFromProgID(L"Paint.Picture", &clsidWord);

 m_pItem =3D new CYourCntrItem(this);
 m_pItem->CreateNewItem(clsidWord);
 m_pItem->DoVerb(OLEIVERB_SHOW, pView);
 UpdateAllViews(NULL);

 return TRUE;
}

5. Add some clean up code. (omitted)

Then build your project and you are done.

Wayne

 -----Original Message-----
Unfortunately, MFC doesn't support (out of the box) being a docobject
container, it does support being a docobject server though.  You'll need  =20
to
do plenty of work to make MFC work as a container.
      =20

 ----------

-----------------------------
Blue Sky Software Corporation
7777 Fay Avenue, Suite 201
La Jolla CA 92037 USA

619.551.2485 Voice
619.551.2486 Fax

http://www.blue-sky.com
-----------------------------



Erik Funkenbusch -- chucks@isd.net
Thursday, January 16, 1997

This doesn't let MFC support the full DocObject spec, it only supports a
very limited functionality, it doesn't include multiple views, printing,
command handling... which is why I indicated that making MFC support
docobjects (not just allow you to embed a docobject) was not very simple.

----------
From: waynet@blue-sky.com
To: mfc-l@netcom.com
Subject: RE: Help with OLE.
Date: Wednesday, January 15, 1997 2:08 PM

MFC doesn't support DocObject container, but most of the requeired   
interfaces are
there and you just need to do a little thing. Here are the steps to   
create DocObject
container using MFC 4.2:

[lots of code deleted]

 -----Original Message-----
Unfortunately, MFC doesn't support (out of the box) being a docobject
container, it does support being a docobject server though.  You'll need   
to
do plenty of work to make MFC work as a container.
       

 ----------

-----------------------------
Blue Sky Software Corporation
7777 Fay Avenue, Suite 201
La Jolla CA 92037 USA

619.551.2485 Voice
619.551.2486 Fax

http://www.blue-sky.com
-----------------------------
----------




Mike Blaszczak -- mikeblas@nwlink.com
Saturday, January 18, 1997

At 21:56 1/16/97 -0600, Erik Funkenbusch wrote:
>This doesn't let MFC support the full DocObject spec, it only supports a
>very limited functionality, it doesn't include multiple views,

_No_ existing Microsoft DocObject servers (Excel or Word, for example),
or containers (Internet Explorer or the Office Binder, for example)
support multiple views, and there's a chance that the multiple view
feature of the document object specification will be fased out.

> printing, command handling...

Code to use IOlePrint on the server is pretty simple for
the container to implement.  Implementing a true
BEGIN_OLECMD_MAP()-compatible command-handling mechanism for the
container could be pretty involved, but it wouldn't be very hard to
add a IOleCmdTarget interface to your container that directly handled 
the commands you wanted to handle without fooling around with any
dispatch mechanism.



.B ekiM
http://www.nwlink.com/~mikeblas/
Why does the "new" Corvette look like a 1993 RX-7?
These words are my own. I do not speak on behalf of Microsoft.




Erik Funkenbusch -- chucks@isd.net
Monday, January 20, 1997

> From: Mike Blaszczak 
> _No_ existing Microsoft DocObject servers (Excel or Word, for example),
> or containers (Internet Explorer or the Office Binder, for example)
> support multiple views, and there's a chance that the multiple view
> feature of the document object specification will be fased out.

This is a shame, When I first read the multiple view spec I thought of many
wonderful uses for it with component systems (mostly internal, i could
understand how trying to support generic multi-view could get pretty hairy
when you don't have any knowledge about the container or server).  I
suspected that the entire multi-view option was similar to the vast
expandability of OLE that was never implemented (ie. transacted and sharing
of streams, expanded locking support, etc..) when I could get no
information from anywhere about how to implement it.

I did some extensive MFC hacking to try and support this, but it never
worked out.  I found the hardest part to be working around asumptions that
MFC had made internal to it's interface implementations.  I almost went so
far as to completly override most of the implementation before giving up,
hoping that someone who knew the internal structure of MFC better than I
would come up with a solution.

> Code to use IOlePrint on the server is pretty simple for
> the container to implement.  Implementing a true
> BEGIN_OLECMD_MAP()-compatible command-handling mechanism for the
> container could be pretty involved, but it wouldn't be very hard to
> add a IOleCmdTarget interface to your container that directly handled 
> the commands you wanted to handle without fooling around with any
> dispatch mechanism.

Hmmm... That's indeed a thought.  I hadn't thought about doing something
like that, though if you want your solution to be used internally at your
company it would be better off to try and fit it into the existing
dispatching mechanisms.

Well, I think i'll wait and see what turns up in a future version of MFC
for now.

Thanks Mike.




Erik Funkenbusch -- chucks@isd.net
Monday, January 20, 1997

> From: Mike Blaszczak 
> _No_ existing Microsoft DocObject servers (Excel or Word, for example),
> or containers (Internet Explorer or the Office Binder, for example)
> support multiple views, and there's a chance that the multiple view
> feature of the document object specification will be fased out.

This is a shame, When I first read the multiple view spec I thought of many
wonderful uses for it with component systems (mostly internal, i could
understand how trying to support generic multi-view could get pretty hairy
when you don't have any knowledge about the container or server).  I
suspected that the entire multi-view option was similar to the vast
expandability of OLE that was never implemented (ie. transacted and sharing
of streams, expanded locking support, etc..) when I could get no
information from anywhere about how to implement it.

I did some extensive MFC hacking to try and support this, but it never
worked out.  I found the hardest part to be working around asumptions that
MFC had made internal to it's interface implementations.  I almost went so
far as to completly override most of the implementation before giving up,
hoping that someone who knew the internal structure of MFC better than I
would come up with a solution.

> Code to use IOlePrint on the server is pretty simple for
> the container to implement.  Implementing a true
> BEGIN_OLECMD_MAP()-compatible command-handling mechanism for the
> container could be pretty involved, but it wouldn't be very hard to
> add a IOleCmdTarget interface to your container that directly handled 
> the commands you wanted to handle without fooling around with any
> dispatch mechanism.

Hmmm... That's indeed a thought.  I hadn't thought about doing something
like that, though if you want your solution to be used internally at your
company it would be better off to try and fit it into the existing
dispatching mechanisms.

Well, I think i'll wait and see what turns up in a future version of MFC
for now.

Thanks Mike.





| Вернуться в корень Архива |