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

📄 configviewarea.cpp

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

#include "stdafx.h"
#include "pitc.h"
#include "ConfigViewArea.h"
#include "MyListCtrl.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_AREA 8002 
/////////////////////////////////////////////////////////////////////////////
// CConfigViewArea

IMPLEMENT_DYNCREATE(CConfigViewArea, CTitleView)

CConfigViewArea::CConfigViewArea()
{
}

CConfigViewArea::~CConfigViewArea()
{
}


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

/////////////////////////////////////////////////////////////////////////////
// CConfigViewArea drawing

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

/////////////////////////////////////////////////////////////////////////////
// CConfigViewArea diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CConfigViewArea message handlers

void CConfigViewArea::OnInitialUpdate() 
{
	CTitleView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	SetViewTitle("所在地列表");

}

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

void CConfigViewArea::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_arrArea.Copy(pDoc->m_arrArea);
	m_arrStart.Copy(pDoc->m_arrStart);
	
	int nitem;
	CString str;
	//m_wndListCtrlArea.SetRedraw(FALSE);
	m_wndListCtrlArea.DeleteAllItems();
	for(int i=0;i<m_arrArea.GetSize();i++)
	{
		nitem=m_wndListCtrlArea.InsertItem(i,m_arrArea.GetAt(i));
		str.Format("%.2f",m_arrStart.GetAt(i));
		if(m_wndListCtrlArea.SetItemText(nitem,1,str)==0)
		{
			str.Format("nitem=%d",nitem);
            //AfxMessageBox(str);
		}
	}
    //m_wndListCtrlArea.SetRedraw(TRUE);
	
}

BOOL CConfigViewArea::ExamArea()
{
	if(!m_wndListCtrlArea.ExamArea())
	{
		return FALSE;
	}
	else
	{
		int count;
		double start;
		count=m_wndListCtrlArea.GetItemCount();
		m_arrArea.RemoveAll();
		m_arrStart.RemoveAll();
		for(int i=0;i<count;i++)
		{
			m_arrArea.Add(m_wndListCtrlArea.GetItemText(i,0));
			start=atof(m_wndListCtrlArea.GetItemText(i,1));
			m_arrStart.Add(start);
		}
		CConfigDoc *pDoc;
		pDoc=(CConfigDoc *)(GetDocument());
		pDoc->m_arrArea.Copy(m_arrArea);
		pDoc->m_arrStart.Copy(m_arrStart);
		//for(int j=0;j<pDoc->m_arrArea.GetSize();j++)
			//AfxMessageBox(pDoc->m_arrArea.GetAt(j));
		return TRUE;
	}

}

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

⌨️ 快捷键说明

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