EDN Admin
Well-known member
Hello Guys,<br/> <br/> I am trying to put a dockable pane into a DLL. The reason for this would be to be able to enable/disable feature in a MDI application or have custom DLL for different configuration providing customized features.<br/> <br/> So, so far I have create a DLL with a CDockablePane drived class, then an interface function to return a CDockablePane pointer of this custom pane.<br/> <br/>
<pre>CDockablePane* CreateDialogPane(void)
{
return new CExplorerPane();
} [/code]
<br/> <br/> <br/> Then my dockable pane header is like this<br/> <br/>
<pre>#ifndef _CExplorerBar_H_
#define _CExplorerBar_H_
#include "afxDockablePane.h"
// CExplorerBar
class CExplorerPane : public CDockablePane
{
DECLARE_DYNAMIC(CExplorerPane)
public:
CExplorerPane();
virtual ~CExplorerPane();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
void AdjustLayout(void);
afx_msg void OnPaint();
};
#endif[/code]
<br/> <br/> <br/> The DLL is a regular DLL with MFC statically linked. It compiles and I checked the exports.<br/> <br/> Back to the MDI application, I just created a fresh one with the demo pane and Visual Studio style (VS2008 with feature pack).<br/> <br/> Inside I added a little method in CMainFrame to load the DLL and get the function pointer. It could be prettier later on but this is what I have at this stage:<br/> <br/>
<pre>BOOL CMainFrame::LoadExplorerPane(void)
{
typedef CDockablePane* (*CreateExplorerPaneFuncT)(void);
m_hLib = LoadLibrary(_T("Explorer.dll"));
CreateExplorerPaneFuncT func = (CreateExplorerPaneFuncT)GetProcAddress(m_hLib, "CreateDialogPane");
// Call the function.
m_pExplorerPane = func();
return (m_pExplorerPane != 0);
}[/code]
<br/> <br/> <br/> This works fine, I get a valid pointer and the debugger breaks in CExplorerPanes constructor, OnCreate, etc...<br/> <br/> Last part: CMainFrame has a CreateDockingWindows method where the other windows are created. So I added mine:<br/> <br/>
<pre>BOOL CMainFrame::CreateDockingWindows()
{
// ...
if(LoadExplorerPane())
{
CString sExplorerWindow = _T("Explorer");
m_pExplorerPane->Create(
sExplorerWindow,
this,
CRect(0, 0, 100, 100),
TRUE,
ID_EXPLORER_VIEW,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI);
m_pExplorerPane->EnableDocking(CBRS_ALIGN_ANY);
}
SetDockingWindowIcons(theApp.m_bHiColorIcons);
return TRUE;
}[/code]
<br/> <br/> <br/> The application asserts at m_pExplorerPane->Create() inside the MFC classes (afxdragframeimpl.cpp).<br/> <br/> Am i doing something badly wrong? Could someone guide me a bit. Ill send the full source to anybody kind enough to have a look at it; I just couldnt find a way to attach it in this forum...<br/> <br/> Thanks,<br/> -Damien<br/> <br/>
View the full article
<pre>CDockablePane* CreateDialogPane(void)
{
return new CExplorerPane();
} [/code]
<br/> <br/> <br/> Then my dockable pane header is like this<br/> <br/>
<pre>#ifndef _CExplorerBar_H_
#define _CExplorerBar_H_
#include "afxDockablePane.h"
// CExplorerBar
class CExplorerPane : public CDockablePane
{
DECLARE_DYNAMIC(CExplorerPane)
public:
CExplorerPane();
virtual ~CExplorerPane();
protected:
DECLARE_MESSAGE_MAP()
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
void AdjustLayout(void);
afx_msg void OnPaint();
};
#endif[/code]
<br/> <br/> <br/> The DLL is a regular DLL with MFC statically linked. It compiles and I checked the exports.<br/> <br/> Back to the MDI application, I just created a fresh one with the demo pane and Visual Studio style (VS2008 with feature pack).<br/> <br/> Inside I added a little method in CMainFrame to load the DLL and get the function pointer. It could be prettier later on but this is what I have at this stage:<br/> <br/>
<pre>BOOL CMainFrame::LoadExplorerPane(void)
{
typedef CDockablePane* (*CreateExplorerPaneFuncT)(void);
m_hLib = LoadLibrary(_T("Explorer.dll"));
CreateExplorerPaneFuncT func = (CreateExplorerPaneFuncT)GetProcAddress(m_hLib, "CreateDialogPane");
// Call the function.
m_pExplorerPane = func();
return (m_pExplorerPane != 0);
}[/code]
<br/> <br/> <br/> This works fine, I get a valid pointer and the debugger breaks in CExplorerPanes constructor, OnCreate, etc...<br/> <br/> Last part: CMainFrame has a CreateDockingWindows method where the other windows are created. So I added mine:<br/> <br/>
<pre>BOOL CMainFrame::CreateDockingWindows()
{
// ...
if(LoadExplorerPane())
{
CString sExplorerWindow = _T("Explorer");
m_pExplorerPane->Create(
sExplorerWindow,
this,
CRect(0, 0, 100, 100),
TRUE,
ID_EXPLORER_VIEW,
WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_LEFT| CBRS_FLOAT_MULTI);
m_pExplorerPane->EnableDocking(CBRS_ALIGN_ANY);
}
SetDockingWindowIcons(theApp.m_bHiColorIcons);
return TRUE;
}[/code]
<br/> <br/> <br/> The application asserts at m_pExplorerPane->Create() inside the MFC classes (afxdragframeimpl.cpp).<br/> <br/> Am i doing something badly wrong? Could someone guide me a bit. Ill send the full source to anybody kind enough to have a look at it; I just couldnt find a way to attach it in this forum...<br/> <br/> Thanks,<br/> -Damien<br/> <br/>
View the full article