TaxExpert.cpp
Upload User: szcysw
Upload Date: 2013-03-11
Package Size: 6752k
Code Size: 7k
Category:

GUI Develop

Development Platform:

Visual C++

  1. // TaxExpert.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "TaxExpert.h"
  5. #include "MainFrm.h"
  6. #include "TaxExpertDoc.h"
  7. #include "TaxExpertView.h"
  8. #include "Splash.h"
  9. #ifdef _DEBUG
  10. #define new DEBUG_NEW
  11. #undef THIS_FILE
  12. static char THIS_FILE[] = __FILE__;
  13. #endif
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CTaxExpertApp
  16. BEGIN_MESSAGE_MAP(CTaxExpertApp, CWinApp)
  17. //{{AFX_MSG_MAP(CTaxExpertApp)
  18. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  19. // NOTE - the ClassWizard will add and remove mapping macros here.
  20. //    DO NOT EDIT what you see in these blocks of generated code!
  21. //}}AFX_MSG_MAP
  22. // Standard file based document commands
  23. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  24. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  25. // Standard print setup command
  26. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  27. END_MESSAGE_MAP()
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CTaxExpertApp construction
  30. CTaxExpertApp::CTaxExpertApp()
  31. {
  32. // TODO: add construction code here,
  33. // Place all significant initialization in InitInstance
  34. }
  35. /////////////////////////////////////////////////////////////////////////////
  36. // The one and only CTaxExpertApp object
  37. CTaxExpertApp theApp;
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CTaxExpertApp initialization
  40. /*
  41. InitInstance:程序初始化函数
  42. 1、检查软件运行环境
  43. 2、限制程序运行实例
  44. 3、启用开始画面
  45. */
  46. BOOL CTaxExpertApp::InitInstance()
  47. {
  48. //进行数据库访问环境的测试,进行错误捕获
  49. try{
  50. AfxDaoInit();
  51. }
  52. catch( CDaoException*e )
  53. {
  54. CString error;
  55. error.Format("在当前的软件环境配置不能够运行本程序! rnrn");
  56. error+="导致该错误的原因可能是以下几方面:rnrn";
  57. error+="1、未安装DAO数据组件,请安装"安装MS-Jet 数据引擎"!rnt
  58. (提示:可以在www.microsoft.com下载Mdac_typ.exe、Ddcom95.exe等相关数据库组件)rn";
  59. error+="2、如果已经安装了数据组件,请在系统中查找dao3?0.dll,
  60. 并使用下面的方法将之注册:rn";
  61. error+="tregsvr32.exe /i X:XXXdao3?0.dllrnrn";
  62. error+="如果不能解决此问题,你也可以和zhoumingyang@163.net
  63. 联系以解决此问题。";
  64. MessageBox(NULL,error,"抱歉",MB_ICONSTOP|MB_OK );
  65. e ->Delete();
  66. return 0;
  67. }
  68. //确保只有一个本程序只能有一个实例在运行
  69. HWND hWndPrevious = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
  70. //从桌面窗口开始检查,查看在内存中的窗口有没有“税务师”窗口
  71. while (::IsWindow(hWndPrevious))
  72. {
  73. if (::GetProp(hWndPrevious, "660E72B2-6BF7-4897-8EF2-9C33FBC49564"))
  74. {
  75. AfxMessageBox("该程序已经有实例在运行!n请使用任务管理器切换到该程序");
  76. return 0;
  77. }
  78. hWndPrevious = ::GetWindow(hWndPrevious,GW_HWNDNEXT);
  79. };
  80. // CG: The following block was added by the Splash Screen component. { CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash); }
  81. AfxEnableControlContainer();
  82. #ifdef _AFXDLL
  83. Enable3dControls();
  84. #else
  85. Enable3dControlsStatic();
  86. #endif
  87. SetRegistryKey(_T("税务师"));
  88. LoadStdProfileSettings();
  89. CSingleDocTemplate* pDocTemplate;
  90. pDocTemplate = new CSingleDocTemplate(
  91. IDR_MAINFRAME,
  92. RUNTIME_CLASS(CTaxExpertDoc),
  93. RUNTIME_CLASS(CMainFrame),     
  94. RUNTIME_CLASS(CTaxExpertView));
  95. AddDocTemplate(pDocTemplate);
  96. CCommandLineInfo cmdInfo;
  97. ParseCommandLine(cmdInfo);
  98. if (!ProcessShellCommand(cmdInfo))
  99. return FALSE;
  100. m_pMainWnd->ShowWindow(SW_SHOW);
  101. m_pMainWnd->UpdateWindow();
  102. return TRUE;
  103. }
  104. /////////////////////////////////////////////////////////////////////////////
  105. // CAboutDlg dialog used for App About
  106. class CAboutDlg : public CDialog
  107. {
  108. public:
  109. void UpdateFont();
  110. CAboutDlg();
  111. // Dialog Data
  112. //{{AFX_DATA(CAboutDlg)
  113. enum { IDD = IDD_ABOUTBOX };
  114. CCJHyperLink m_staticEmail;
  115. CCJHyperLink m_staticAddress;
  116. CStatic      m_staticDisclaimer,m_static;
  117. CString m_editDisclaimer;
  118. CAnimateCtrl avi;
  119. //}}AFX_DATA
  120. CFont m_Font;
  121. // ClassWizard generated virtual function overrides
  122. //{{AFX_VIRTUAL(CAboutDlg)
  123. protected:
  124. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  125. //}}AFX_VIRTUAL
  126. // Implementation
  127. protected:
  128. //{{AFX_MSG(CAboutDlg)
  129. virtual BOOL OnInitDialog();
  130. afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  131. //}}AFX_MSG
  132. DECLARE_MESSAGE_MAP()
  133. };
  134. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  135. {
  136. //{{AFX_DATA_INIT(CAboutDlg)
  137. m_editDisclaimer = _T("");
  138. //}}AFX_DATA_INIT
  139. m_editDisclaimer.LoadString(IDS_DISCLAIMER);
  140. UpdateFont();
  141. }
  142.  int CAboutDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
  143.  {
  144. if (CDialog::OnCreate(lpCreateStruct) == -1)
  145. return -1;
  146. avi.Create(WS_CHILD|WS_VISIBLE|ACS_TRANSPARENT   |ACS_CENTER   |
  147. WS_TABSTOP|CBS_AUTOHSCROLL,CRect(0,0,200,200),this, 888888888888);
  148. return 0;
  149.  }
  150. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  151. {
  152. CDialog::DoDataExchange(pDX);
  153. //{{AFX_DATA_MAP(CAboutDlg)
  154. DDX_Control(pDX, IDC_STATIC_MAILME, m_staticEmail);
  155. DDX_Control(pDX, IDC_STATIC_DISCLAIMER, m_staticDisclaimer);
  156. DDX_Control(pDX, IDC_STATIC_ADDRESS, m_staticAddress);
  157. DDX_Text(pDX, IDC_EDIT_DISCLAIMER, m_editDisclaimer);
  158. DDX_Control(pDX, IDC_STATIC1, m_static);
  159. //}}AFX_DATA_MAP
  160. }
  161. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  162. //{{AFX_MSG_MAP(CAboutDlg)
  163. ON_WM_CREATE()
  164. //}}AFX_MSG_MAP
  165. END_MESSAGE_MAP()
  166. void CAboutDlg::UpdateFont()
  167. {
  168. NONCLIENTMETRICS ncm;
  169. memset(&ncm, 0, sizeof(NONCLIENTMETRICS));
  170. ncm.cbSize = sizeof(NONCLIENTMETRICS);
  171. VERIFY(::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,
  172. sizeof(NONCLIENTMETRICS), &ncm, 0));
  173. ncm.lfMessageFont.lfWeight = 700;
  174. m_Font.CreateFontIndirect(&ncm.lfMessageFont);
  175. }
  176. BOOL CAboutDlg::OnInitDialog() 
  177. {
  178. CDialog::OnInitDialog();
  179. // set the hyperlinks and static font.
  180. m_staticEmail.SetURL(_T("mailto:zhoumingyang@163.net?subject=税务师软件"));
  181. m_staticAddress.SetURL(_T("http://nationaltax.home.chinaren.com"));
  182. //m_staticDisclaimer.SetFont(&m_Font);
  183. CString k;
  184. this->m_staticDisclaimer.SetWindowText("尊敬的朋友:");
  185. m_editDisclaimer.LoadString(IDS_STRING1);
  186.  this->m_static.SetWindowText("联系方式");
  187. //m_staticDisclaimer=k;
  188. this->RedrawWindow();
  189.  avi.Open(IDR_AVI1);
  190. avi.Play(0,-1,-1);
  191. return TRUE;  // return TRUE unless you set the focus to a control
  192.               // EXCEPTION: OCX Property Pages should return FALSE
  193. }
  194. /////////////////////////////////////////////////////////////////////////////
  195. // App command to run the dialog
  196. void CTaxExpertApp::OnAppAbout()
  197. {
  198. CAboutDlg aboutDlg;
  199. aboutDlg.DoModal();
  200. }
  201. /////////////////////////////////////////////////////////////////////////////
  202. // CTaxExpertApp commands
  203. void CTaxExpertApp::UpdateFont(CFont& font, LONG lfWeight)
  204. {
  205. font.DeleteObject();
  206. NONCLIENTMETRICS info;
  207. info.cbSize = sizeof(info);
  208. SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(info), &info, 0);
  209. info.lfMessageFont.lfWeight = lfWeight;
  210. VERIFY(font.CreateFontIndirect(&info.lfMenuFont));
  211. }
  212. BOOL CTaxExpertApp::PreTranslateMessage(MSG* pMsg)
  213. {
  214. // CG: The following lines were added by the Splash Screen component. if (CSplashWnd::PreTranslateAppMessage(pMsg)) return TRUE; return CWinApp::PreTranslateMessage(pMsg);
  215. }