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

📄 pitc.cpp

📁 一个简单的个人所得税计算器,可以编辑税率表和所在地列表.
💻 CPP
字号:
// PITC.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "PITC.h"

#include "MainFrm.h"
#include "PITCDoc.h"
#include "PITCView.h"
#include "ConfigDoc.h"
#include "ComputView.h"
#include "ConfigViewCess.h"
#include "shlwapi.h"//用于判断文件或目录是否存在
#pragma comment(lib,"shlwapi.lib")
#include "math.h"
#include "TestDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPITCApp

BEGIN_MESSAGE_MAP(CPITCApp, CWinApp)
	//{{AFX_MSG_MAP(CPITCApp)
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
	ON_COMMAND(ID_HELP, OnHelp)
	ON_COMMAND(ID_TEST, OnTest)
	//}}AFX_MSG_MAP
	// Standard file based document commands
	ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
	ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
	// Standard print setup command
	ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPITCApp construction

CPITCApp::CPITCApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CPITCApp object

CPITCApp theApp;
CString cessFlag;
CString areaFlag;
BOOL modified;
CString pathname;
CString filename;
//int curArea;
//int curCess;
/////////////////////////////////////////////////////////////////////////////
// CPITCApp initialization

BOOL CPITCApp::InitInstance()
{
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the registry key under which our settings are stored.
	// TODO: You should modify this string to be something appropriate
	// such as the name of your company or organization.
	SetRegistryKey(_T("Local AppWizard-Generated Applications"));

	LoadStdProfileSettings();  // Load standard INI file options (including MRU)

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

	CSingleDocTemplate* pDocTemplate;
	pDocTemplate = new CSingleDocTemplate(
		IDR_MAINFRAME,
		RUNTIME_CLASS(CPITCDoc),
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
		RUNTIME_CLASS(CPITCView));
	AddDocTemplate(pDocTemplate);

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	ParseCommandLine(cmdInfo);

	//if(cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew)
		//cmdInfo.m_nShellCommand=CCommandLineInfo::FileNothing;


	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;
//WS_MINIMIZEBOX   
//BOOL ModifyStyle( DWORD dwRemove, DWORD dwAdd, UINT nFlags = 0 );
/*
	VERIFY( 1 == InitSkinMagicLib( AfxGetInstanceHandle(), "Demo" ,NULL,NULL ) );//初始化类库
	VERIFY( 1 == LoadSkinFromResource( AfxGetInstanceHandle()  , "DEVIOR" ,"SKINMAGIC") );//从资源中加载皮肤 
	
	VERIFY( 1 == SetWindowSkin( m_pMainWnd->m_hWnd , "MainFrame" ));
	VERIFY( 1 == SetDialogSkin( "Dialog" ) );
	((CMainFrame*)m_pMainWnd)->m_bSkinned = TRUE;
	((CMainFrame*)m_pMainWnd)->m_nIndex = 1;
*/
    //m_pMainWnd->ModifyStyle( WS_MINIMIZEBOX|WS_MAXIMIZEBOX, 0,  1 );
	////
	//pDocTemplate->m_hMenuShared=pMainFrame->NewDefaultMenu();
	((CMainFrame*)m_pMainWnd)->m_hMenuDefault=((CMainFrame*)m_pMainWnd)->NewDefaultMenu();
	((CMainFrame*)m_pMainWnd)->OnUpdateFrameMenu(((CMainFrame*)m_pMainWnd)->m_hMenuDefault);
	////
	// The one and only window has been initialized, so show and update it.
	//CString str;
	//m_pMainWnd->SetWindowText(str);
	m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);//最大化显示
	m_pMainWnd->UpdateWindow();

	CMainFrame *pMain;
	pMain=(CMainFrame*)m_pMainWnd;
	////////////////
	CString temp,path;
	FilePath configfilepath;
	configfilepath=((CPITCApp*)AfxGetApp())->GetExeFilePath();
    //AfxMessageBox(configfilepath.driver+configfilepath.dir+"config.ini");
	CString t;
	t.Format("%s%s",configfilepath.driver+configfilepath.dir,"\cess2006.pit");
    ::GetPrivateProfileString("Load","PITFileName",_T(t),
		temp.GetBuffer(255),255,configfilepath.driver+configfilepath.dir+"config.ini");
	path.Format("%s",temp);
	if(pMain->m_pConfigDoc->OnOpenDocument(path))
	{
		::WritePrivateProfileString("Load","PITFileName",path,configfilepath.driver+configfilepath.dir+"config.ini");
        pMain->m_pConfigViewCess->m_wndListCtrlCess.m_cToolTipCtrl.UpdateTipText(path,&(pMain->m_pConfigViewCess->m_wndListCtrlCess));
	    pathname=path;

		filename=pMain->GetNameFromPath(path);
	    CString title;
	    title.LoadString(AFX_IDS_APP_TITLE);
	    title=title+"-"+filename;
	    pMain->SetWindowText(title);
	}
	else
	{
		pathname="";
		//AfxMessageBox("未加载配置文件!");
		
	}
	modified=FALSE;
	////////////////////////

	return TRUE;
}


/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class 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)
	virtual BOOL OnInitDialog();
	//}}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)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

// App command to run the dialog
void CPITCApp::OnAppAbout()
{
	CAboutDlg aboutDlg;
	aboutDlg.DoModal();
}

/////////////////////////////////////////////////////////////////////////////
// CPITCApp message handlers


BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString str;
	str.LoadString(AFX_IDS_APP_TITLE);
	GetDlgItem(IDC_STATIC_TITLE)->SetWindowText(str);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPITCApp::OnHelp() 
{
	// TODO: Add your command handler code here
	FilePath configfilepath;
	configfilepath=((CPITCApp*)AfxGetApp())->GetExeFilePath();
	CString temp,filename;
	::GetPrivateProfileString("Load","PITCHelpFileName",_T("d:\\PITC\\PITChelp.chm"),
		          temp.GetBuffer(255),255,configfilepath.driver+configfilepath.dir+"config.ini");
	filename.Format("%s",temp);

	CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
					"帮助文件(*.chm)|*.chm||" );
	while(!PathFileExists(filename))
	{
		if(dlg.DoModal()==IDOK)
		{
		    filename=dlg.GetPathName();
			goto lab_open;
		}
		else
		{
			AfxMessageBox("没有找到帮助文件!");
            return;
		}
	}
lab_open:      
	//::HtmlHelp(NULL, configfilepath.driver+configfilepath.dir+"TMOhelp.chm", HH_DISPLAY_TOPIC, 0);
    ::HtmlHelp(NULL, filename, HH_DISPLAY_TOPIC, 0);
    ::WritePrivateProfileString("Load","PITCHelpFileName",filename,configfilepath.driver+configfilepath.dir+"config.ini");
	

}


FilePath CPITCApp::GetExeFilePath()
{
	TCHAR szFileName[MAX_PATH];
    TCHAR szDriver[MAX_PATH];
    TCHAR szDir[MAX_PATH];

    GetModuleFileName(NULL,szFileName,MAX_PATH);
    _tsplitpath(szFileName,szDriver,szDir,NULL,NULL);

	FilePath ExefilePath;
	ExefilePath.driver=szDriver;
	ExefilePath.dir=szDir;
    ExefilePath.filename=szFileName;

	return ExefilePath;


}


void CPITCApp::OnTest() 
{
	// TODO: Add your command handler code here
	double a,b;
	a=319.455;
	//b=a*100.0;
	//a=b/100.0;
	CString str;
	
	//a=Sswr(319.454,3);
	
	//int c;
	//c=a*100;
	//a=c/100.0;

	//a=dd2(a);

	a=a+0.005;

	int N = 100;
    double f =319.455;

	a=45345345;
	 b=Sswr( a, 2);

    str.Format("a=%f\nSswr(a,2)=%f",a,b);
	//AfxMessageBox(str);

	CTestDlg dlg;
	dlg.DoModal();
}

double CPITCApp::Sswr(double raw,int n)//将raw四舍五入取n位小数
{
	int N=1;
	double f;
	_int64 m;

	f=raw;
	int i;
	for( i=0;i<n;i++)
		N=N*10;

	
    f *= N;
	m=(_int64)(f + 0.5);
    f = (double)(m);
	f/=N;

	return f;
    
}

double CPITCApp::Ssws(double raw,int n)//将raw截取n位小数
{
	int N=1;
	double f;
	f=raw;
	for(int i=0;i<n;i++)
		N=N*10;
    f *= N;
    f = (double)((_int64)f);
    f /= N;

	return f;
}



int CPITCApp::ReadMaxInt(CString str, int *a)
{
	int len,i;
	len=strlen(str);
	for(i=len;i>=1;i--)
	{
	}
return len;

}

⌨️ 快捷键说明

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