countdlg.cpp

来自「这是书上的代码」· C++ 代码 · 共 116 行

CPP
116
字号
// CountDlg.cpp : implementation file
////written by  熊英


#include "stdafx.h"
#include "XYCALC.h"
#include "CountDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCountDlg dialog


CCountDlg::CCountDlg(CKXdlg* pParent /*=NULL*/)
	: CDialog(CCountDlg::IDD, pParent),m_pParent(pParent)
{
	//{{AFX_DATA_INIT(CCountDlg)
	m_num = 0;
	//}}AFX_DATA_INIT
	if(Create(CCountDlg::IDD,pParent))
	{ShowWindow(SW_SHOW);}
}


void CCountDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCountDlg)
	DDX_Control(pDX, IDC_LIST1, m_list);
	DDX_Text(pDX, IDC_EDIT1, m_num);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCountDlg, CDialog)
	//{{AFX_MSG_MAP(CCountDlg)
	ON_BN_CLICKED(IDC_return, Onreturn)
	ON_BN_CLICKED(IDC_INSERT, OnInsert)
	ON_BN_CLICKED(IDC_CLEAR, OnClear)
	ON_BN_CLICKED(IDC_CLEARALL, OnClearall)
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCountDlg message handlers

void CCountDlg::OnOK() 
{
	// TODO: Add extra validation here
	ShowWindow(SW_HIDE);
//	CDialog::OnOK();
}



void CCountDlg::Onreturn() 
{
	// TODO: Add your control notification handler code here
m_pParent->BringWindowToTop( );	
}

void CCountDlg::OnInsert() 
{
	// TODO: Add your control notification handler code here
int nIndex = m_list.GetCurSel();
if(nIndex+1)          //not null
{  m_pParent->m_operand=num[nIndex];
  m_pParent->m_accum=num[nIndex];
}
m_pParent->updisp( );
//m_list.GetText(nIndex,m_pParent->m_str);
//m_pParent->UpdateData(FALSE);


}

void CCountDlg::OnClear() 
{
	// TODO: Add your control notification handler code here
int nIndex = m_list.GetCurSel();
	m_list.DeleteString(nIndex);
if(m_num)	m_num-=1;
int i;
for(i=nIndex+1;i<=m_num;i++)
  num[i-1]=num[i];
UpdateData(FALSE);
m_list.SetCurSel(m_num-1);
}	



void CCountDlg::OnClearall() 
{
	// TODO: Add your control notification handler code here
m_list.ResetContent( );
m_num=0;	
UpdateData(FALSE);
}
extern CCountDlg* g_pmodless;

void CCountDlg::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	
	CDialog::OnClose();
	delete this;
    g_pmodless=NULL;
}

⌨️ 快捷键说明

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