📄 sample05dlg.cpp
字号:
// Sample05Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "Sample05.h"
#include "Sample05Dlg.h"
#include "DlgProxy.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSample05Dlg dialog
IMPLEMENT_DYNAMIC(CSample05Dlg, CDialog);
CSample05Dlg::CSample05Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CSample05Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSample05Dlg)
m_sDept = _T("");
m_sEmail = _T("");
m_nID = 0;
m_sName = _T("");
m_sPhone = _T("");
m_sRemark = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
m_pAutoProxy = NULL;
}
CSample05Dlg::~CSample05Dlg()
{
// If there is an automation proxy for this dialog, set
// its back pointer to this dialog to NULL, so it knows
// the dialog has been deleted.
if (m_pAutoProxy != NULL)
m_pAutoProxy->m_pDialog = NULL;
}
void CSample05Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSample05Dlg)
DDX_Text(pDX, IDC_DEPT, m_sDept);
DDX_Text(pDX, IDC_EMAIL, m_sEmail);
DDX_Text(pDX, IDC_ID, m_nID);
DDX_Text(pDX, IDC_NAME, m_sName);
DDX_Text(pDX, IDC_PHONE, m_sPhone);
DDX_Text(pDX, IDC_REMARK, m_sRemark);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSample05Dlg, CDialog)
//{{AFX_MSG_MAP(CSample05Dlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_PREV, OnPrev)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_FIRST, OnFirst)
ON_BN_CLICKED(IDC_LAST, OnLast)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSample05Dlg message handlers
BOOL CSample05Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_recordInfo.Open();
m_recordInfo.MoveFirst();
ShowRecord();
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CSample05Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CSample05Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
// Automation servers should not exit when a user closes the UI
// if a controller still holds on to one of its objects. These
// message handlers make sure that if the proxy is still in use,
// then the UI is hidden but the dialog remains around if it
// is dismissed.
void CSample05Dlg::OnClose()
{
if (CanExit())
CDialog::OnClose();
}
void CSample05Dlg::OnOK()
{
if (CanExit())
CDialog::OnOK();
}
void CSample05Dlg::OnCancel()
{
if (CanExit())
CDialog::OnCancel();
}
BOOL CSample05Dlg::CanExit()
{
// If the proxy object is still around, then the automation
// controller is still holding on to this application. Leave
// the dialog around, but hide its UI.
if (m_pAutoProxy != NULL)
{
ShowWindow(SW_HIDE);
return FALSE;
}
return TRUE;
}
void CSample05Dlg::OnPrev()
{
m_recordInfo.MovePrev();
ShowRecord();
}
void CSample05Dlg::OnNext()
{
m_recordInfo.MoveNext();
ShowRecord();
}
void CSample05Dlg::OnFirst()
{
m_recordInfo.MoveFirst();
ShowRecord();
}
void CSample05Dlg::OnLast()
{
m_recordInfo.MoveLast();
ShowRecord();
}
void CSample05Dlg::ShowRecord()
{
m_nID = m_recordInfo.m_ID;
m_sName = m_recordInfo.m_column0;
m_sDept = m_recordInfo.m_column1;
m_sPhone = m_recordInfo.m_column2;
m_sEmail = m_recordInfo.m_Email;
m_sRemark = m_recordInfo.m_column3;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -