// (c) R.I.Allen 2002
// You may use this code in anyway that you feel, no guarantees or waranties are implied
// please keep all headers with any source used.
//
// PIChildFrm.cpp : implementation of the CPIChildFrame class
//
#include "stdafx.h"
#include "PlugInApp.h"
#include "PIChildFrame.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPIChildFrame
IMPLEMENT_DYNCREATE(CPIChildFrame, CMDIChildWnd)
BEGIN_MESSAGE_MAP(CPIChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CPIChildFrame)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPIChildFrame construction/destruction
CPIChildFrame::CPIChildFrame()
{
m_pMaps = NULL ;
m_MapCount = 0 ;
}
CPIChildFrame::~CPIChildFrame()
{
// release message map pointers
for (int i = 0 ; i < m_MapCount ; ++i)
delete m_pMaps[i] ;
delete []m_pMaps ;
}
void CPIChildFrame::InitialisePlugIns()
{
CPlugInApp *pApp = static_cast<CPlugInApp*>(AfxGetApp()) ;
// get our pointers to any plug in maps
m_pMaps = pApp->GetMessageMaps(this, m_MapCount) ;
}
/////////////////////////////////////////////////////////////////////////////
// CPIChildFrame diagnostics
#ifdef _DEBUG
void CPIChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}
void CPIChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPIChildFrame message handlers
BOOL CPIChildFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// check to see whether any of the plug-in DLL's
// want to intercept this message and process it before the application class
CPlugInApp *pApp = static_cast<CPlugInApp*>(AfxGetApp()) ;
ASSERT(pApp) ;
BOOL ret_pre = FALSE ;
BOOL ret_app = FALSE ;
BOOL ret_post = FALSE ;
m_bSuppressThisMessage = false ;
// allow DLL's to process this message before the exe
ret_pre = pApp->ProcessCommandMessageMaps(true, m_pMaps, m_MapCount, nID, nCode, pExtra, pHandlerInfo) ;
if (!m_bSuppressThisMessage)
{
// allow the exe to process the message is it hasn't been suppressed by a DLL
ret_app = CMDIChildWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo) ;
}
// allow DLL to process the message after the exe
// note that DLLs get to do this whether the message has been supressed or not
ret_post = pApp->ProcessCommandMessageMaps(false, m_pMaps, m_MapCount, nID, nCode, pExtra, pHandlerInfo) ;
if (ret_pre || ret_app || ret_post)
return TRUE ;
return FALSE ;
}
BOOL CPIChildFrame::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
LRESULT lResult ;
// special case for commands
if (message == WM_COMMAND)
{
if (OnCommand(wParam, lParam))
{
lResult = 1;
if (pResult != NULL)
*pResult = lResult;
return TRUE;
}
return FALSE;
}
// special case for notifies
if (message == WM_NOTIFY)
{
NMHDR* pNMHDR = (NMHDR*)lParam;
if (pNMHDR->hwndFrom != NULL && OnNotify(wParam, lParam, &lResult))
{
if (pResult != NULL)
*pResult = lResult;
return TRUE;
}
return FALSE;
}
// check to see whether any of the plug-in DLL's
// want to intercept this message and process it before the application class
CPlugInApp *pApp = static_cast<CPlugInApp*>(AfxGetApp()) ;
ASSERT(pApp) ;
BOOL ret_pre = FALSE ;
BOOL ret_app = FALSE ;
BOOL ret_post = FALSE ;
m_bSuppressThisMessage = false ;
// allow DLL's to process this message before the exe
ret_pre = pApp->ProcessWindowMessageMaps(true, m_pMaps, m_MapCount, message, wParam, lParam, pResult) ;
if (!m_bSuppressThisMessage)
{
// allow the exe to process the message is it hasn't been suppressed by a DLL
ret_app = CMDIChildWnd::OnWndMsg(message, wParam, lParam, pResult) ;
}
// allow DLL to process the message after the exe
// note that DLLs get to do this whether the message has been supressed or not
ret_pre = pApp->ProcessWindowMessageMaps(false, m_pMaps, m_MapCount, message, wParam, lParam, pResult) ;
if (ret_pre || ret_app || ret_post)
return TRUE ;
return FALSE ;
}