// Edit_BoxDlg.cpp : implementation file
//#include "stdafx.h"
#include "Edit_Box.h"
#include "Edit_BoxDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
{
public:
CAboutDlg();// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CEdit_BoxDlg dialogCEdit_BoxDlg::CEdit_BoxDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEdit_BoxDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEdit_BoxDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CEdit_BoxDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEdit_BoxDlg)
DDX_Control(pDX, IDC_SINGLEEDIT, m_SingleEdit);
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CEdit_BoxDlg, CDialog)
//{{AFX_MSG_MAP(CEdit_BoxDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_SETFOCUS(IDC_SINGLEEDIT, OnSetfocusSingleedit)
ON_EN_SETFOCUS(IDC_MULTILINEEDIT, OnSetfocusMultilineedit)
ON_EN_CHANGE(IDC_MULTILINEEDIT, OnChangeMultilineedit)
ON_BN_CLICKED(IDC_CUT, OnCut)
ON_BN_CLICKED(IDC_COPY, OnCopy)
ON_BN_CLICKED(IDC_PASTE, OnPaste)
ON_BN_CLICKED(IDC_UNDO, OnUndo)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CEdit_BoxDlg message handlersBOOL CEdit_BoxDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // 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
return TRUE; // return TRUE unless you set the focus to a control
}void CEdit_BoxDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}// 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 CEdit_BoxDlg::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 CEdit_BoxDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}void CEdit_BoxDlg::OnSetfocusSingleedit()
{
// TODO: Add your control notification handler code here
IfMultilineEditFocus=FALSE;
IfSingleEditFocus=TURE;
}void CEdit_BoxDlg::OnSetfocusMultilineedit()
{
// TODO: Add your control notification handler code here
IfMultilineEditFocus=Ture;
IfSingleEditFocus=FALSE;
}void CEdit_BoxDlg::OnChangeMultilineedit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString METext;
char Count[6];
int nCharNum,nLineNum;
m_MultilineEdit.GetWindowText(METext);
nCharNum=METext.GetLength();
nLineNum=m_MultilineEdit.GetLineCount();
nCharNum-=(nLineNum-1);
itoa(nCharNum,Count,10);
m_Char.SetWindowText(Count);
itoa(nLineNum,Count,10);
m_Line.SetWindowText(Count);
}void CEdit_BoxDlg::OnCut()
{
// TODO: Add your control notification handler code here
if(IfMultilineEditFocus)
m_MultilineEdit.Cut();
else if(IfSingleEditFocus)
m_SingleEdit.Cut();
else;
}void CEdit_BoxDlg::OnCopy()
{
// TODO: Add your control notification handler code here
if(IfMultilineEditFocus)
m_MultilineEdit.Copy();
else if(IfSingleEditFocus)
m_SingleEdit.Copy();
else;
}void CEdit_BoxDlg::OnPaste()
{
// TODO: Add your control notification handler code here
if(IfMultilineEditFocus)
m_MultilineEdit.Paste();
else if(IfSingleEditFocus)
m_SingleEdit.Paste();
else;
}void CEdit_BoxDlg::OnUndo()
{
// TODO: Add your control notification handler code here
if(m_MultilineEdit.CanUndo()&&IfMultilineEditFocus)
m_MultilineEdit.Undo();
if(m_SingleEdit.CanUndo()&&IfSingleEditFocus)
m_SingleEdit.Undo();
}void CEdit_BoxDlg::OnClose()
{
// TODO: Add your control notification handler code here
OnOK();
}Compiling...
Edit_BoxDlg.cpp
e:\lyx\edit_box\edit_boxdlg.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/Edit_Box.pch': No such file or directory
执行 cl.exe 时出错.Edit_BoxDlg.obj - 1 error(s), 0 warning(s)
//#include "stdafx.h"
#include "Edit_Box.h"
#include "Edit_BoxDlg.h"#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
{
public:
CAboutDlg();// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA // ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CEdit_BoxDlg dialogCEdit_BoxDlg::CEdit_BoxDlg(CWnd* pParent /*=NULL*/)
: CDialog(CEdit_BoxDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CEdit_BoxDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}void CEdit_BoxDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEdit_BoxDlg)
DDX_Control(pDX, IDC_SINGLEEDIT, m_SingleEdit);
//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(CEdit_BoxDlg, CDialog)
//{{AFX_MSG_MAP(CEdit_BoxDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_EN_SETFOCUS(IDC_SINGLEEDIT, OnSetfocusSingleedit)
ON_EN_SETFOCUS(IDC_MULTILINEEDIT, OnSetfocusMultilineedit)
ON_EN_CHANGE(IDC_MULTILINEEDIT, OnChangeMultilineedit)
ON_BN_CLICKED(IDC_CUT, OnCut)
ON_BN_CLICKED(IDC_COPY, OnCopy)
ON_BN_CLICKED(IDC_PASTE, OnPaste)
ON_BN_CLICKED(IDC_UNDO, OnUndo)
ON_BN_CLICKED(IDC_CLOSE, OnClose)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CEdit_BoxDlg message handlersBOOL CEdit_BoxDlg::OnInitDialog()
{
CDialog::OnInitDialog(); // Add "About..." menu item to system menu. // IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
} // 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
return TRUE; // return TRUE unless you set the focus to a control
}void CEdit_BoxDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}// 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 CEdit_BoxDlg::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 CEdit_BoxDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}void CEdit_BoxDlg::OnSetfocusSingleedit()
{
// TODO: Add your control notification handler code here
IfMultilineEditFocus=FALSE;
IfSingleEditFocus=TURE;
}void CEdit_BoxDlg::OnSetfocusMultilineedit()
{
// TODO: Add your control notification handler code here
IfMultilineEditFocus=Ture;
IfSingleEditFocus=FALSE;
}void CEdit_BoxDlg::OnChangeMultilineedit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
CString METext;
char Count[6];
int nCharNum,nLineNum;
m_MultilineEdit.GetWindowText(METext);
nCharNum=METext.GetLength();
nLineNum=m_MultilineEdit.GetLineCount();
nCharNum-=(nLineNum-1);
itoa(nCharNum,Count,10);
m_Char.SetWindowText(Count);
itoa(nLineNum,Count,10);
m_Line.SetWindowText(Count);
}void CEdit_BoxDlg::OnCut()
{
// TODO: Add your control notification handler code here
if(IfMultilineEditFocus)
m_MultilineEdit.Cut();
else if(IfSingleEditFocus)
m_SingleEdit.Cut();
else;
}void CEdit_BoxDlg::OnCopy()
{
// TODO: Add your control notification handler code here
if(IfMultilineEditFocus)
m_MultilineEdit.Copy();
else if(IfSingleEditFocus)
m_SingleEdit.Copy();
else;
}void CEdit_BoxDlg::OnPaste()
{
// TODO: Add your control notification handler code here
if(IfMultilineEditFocus)
m_MultilineEdit.Paste();
else if(IfSingleEditFocus)
m_SingleEdit.Paste();
else;
}void CEdit_BoxDlg::OnUndo()
{
// TODO: Add your control notification handler code here
if(m_MultilineEdit.CanUndo()&&IfMultilineEditFocus)
m_MultilineEdit.Undo();
if(m_SingleEdit.CanUndo()&&IfSingleEditFocus)
m_SingleEdit.Undo();
}void CEdit_BoxDlg::OnClose()
{
// TODO: Add your control notification handler code here
OnOK();
}Compiling...
Edit_BoxDlg.cpp
e:\lyx\edit_box\edit_boxdlg.cpp(4) : fatal error C1083: Cannot open precompiled header file: 'Debug/Edit_Box.pch': No such file or directory
执行 cl.exe 时出错.Edit_BoxDlg.obj - 1 error(s), 0 warning(s)
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货