demodlg.cpp

来自「《MFC经典问答》pdf格式 拿出来大家共享一下」· C++ 代码 · 共 83 行

CPP
83
字号
// DemoDlg.cpp : implementation file
//

#include "stdafx.h"
#include "CenterDialog.h"
#include "DemoDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDemoDlg dialog


CDemoDlg::CDemoDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CDemoDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDemoDlg)
	m_nX = 0;
	m_nY = 0;
	m_nShape = -1;
	//}}AFX_DATA_INIT
}


void CDemoDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDemoDlg)
	DDX_Control(pDX, IDC_SHAPE, m_cmbShape);
	DDX_Control(pDX, IDC_Y, m_edtY);
	DDX_Control(pDX, IDC_X, m_edtX);
	DDX_Text(pDX, IDC_X, m_nX);
	DDX_Text(pDX, IDC_Y, m_nY);
	DDX_CBIndex(pDX, IDC_SHAPE, m_nShape);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDemoDlg, CDialog)
	//{{AFX_MSG_MAP(CDemoDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

///////////////////////////////////////////////////////////
// EkGetActiveFrame : function implementation
//
// Return the active frame window or NULL

CFrameWnd* EkGetActiveFrame()
{
	CWnd* pMainWnd = AfxGetMainWnd();
	ASSERT_VALID( pMainWnd );

	if( !pMainWnd->IsKindOf( RUNTIME_CLASS( CFrameWnd ) ) )
	{
		return NULL;
	}

	return static_cast<CFrameWnd*>( pMainWnd )
										->GetActiveFrame();
}

/////////////////////////////////////////////////////////////////////////////
// CDemoDlg message handlers

BOOL CDemoDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// Center our dialog window relative to the active
	// frame window
	CWnd* pActiveFrame = EkGetActiveFrame();
	ASSERT_VALID( pActiveFrame );
	CenterWindow( pActiveFrame );
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?