I would like to ask you about the following problem. I have read with
interest how people have used AFX_DATA to overcome problems with views
that are derived from MFC base classes in dlls. I would like to ask
your thoughts on the following problem:

I have an .exe that uses a splitter window. This window is used to
display various different CFormView derived classes. The literature
points to using the CreateView method of the splitterwnd to create the
new view to display. The general syntax of this is

CreateView(row, col, CRuntimeClass*, CCreateContext* );

As the view that I wish to put here is to be a CFormView derived class
of type unknown at compile or link time I decided the following

my .dll would have the following (abbreviated)

__declspec(dllexport) CRuntimeClass* getRuntimeClass() {
RUNTIME_CLASS(CmyformView); }

and my class is

class __declspec(dllexport) CMyFormView : public CFromView

with the dll having the resources etc for the FormView.

This way I tried to add the view from the dll as

hlib = LoadLibrary("...");
fn=GetProcAddress(hlib, "getRuntimeClass");
splitterWnd->CreateView(0,1, getRuntimeClass(), &context);

This always fails in the call to

IsDerivedFrom(CWnd)which is a part of the CreateView call.

It seems that although when debugging through the code that the
m_pBaseClass member of my CMyFormView class is indeed derived from a
CWnd class the actual comparison method used is the following pointer

pClassThis == pBaseClass

What am I missing. I can see that defining the _AFXDLL uses an
alternate base class derivation method - will it fix it and if so why
when I define _AFXDLL does this always result in compile errors.

Thanks guys I really appreciate any light you can throw on this one.

P.S. the .exe is statically linked with MFC and the .dll I haved tried
both statically and dynamically - neither seems to work

What am I missing here?