GraphSoft.cpp
上传用户:lj3531212
上传日期:2007-06-18
资源大小:346k
文件大小:7k
源码类别:

绘图程序

开发平台:

Visual C++

  1. // GraphSoft.cpp : Defines the class behaviors for the application.
  2. //
  3. #include "stdafx.h"
  4. #include "GraphSoft.h"
  5. #include <atlbase.h>
  6. #include "MainFrm.h"
  7. #include "GraphSoftDoc.h"
  8. #include "GraphSoftView.h"
  9. #include "HyperLink.h"
  10. #include "SplashWindow.h"
  11. #include "UND_Create.h"
  12. #include "UND_Move.h"
  13. #include "UND_Rotate.h"
  14. #include "UND_Magnify.h"
  15. #include "UND_ShowPoints.h"
  16. #include "UND_TopToBtm.h"
  17. #include "UND_LeftToRight.h"
  18. #include "UND_Delete.h"
  19. #include "UND_Copy.h"
  20. #include "UND_Edit.h"
  21. #include "UND_Property.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. /////////////////////////////////////////////////////////////////////////////
  28. // CGraphSoftApp
  29. BEGIN_MESSAGE_MAP(CGraphSoftApp, CWinApp)
  30. //{{AFX_MSG_MAP(CGraphSoftApp)
  31. ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
  32. ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
  33. //}}AFX_MSG_MAP
  34. // Standard file based document commands
  35. ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
  36. ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
  37. // Standard print setup command
  38. ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
  39. END_MESSAGE_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // CGraphSoftApp construction
  42. CGraphSoftApp::CGraphSoftApp()
  43. {
  44. // TODO: add construction code here,
  45. // Place all significant initialization in InitInstance
  46. }
  47. /////////////////////////////////////////////////////////////////////////////
  48. // The one and only CGraphSoftApp object
  49. CGraphSoftApp theApp;
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CGraphSoftApp initialization
  52. BOOL CGraphSoftApp::InitInstance()
  53. {
  54. AfxEnableControlContainer();
  55. // Standard initialization
  56. // If you are not using these features and wish to reduce the size
  57. //  of your final executable, you should remove from the following
  58. //  the specific initialization routines you do not need.
  59. #ifdef _AFXDLL
  60. Enable3dControls(); // Call this when using MFC in a shared DLL
  61. #else
  62. Enable3dControlsStatic(); // Call this when linking to MFC statically
  63. #endif
  64. // Change the registry key under which our settings are stored.
  65. // TODO: You should modify this string to be something appropriate
  66. // such as the name of your company or organization.
  67. SetRegistryKey(_T("Local AppWizard-Generated Applications"));
  68. LoadStdProfileSettings();  // Load standard INI file options (including MRU)
  69. //the control of test deition
  70. CRegKey hKey;
  71. if(hKey.Create(HKEY_LOCAL_MACHINE,"SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION") == ERROR_SUCCESS)
  72. {
  73. BOOL bWrite = TRUE;
  74. TCHAR scTemp[_MAX_PATH];
  75. DWORD dwCount = sizeof(scTemp);
  76. if(hKey.QueryValue(scTemp,"SystemVctmp",&dwCount) == ERROR_SUCCESS)
  77. {
  78. if(atoi(scTemp)>25){
  79. // MessageBox(NULL,"GraphSoft2 试用班版到期! n购买序列号联系Xiagl@nanjing_fnst.com","提示",MB_OK);
  80. // abort();
  81. }else{
  82. int nTime = atoi(scTemp);
  83. nTime = nTime + 1;
  84. CString str;
  85. str.Format("%d",nTime);
  86. hKey.SetValue(str,"SystemVctmp");
  87. bWrite = FALSE;
  88. }
  89. }
  90. if(bWrite)
  91. hKey.SetValue("1","SystemVctmp");
  92. hKey.Close();
  93. }
  94. // Register the application's document templates.  Document templates
  95. //  serve as the connection between documents, frame windows and views.
  96. CSplashWindow *m_pSplashWindow = new CSplashWindow;
  97. m_pSplashWindow->CreateSplash();
  98. m_pSplashWindow->CenterWindow();
  99. m_pSplashWindow->ShowWindow(SW_SHOW);
  100. m_pSplashWindow->UpdateWindow();
  101. Sleep(2000); //Delay 3 Seconds
  102. m_pSplashWindow->DestroyWindow(); //Destroy Window
  103. delete m_pSplashWindow;
  104. CSingleDocTemplate* pDocTemplate;
  105. pDocTemplate = new CSingleDocTemplate(
  106. IDR_MAINFRAME,
  107. RUNTIME_CLASS(CGraphSoftDoc),
  108. RUNTIME_CLASS(CMainFrame),       // main SDI frame window
  109. RUNTIME_CLASS(CGraphSoftView));
  110. AddDocTemplate(pDocTemplate);
  111. // Parse command line for standard shell commands, DDE, file open
  112. CCommandLineInfo cmdInfo;
  113. ParseCommandLine(cmdInfo);
  114. // Dispatch commands specified on the command line
  115. if (!ProcessShellCommand(cmdInfo))
  116. return FALSE;
  117. // The one and only window has been initialized, so show and update it.
  118. m_pMainWnd->ShowWindow(SW_SHOW);
  119. m_pMainWnd->UpdateWindow();
  120.  
  121. return TRUE;
  122. }
  123. /////////////////////////////////////////////////////////////////////////////
  124. // CAboutDlg dialog used for App About
  125. class CAboutDlg : public CDialog
  126. {
  127. public:
  128. CAboutDlg();
  129. // Dialog Data
  130. //{{AFX_DATA(CAboutDlg)
  131. enum { IDD = IDD_ABOUTBOX };
  132. CHyperLink m_ctrlMail;
  133. //}}AFX_DATA
  134. // ClassWizard generated virtual function overrides
  135. //{{AFX_VIRTUAL(CAboutDlg)
  136. protected:
  137. virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  138. //}}AFX_VIRTUAL
  139. // Implementation
  140. protected:
  141. //{{AFX_MSG(CAboutDlg)
  142. virtual BOOL OnInitDialog();
  143. //}}AFX_MSG
  144. DECLARE_MESSAGE_MAP()
  145. };
  146. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  147. {
  148. //{{AFX_DATA_INIT(CAboutDlg)
  149. //}}AFX_DATA_INIT
  150. }
  151. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  152. {
  153. CDialog::DoDataExchange(pDX);
  154. //{{AFX_DATA_MAP(CAboutDlg)
  155. DDX_Control(pDX, IDC_MAIL, m_ctrlMail);
  156. //}}AFX_DATA_MAP
  157. }
  158. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  159. //{{AFX_MSG_MAP(CAboutDlg)
  160. //}}AFX_MSG_MAP
  161. END_MESSAGE_MAP()
  162. BOOL CAboutDlg::OnInitDialog() 
  163. {
  164. CDialog::OnInitDialog();
  165. // TODO: Add extra initialization here
  166. m_ctrlMail.SetURL("mailto:325003xgl@sina.com");
  167. return TRUE;  // return TRUE unless you set the focus to a control
  168. // EXCEPTION: OCX Property Pages should return FALSE
  169. }
  170. // App command to run the dialog
  171. void CGraphSoftApp::OnAppAbout()
  172. {
  173. CAboutDlg aboutDlg;
  174. aboutDlg.DoModal();
  175. }
  176. /////////////////////////////////////////////////////////////////////////////
  177. // CGraphSoftApp message handlers
  178. void CGraphSoftApp::OnFileOpen() 
  179. {
  180. // TODO: Add your command handler code here
  181. CWinApp::OnFileOpen();
  182. }
  183. CDocument* CGraphSoftApp::OpenDocumentFile(LPCTSTR lpszFileName) 
  184. {
  185. // TODO: Add your specialized code here and/or call the base class
  186. /* CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView();
  187. CGraphSoftDoc* pDoc=pView->GetDocument();
  188. CString strTitle,strDetail;
  189. strTitle.LoadString(IDS_FILE_SAVE_TITLE);
  190. strDetail.LoadString(IDS_FILE_SAVE_STRING);
  191. if(pDoc->m_pCore->IsAbleToUndo()||pDoc->m_pCore->IsAbleToRedo())
  192. {
  193. int nRtn=GetMainWnd()->MessageBox(strDetail,strTitle,MB_YESNOCANCEL|MB_APPLMODAL);
  194. if(nRtn==IDYES){
  195. SendMessage(AfxGetApp()->GetMainWnd()->GetSafeHwnd(),WM_COMMAND,WPARAM(ID_FILE_SAVE),NULL);
  196. }else if(nRtn==IDCANCEL){
  197. return CWinApp::OpenDocumentFile(lpszFileName);;
  198. }
  199. }
  200. pDoc->m_nCurrentShapeType=_shape_none;
  201. if(pView!=NULL)
  202. {
  203. pView->m_graph_op=_graph_noneOp;
  204. pView->m_bDrawFlag = FALSE;
  205. }
  206. if(m_strFileName.Compare(lpszFileName)!=0) {
  207. delete pDoc->m_pCore;//删除撤消/恢复对象指针,以及删除图形对象指针
  208. pDoc->m_shapeList.RemoveAll();
  209. pDoc->m_pCore=new CCore(pDoc,pView);    
  210. }
  211. */
  212. CDocument* pDocRlt=CWinApp::OpenDocumentFile(lpszFileName);//如果同名,则不再重新序列化
  213. /* if(m_strFileName.Compare(lpszFileName)!=0) {
  214. CUND_Base* pUNDBase;
  215. POSITION pos=pDoc->m_shapeList.GetHeadPosition();
  216. while (pos!=NULL) {
  217. CShape* pShape=pDoc->m_shapeList.GetNext(pos);
  218. pUNDBase = new CUND_Create(pShape);
  219. pDoc->m_pCore->AddUndoItem(pUNDBase);
  220. }
  221. ((CMainFrame*)this->GetMainWnd())->GetActiveView()->Invalidate(TRUE); 
  222. }
  223. m_strFileName = lpszFileName;
  224. */
  225. return pDocRlt;
  226. }