need Your opinion on my solution "add OLE support to CMainFrame" 
Author Message
 need Your opinion on my solution "add OLE support to CMainFrame"

Hi.
i  want to ask your opinion on my way to add methods to MFC
SDI mainframe.
i tested it with VB and it work fine.

1.i just declare a new macro
  whice will hand the already running CCmdTraget(CMainFrame)
  to the client
2.added all the usual stuff(interface map,EnableAutomation,ODL etc....)

here is the macro:

IMPLEMENT_OLEFACTORY_DYNCREATE(CMainFrame, CFrameWnd)

static bCreate=FALSE;
CObject* Pascal CMainFrame::CreateObject()
{

      if(bCreate==FALSE)
       {
   //MFC FrameWork need a new class
                   bCreate=TRUE;
    return new CMainFrame;
     }

     //COleObjectFactory CreateInstance need aCCmdTarget
     //hand him the ALREADY created CMainFrame

     CMainFrame *pFrame=(CMainFrame*)AfxGetMainWnd();
       ASSERT(pFrame!=NULL);
       CCmdTarget* pTarget=(CCmdTarget*)pFrame;

       pTarget->InternalAddRef();
     return pTarget;

Quote:
}

//some usual stuff from the original macro
IMPLEMENT_RUNTIMECLASS(CMainFrame,CFrameWnd, 0xFFFF,CMainFrame::CreateObject)

tomer
korpro



Sun, 12 Aug 2001 03:00:00 GMT  
 need Your opinion on my solution "add OLE support to CMainFrame"

Just be sure you are handling OnFinalRelease properly and/or AddRef'ing for
your internal (inside the app) usage of the mainframe. You could have the
object destroy and release inadvertantly.

-Andy


Quote:
>Hi.
>i  want to ask your opinion on my way to add methods to MFC
>SDI mainframe.
>i tested it with VB and it work fine.

>1.i just declare a new macro
>  whice will hand the already running CCmdTraget(CMainFrame)
>  to the client
>2.added all the usual stuff(interface map,EnableAutomation,ODL etc....)

>here is the macro:

>IMPLEMENT_OLEFACTORY_DYNCREATE(CMainFrame, CFrameWnd)

>static bCreate=FALSE;
>CObject* PASCAL CMainFrame::CreateObject()
>{

>      if(bCreate==FALSE)
>       {
>   //MFC FrameWork need a new class
>                   bCreate=TRUE;
>    return new CMainFrame;
>     }

>     //COleObjectFactory CreateInstance need aCCmdTarget
>     //hand him the ALREADY created CMainFrame

>     CMainFrame *pFrame=(CMainFrame*)AfxGetMainWnd();
>       ASSERT(pFrame!=NULL);
>       CCmdTarget* pTarget=(CCmdTarget*)pFrame;

>       pTarget->InternalAddRef();
>     return pTarget;

>}
>//some usual stuff from the original macro
>IMPLEMENT_RUNTIMECLASS(CMainFrame,CFrameWnd, 0xFFFF,CMainFrame::CreateObject)

>tomer
>korpro



Sun, 12 Aug 2001 03:00:00 GMT  
 need Your opinion on my solution "add OLE support to CMainFrame"
thanks..!


Quote:

>Just be sure you are handling OnFinalRelease properly and/or AddRef'ing for



Sun, 12 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. need Your opinion on my solution "add OLE support to CMainFrame"

2. Turning "off" CMainFrame menu

3. OPINIONS on using "register" keyword

4. Opinions: A property of type "Object"?

5. Searching in "Current solution"

6. Better solution than system("ping")??

7. Better solution than system("ping")??

8. Source formatters -- not the "right" solution

9. Source formatters -- not the "right" solution

10. Solution to "Varargs for Macros"

11. FS: "Microsoft Olap Solutions" with CD

12. Borland 5.0 WIN95 "C" BWCC support

 

 
Powered by phpBB® Forum Software