Hi all,

I create a MFC DLL "Static" and with wizard I add a dialog and "Microsoft web browser" ActiveX in this dialog, also I create a class for this Dialog.

All I want here to call this Dll from a Win32 app "normal c++" and load this Dialog into the Main UI, But I got an Assertion error.

Snippet of Code:

//////////////
// DLL
//////////////
//.h
class CShofhaMFCStaticApp : public CWinApp
{
public:
CShofhaMFCStaticApp();
void CreateBrowser(HWND hWnd);

// Overrides
public:
virtual BOOL InitInstance();
DECLARE_MESSAGE_MAP()

};
extern "C" __declspec(dllexport) void CreateBrowserEx(HWND hWnd);
//.cpp
ShofhaBrowser *m_pMyDlg;
extern "C" __declspec(dllexport) void CreateBrowserEx(HWND hWnd);
CShofhaMFCStaticApp* thisDLL;
__declspec(dllexport) void CreateBrowserEx(HWND hWnd)
{
thisDLL->CreateBrowser(hWnd);
}
CShofhaMFCStaticApp::CShofhaMFCStaticApp()
{
thisDLL = this;
m_pMyDlg = NULL;
}
class tempRoutingFrame {

CFrameWnd* m_pFrame ;

public:

tempRoutingFrame(CFrameWnd * pWnd= NULL)
{
// Save current value
m_pFrame = AfxGetThreadState()->m_pRoutingFrame;
// Set to value passed in. NULL by default.
AfxGetThreadState()->m_pRoutingFrame = pWnd;
}
~tempRoutingFrame()
{
// Restore m_pRoutingFrame to original value.
AfxGetThreadState()->m_pRoutingFrame = m_pFrame;
}

};

void CShofhaMFCStaticApp::CreateBrowser(HWND hWnd)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());

if(m_pMyDlg == NULL)
{
CWnd *pParent = CWnd::FromHandle(hWnd);
m_pMyDlg = new ShofhaBrowser(pParent);
m_pMyDlg->Create(IDD_MAIN, pParent);
m_pMyDlg->ShowWindow(SW_SHOW);
}
}
//and The dialog
class ShofhaBrowser : public CDialog
{
DECLARE_DYNAMIC(ShofhaBrowser)

public:
ShofhaBrowser(CWnd* pParent = NULL); // standard constructor
virtual ~ShofhaBrowser();

virtual void OnFinalRelease();

// Dialog Data
enum { IDD = IDD_MAIN };

protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support

DECLARE_MESSAGE_MAP()
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
public:
CExplorer1 m_browser;
};
//////////////
// Exe
//////////////
void CMFCtestApp::OnAppAbout()
{
/* get handle to dll */
HINSTANCE hGetProcIDDLL = LoadLibrary(TEXT("..\\ShofhaMFCStatic.dll"));

/* get pointer to the function in the dll*/
FARPROC lpfnGetProcessID = GetProcAddress(HMODULE (hGetProcIDDLL),"CreateBrowserEx");

/*
Define the Function in the DLL for reuse. This is just prototyping the dll's function.
A mock of it. Use "stdcall" for maximum compatibility.
*/
typedef BOOL (__stdcall * pICFUNC)(HWND);

pICFUNC MyFunction;
MyFunction = pICFUNC(lpfnGetProcessID);

HWND fWindow; // Window handle of the window you want to get

fWindow = FindWindow(NULL, _T("Window_title")); // Find the window

///* The actual call to the function contained in the dll */
BOOL intMyReturnVal = MyFunction(fWindow);

/* Release the Dll */
FreeLibrary(hGetProcIDDLL);
}

Please Help
Thanks in advance