www.pudn.com > CePropertySheet_src.zip > CePropertySheet.cpp
// CePropertySheet.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CePropertySheet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
PFNPROPSHEETCALLBACK CCePropertySheet::m_pCallBack = NULL;
CString CCePropertySheet::m_strLink;
CString CCePropertySheet::m_strTitle;
//---------------------------------------------------------------------------
//
// CCePropertySheet
//
//---------------------------------------------------------------------------
IMPLEMENT_DYNAMIC(CCePropertySheet, CPropertySheet)
CCePropertySheet::CCePropertySheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
: CPropertySheet (nIDCaption, pParentWnd, iSelectPage),
m_pWndEmptyCB (NULL)
{
m_strTitle.LoadString(nIDCaption);
HookCallback();
}
CCePropertySheet::CCePropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
: CPropertySheet (pszCaption, pParentWnd, iSelectPage),
m_pWndEmptyCB (NULL)
{
m_strTitle = pszCaption;
HookCallback();
}
CCePropertySheet::~CCePropertySheet()
{
//
// Thanks, Daniel!
//
if(m_pWndEmptyCB)
delete m_pWndEmptyCB;
}
BEGIN_MESSAGE_MAP(CCePropertySheet, CPropertySheet)
//{{AFX_MSG_MAP(CCePropertySheet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// CCePropertySheet::CePropertySheetCallBack
//
// The property sheet callback
//
int CALLBACK CCePropertySheet::CePropertySheetCallBack(HWND hWnd, UINT message, LPARAM lParam)
{
if(message == PSCB_GETLINKTEXT)
{
if(!m_strLink.IsEmpty())
{
LPTSTR pBuf = (LPTSTR)lParam;
wcscpy(pBuf, m_strLink);
}
}
else if(message == PSCB_GETTITLE)
{
if(!m_strTitle.IsEmpty())
{
LPTSTR pBuf = (LPTSTR)lParam;
wcscpy(pBuf, m_strTitle);
}
}
return (m_pCallBack)(hWnd, message, lParam);
}
// CCePropertySheet::HookCallback
//
// Hooks the MFC property sheet callback function
//
void CCePropertySheet::HookCallback()
{
m_pCallBack = m_psh.pfnCallback;
m_psh.pfnCallback = CePropertySheetCallBack;
}
//---------------------------------------------------------------------------
//
// CCePropertySheet virtual methods
//
//---------------------------------------------------------------------------
// CCePropertySheet::OnInitDialog
//
// Initialize the dialog.
// Create the empty command bar.
//
BOOL CCePropertySheet::OnInitDialog()
{
BOOL bResult = CPropertySheet::OnInitDialog();
//
// Create the empty command bar.
// Code provided by Vassili Philippov.
//
m_pWndEmptyCB = new CCeCommandBar;
if(m_pWndEmptyCB != NULL)
{
m_pWndEmptyCB->CreateEx(this);
}
return bResult;
}
//---------------------------------------------------------------------------
//
// CCePropertySheet message handlers
//
//---------------------------------------------------------------------------