扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:LITHE 来源:blog 2007年10月19日
关键字:
class CWizBkColorPage : public CPropertyPageImpl<CWizBkColorPage>, public CWinDataExchange<CWizBkColorPage> { public: // some stuff removed for brevity... BEGIN_DDX_MAP(CWizBkColorPage) DDX_RADIO(IDC_BLUE, m_nColor) DDX_CHECK(IDC_FAIL_DDV, m_bFailDDV) END_DDX_MAP() // Notification handlers int OnSetActive(); BOOL OnKillActive(); // DDX vars int m_nColor; protected: int m_bFailDDV; }; |
int CWizBkColorPage::OnSetActive() { SetWizardButtons ( PSWIZB_BACK | PSWIZB_NEXT ); return 0; } int CWizBkColorPage::OnKillActive() { if ( !DoDataExchange(true) ) return TRUE; // prevent deactivation if ( m_bFailDDV ) { MessageBox (_T("Error box checked, wizard will stay on this page."),_T("PSheets"), MB_ICONERROR ); return TRUE; // prevent deactivation } return FALSE; // allow deactivation } |
class CAppPropertySheet : public CPropertySheetImpl<CAppPropertySheet> { //... static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam) { int nRet = CPropertySheetImpl<CAppPropertySheet>::PropSheetCallback (hWnd, uMsg, lParam ); if ( PSCB_INITIALIZED == uMsg ) { // center sheet... somehow? } return nRet; } }; |
class CAppPropertySheet : public CPropertySheetImpl<CAppPropertySheet> { //... static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM) { if(uMsg == PSCB_INITIALIZED) { // Code copied from WTL and tweaked to use CAppPropertySheet // instead of T: ATLASSERT(hWnd != NULL); CAppPropertySheet* pT = (CAppPropertySheet*) _Module.ExtractCreateWndData(); // subclass the sheet window pT->SubclassWindow(hWnd); // remove page handles array pT->_CleanUpPages(); // Our own code follows: pT->CenterWindow ( pT->m_psh.hwndParent ); } return 0; } }; |
#define UWM_CENTER_SHEET WM_APP CAppPropertySheet 在它的消息映射链中处理这个消息: class CAppPropertySheet : public CPropertySheetImpl<CAppPropertySheet> { //... BEGIN_MSG_MAP(CAppPropertySheet) MESSAGE_HANDLER_EX(UWM_CENTER_SHEET, OnPageInit) CHAIN_MSG_MAP(CPropertySheetImpl<CAppPropertySheet>) END_MSG_MAP() // Message handlers LRESULT OnPageInit ( UINT, WPARAM, LPARAM ); protected: bool m_bCentered; // set to false in the ctor }; LRESULT CAppPropertySheet::OnPageInit ( UINT, WPARAM, LPARAM ) { if ( !m_bCentered ) { m_bCentered = true; CenterWindow ( m_psh.hwndParent ); } return 0; } |
BOOL CBackgroundOptsPage::OnInitDialog ( HWND hwndFocus, LPARAM lParam ) { GetPropertySheet().SendMessage ( UWM_CENTER_SHEET ); DoDataExchange(false); return TRUE; } |
CBackgroundOptsPage::CBackgroundOptsPage() { m_psp.dwFlags |= PSP_USEICONID; m_psp.pszIcon = MAKEINTRESOURCE(IDI_TABICON); m_psp.hInstance = _Module.GetResourceInstance(); } |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者