www.pudn.com > 44757463.rar > GraphSoft.cpp


// GraphSoft.cpp : Defines the class behaviors for the application. 
// 
 
#include "stdafx.h" 
#include "GraphSoft.h" 
#include  
 
#include "MainFrm.h" 
#include "GraphSoftDoc.h" 
#include "GraphSoftView.h" 
#include "HyperLink.h" 
#include "SplashWindow.h" 
 
 
#include "UND_Create.h" 
#include "UND_Move.h" 
#include "UND_Rotate.h" 
#include "UND_Magnify.h" 
#include "UND_ShowPoints.h" 
#include "UND_TopToBtm.h" 
#include "UND_LeftToRight.h" 
#include "UND_Delete.h" 
#include "UND_Copy.h" 
#include "UND_Edit.h" 
#include "UND_Property.h" 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CGraphSoftApp 
 
BEGIN_MESSAGE_MAP(CGraphSoftApp, CWinApp) 
	//{{AFX_MSG_MAP(CGraphSoftApp) 
	ON_COMMAND(ID_APP_ABOUT, OnAppAbout) 
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen) 
	//}}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() 
 
///////////////////////////////////////////////////////////////////////////// 
// CGraphSoftApp construction 
 
CGraphSoftApp::CGraphSoftApp() 
{ 
	// TODO: add construction code here, 
	// Place all significant initialization in InitInstance 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// The one and only CGraphSoftApp object 
 
CGraphSoftApp theApp; 
 
///////////////////////////////////////////////////////////////////////////// 
// CGraphSoftApp initialization 
 
BOOL CGraphSoftApp::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) 
 
 
	//the control of test deition 
	CRegKey hKey; 
	if(hKey.Create(HKEY_LOCAL_MACHINE,"SOFTWARE\\MICROSOFT\\WINDOWS\\CURRENTVERSION") == ERROR_SUCCESS) 
	{ 
		BOOL bWrite = TRUE;			 
		TCHAR scTemp[_MAX_PATH]; 
		DWORD dwCount = sizeof(scTemp); 
		if(hKey.QueryValue(scTemp,"SystemVctmp",&dwCount) == ERROR_SUCCESS) 
		{ 
			if(atoi(scTemp)>25){ 
//				MessageBox(NULL,"GraphSoft2 试用班版到期! \n购买序列号联系Xiagl@nanjing_fnst.com","提示",MB_OK); 
//				abort(); 
			}else{ 
				int nTime = atoi(scTemp); 
				nTime = nTime + 1; 
				CString str;		 
				str.Format("%d",nTime);				 
				hKey.SetValue(str,"SystemVctmp"); 
				bWrite = FALSE; 
			} 
		} 
		if(bWrite) 
			hKey.SetValue("1","SystemVctmp"); 
		hKey.Close(); 
	} 
 
	// Register the application's document templates.  Document templates 
	//  serve as the connection between documents, frame windows and views. 
	CSplashWindow *m_pSplashWindow = new CSplashWindow; 
	m_pSplashWindow->CreateSplash(); 
	m_pSplashWindow->CenterWindow(); 
	m_pSplashWindow->ShowWindow(SW_SHOW); 
	m_pSplashWindow->UpdateWindow(); 
	Sleep(2000); //Delay 3 Seconds 
	m_pSplashWindow->DestroyWindow(); //Destroy Window 
	delete m_pSplashWindow; 
	 
 
 
	CSingleDocTemplate* pDocTemplate; 
	pDocTemplate = new CSingleDocTemplate( 
		IDR_MAINFRAME, 
		RUNTIME_CLASS(CGraphSoftDoc), 
		RUNTIME_CLASS(CMainFrame),       // main SDI frame window 
		RUNTIME_CLASS(CGraphSoftView)); 
	AddDocTemplate(pDocTemplate); 
 
	// Parse command line for standard shell commands, DDE, file open 
	CCommandLineInfo cmdInfo; 
	ParseCommandLine(cmdInfo); 
 
	// Dispatch commands specified on the command line 
	if (!ProcessShellCommand(cmdInfo)) 
		return FALSE; 
 
	// The one and only window has been initialized, so show and update it. 
	m_pMainWnd->ShowWindow(SW_SHOW); 
	m_pMainWnd->UpdateWindow(); 
  
	return TRUE; 
} 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CAboutDlg dialog used for App About 
 
class CAboutDlg : public CDialog 
{ 
public: 
	CAboutDlg(); 
 
// Dialog Data 
	//{{AFX_DATA(CAboutDlg) 
	enum { IDD = IDD_ABOUTBOX }; 
	CHyperLink	m_ctrlMail; 
	//}}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) 
	DDX_Control(pDX, IDC_MAIL, m_ctrlMail); 
	//}}AFX_DATA_MAP 
} 
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 
	//{{AFX_MSG_MAP(CAboutDlg) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
BOOL CAboutDlg::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
	 
	// TODO: Add extra initialization here 
	m_ctrlMail.SetURL("mailto:325003xgl@sina.com"); 
	 
	return TRUE;  // return TRUE unless you set the focus to a control 
	// EXCEPTION: OCX Property Pages should return FALSE 
} 
// App command to run the dialog 
void CGraphSoftApp::OnAppAbout() 
{ 
	CAboutDlg aboutDlg; 
	aboutDlg.DoModal(); 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CGraphSoftApp message handlers 
 
 
void CGraphSoftApp::OnFileOpen()  
{ 
	// TODO: Add your command handler code here 
	CWinApp::OnFileOpen();		 
} 
 
CDocument* CGraphSoftApp::OpenDocumentFile(LPCTSTR lpszFileName)  
{ 
	// TODO: Add your specialized code here and/or call the base class 
 
/*	CGraphSoftView* pView=(CGraphSoftView*)((CMainFrame*)AfxGetApp()->GetMainWnd())->GetActiveView(); 
	CGraphSoftDoc* pDoc=pView->GetDocument(); 
	 
	CString strTitle,strDetail; 
	strTitle.LoadString(IDS_FILE_SAVE_TITLE); 
	strDetail.LoadString(IDS_FILE_SAVE_STRING);	 
	 
	if(pDoc->m_pCore->IsAbleToUndo()||pDoc->m_pCore->IsAbleToRedo()) 
	{ 
		int nRtn=GetMainWnd()->MessageBox(strDetail,strTitle,MB_YESNOCANCEL|MB_APPLMODAL); 
		if(nRtn==IDYES){ 
			SendMessage(AfxGetApp()->GetMainWnd()->GetSafeHwnd(),WM_COMMAND,WPARAM(ID_FILE_SAVE),NULL);		 
		}else if(nRtn==IDCANCEL){ 
			return CWinApp::OpenDocumentFile(lpszFileName);; 
		} 
	}	 
	 
	pDoc->m_nCurrentShapeType=_shape_none; 
	if(pView!=NULL) 
	{ 
		pView->m_graph_op=_graph_noneOp; 
		pView->m_bDrawFlag = FALSE;		 
	} 
	if(m_strFileName.Compare(lpszFileName)!=0)	{ 
		delete pDoc->m_pCore;//删除撤消/恢复对象指针,以及删除图形对象指针 
		pDoc->m_shapeList.RemoveAll(); 
		pDoc->m_pCore=new CCore(pDoc,pView);    		 
	}	 
*/ 
	CDocument* pDocRlt=CWinApp::OpenDocumentFile(lpszFileName);//如果同名,则不再重新序列化 
 
/*	if(m_strFileName.Compare(lpszFileName)!=0)	{		 
		CUND_Base* pUNDBase; 
		POSITION pos=pDoc->m_shapeList.GetHeadPosition();	 
		while (pos!=NULL) { 
			CShape* pShape=pDoc->m_shapeList.GetNext(pos); 
			pUNDBase = new CUND_Create(pShape); 
			pDoc->m_pCore->AddUndoItem(pUNDBase); 
		}		 
		 
		((CMainFrame*)this->GetMainWnd())->GetActiveView()->Invalidate(TRUE);  
	}	 
	m_strFileName = lpszFileName; 
*/ 
	return pDocRlt; 
}