SDI in MFC static DLL ?
Sathish Vasudevaiah -- vsatish@netscape.com
Monday, April 22, 1996
Hello everyone,
Environ: VC++ 4.0/Win NT 3.51
I am developing a MFC static dll (actually a plugin for the Netscape
browser) and I am trying to put the AppWizard created SDI framework
within the dll. Here is what is bugging me...
I created the CNPTestApp, CPlugDoc,CPlugFrame,CPlugView classes and the
InitInstance code looks like this:
----------------------------------------------------------
CNPTestApp theApp;
....
CNPTestApp::InitInstance()
...
pDocTemplate = new CSingleDocTemplate(
IDR_MENU1,
RUNTIME_CLASS(CPlugDoc),
RUNTIME_CLASS(CPlugFrame),
RUNTIME_CLASS(CPlugView));
AddDocTemplate( pDocTemplate);
....
----------------------------------------------------------
In InitInstance, the constructors for the CPlugDoc, CPlugFrame and
CPlugView are invoked but frame window itself is *never* displayed.
When the application(browser) creates an instance of of my plugin
the proc NPP_New is invoked. I added the following lines. Now the framewindow
is displayed, menu bar appears and behaves well, all the related dialog(modal)
windows ok but the view is missing. Infact CPlugView::OnDraw is never invoked.
-----------------------------------------------------------
NPP_New:
...
data-> pFrame = (CPlugFrame *) new CPlugFrame;
data-> pFrame-> LoadFrame(IDR_MENU1);
data-> pFrame-> ShowWindow(theApp.m_nCmdShow);
data-> pFrame-> UpdateWindow();
...
-----------------------------------------------------------
At this point, I have a few questions:
1. What happened to the original set of objects created in InitInstance ?
How do I reference them ?
2. Is what I did in NPP_New correct ?
3. I understand that the problem is because there is no message pump in the
DLL. Are there any books/technotes where this setup has been discussed ?
(I looked up many MFC books, including Kruglinski's , VC++ CD samples and
also MS KB, but I still remain confused..)
Somebody please help!
thanks
sathish
Mike Blaszczak -- mikeblas@msn.com
Saturday, April 27, 1996
---------
From: owner-mfc-l@netcom.com on behalf of Sathish Vasudevaiah
Sent: Monday, April 22, 1996 04:26
> Environ: VC++ 4.0/Win NT 3.51
Thanks.
> I am developing a MFC static dll
Does that mean thta you have built a DLL which uses MFC statically? So, this
is not an extension DLL, huh?
> In InitInstance, the constructors for the CPlugDoc, CPlugFrame and
> CPlugView are invoked but frame window itself is *never* displayed.
No, they're not. Or, at least, they're not invoked in the code that you've
copied here. Later on, the constructors are indirectly invoked when you
create a new, empty file--that happens when you parse the command line.
Is this code even being run, by the way? I mean, did you try putting a
breakpoint on it?
> 1. What happened to the original set of objects created in InitInstance ?
> How do I reference them ?
Was InitInstance() even run?
> 2. Is what I did in NPP_New correct ?
I don't think the code you wrote does what you really want. The code you
wrote creates a new frame window, and then displays it. That's exactly what
you coded--you didn't ask MFC to create everything associated with that frame
window, like a new view or document. So, maybe you really wanted to write
code that tries to create a new document/view/frame instead of just a frame.
> 3. I understand that the problem is because there is no message pump in the
> DLL.
What problem? Why does your DLL need a message pump? If your DLL creates
windows, it does so on behalf of the application that created it -- and
presumably, that application has a message pump. If "the problem" you're
talking about is that your frame doesn't have a view in it, that has nothing
to do with a message pump--see the previous paragraph. Maybe "the problem"
you're talking about is something else.
> Are there any books/technotes where this setup has been discussed ?
I doubt that any MFC book covers writing a Netscape plug-in. Netscape
plug-ins are too new to have made it to the bookstores, and of such limited
interest that most authors wouldn't be interested in writing about them.
Believe it or not, it takes a lot of time to write a book and get it
published!
.B ekiM
TCHAR szPlayoffs[] = _T("Look! A skating zebra!");
| Вернуться в корень Архива
|