⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 configviewcess.cpp

📁 一个简单的个人所得税计算器,可以编辑税率表和所在地列表.
💻 CPP
字号:
// ConfigViewCess.cpp : implementation file
//

#include "stdafx.h"
#include "pitc.h"
#include "ConfigViewCess.h"
#include "ConfigDoc.h"

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

#include <afxtempl.h>
#define IDC_LISTCTRL_CESS 8001 

extern CString pathname;
/////////////////////////////////////////////////////////////////////////////
// CConfigViewCess

IMPLEMENT_DYNCREATE(CConfigViewCess, CTitleView)

CConfigViewCess::CConfigViewCess()
{
}

CConfigViewCess::~CConfigViewCess()
{
}


BEGIN_MESSAGE_MAP(CConfigViewCess, CTitleView)
	//{{AFX_MSG_MAP(CConfigViewCess)
	ON_WM_SIZE()
	ON_WM_CREATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CConfigViewCess drawing

void CConfigViewCess::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CConfigViewCess diagnostics

#ifdef _DEBUG
void CConfigViewCess::AssertValid() const
{
	CTitleView::AssertValid();
}

void CConfigViewCess::Dump(CDumpContext& dc) const
{
	CTitleView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CConfigViewCess message handlers


void CConfigViewCess::OnInitialUpdate() 
{
	CTitleView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	SetViewTitle("税率表");
	
	//AfxMessageBox("CConfigViewCess::OnInitialUpdate()");

	
}

void CConfigViewCess::OnSize(UINT nType, int cx, int cy) 
{
	CTitleView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if(m_wndListCtrlCess)
	{
		m_wndListCtrlCess.MoveWindow(CRect(0,22,cx,cy),TRUE);
	}
}

int CConfigViewCess::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTitleView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	if(!m_wndListCtrlCess.Create(WS_VISIBLE|WS_CHILD|LVS_REPORT|LVS_SINGLESEL ,CRect(0,0,0,0),this,IDC_LISTCTRL_CESS))
	{
		AfxMessageBox("创建List控件时出错!");
		return -1;
	}

	return 0;
}

void CConfigViewCess::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	CConfigDoc *pDoc;
	pDoc=(CConfigDoc*)(GetDocument());

	m_arrFrom.Copy(pDoc->m_arrFrom);
	m_arrTo.Copy(pDoc->m_arrTo);
	m_arrCess.Copy(pDoc->m_arrCess);
	m_arrSub.Copy(pDoc->m_arrSub);
    CString str;
	int nitem,count;
	count=m_arrFrom.GetSize();
	m_wndListCtrlCess.DeleteAllItems();
	for(int i=0;i<count;i++)
	{
		str.Format("%d",i+1);
		nitem=m_wndListCtrlCess.InsertItem(i,str);
		str.Format("%.2f",m_arrFrom.GetAt(i));
		m_wndListCtrlCess.SetItemText(nitem,1,str);
        if(i<count-1)
		{
		    str.Format("%.2f",m_arrTo.GetAt(i));
		    m_wndListCtrlCess.SetItemText(nitem,2,str);
		}
		else
		{
			m_wndListCtrlCess.SetItemText(nitem,2,"∞");
		}
		str.Format("%.2f",m_arrCess.GetAt(i));
		m_wndListCtrlCess.SetItemText(nitem,3,str);
		str.Format("%.2f",m_arrSub.GetAt(i));
		m_wndListCtrlCess.SetItemText(nitem,4,str);
		//AfxMessageBox(str);
	}

	
	///更新ToolTipCtrl的显示
	str=pDoc->GetPathName();
	//AfxMessageBox(str);
	if(str=="")
		str="未命名配置文件";
	//else
		//str=pathname;
    m_wndListCtrlCess.m_cToolTipCtrl.UpdateTipText(str,&m_wndListCtrlCess);
	
}

BOOL CConfigViewCess::ExamCess()
{
	if(!m_wndListCtrlCess.ExamCess())
	{
		return FALSE;
	}
	else
	{
		int count;
		double from,to,cess,sub;
		count=m_wndListCtrlCess.GetItemCount();
		m_arrFrom.RemoveAll();
		m_arrTo.RemoveAll();
		m_arrCess.RemoveAll();
		m_arrSub.RemoveAll();
	
		for(int i=0;i<count;i++)
		{
			from=atof(m_wndListCtrlCess.GetItemText(i,1));
			m_arrFrom.Add(from);
			if(i<count-1)
			{
			    to=atof(m_wndListCtrlCess.GetItemText(i,2));
			    m_arrTo.Add(to);
			}
			cess=atof(m_wndListCtrlCess.GetItemText(i,3));
			m_arrCess.Add(cess);
			sub=atof(m_wndListCtrlCess.GetItemText(i,4));
			m_arrSub.Add(sub);
		}
		CConfigDoc *pDoc;
		pDoc=(CConfigDoc *)(GetDocument());
		pDoc->m_arrFrom.Copy(m_arrFrom);
		pDoc->m_arrTo.Copy(m_arrTo);
		pDoc->m_arrCess.Copy(m_arrCess);
		pDoc->m_arrSub.Copy(m_arrSub);
		return TRUE;
	}

}

⌨️ 快捷键说明

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