📄 gpmis.cpp
字号:
// GPMIS.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "GPMIS.h"
#include "MainFrm.h"
#include "GPMISDoc.h"
#include "GPMISView.h"
#include "Global.h"
#include "LogonDlg.h"
#include "HyperLink.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CGPMISApp
BEGIN_MESSAGE_MAP(CGPMISApp, CWinApp)
//{{AFX_MSG_MAP(CGPMISApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}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()
/////////////////////////////////////////////////////////////////////////////
// CGPMISApp construction
CGPMISApp::CGPMISApp()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
m_hkey = HKEY_LOCAL_MACHINE;
SetRegistryKey(REGISTRY_KEY);
m_pBlowfish = NULL;
m_pConnect = NULL;
m_hProcessID = NULL;
m_lpData = NULL;
}
CGPMISApp::~CGPMISApp()
{
CGlobal::GetInstance().RemoveTeacherList();
delete m_pBlowfish;
if(m_pConnect)
m_pConnect->Close();
if( m_lpData )
::UnmapViewOfFile(m_lpData); // 取消文件映象
if( m_hProcessID )
::CloseHandle(m_hProcessID);
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CGPMISApp object
CGPMISApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CGPMISApp initialization
BOOL CGPMISApp::InitInstance()
{
if (!AfxSocketInit())
{
AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
return FALSE;
}
AfxEnableControlContainer();
SingleInstance();
// 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.
m_pBlowfish = new CBlowfish((BYTE*)CRYPT_KEY, (short)strlen(CRYPT_KEY));
GetDataBaseStr();
// set register
SetRegistryKey("Software\\Microsoft\\Shared Tools\\");
GetRegistryValue("MsInfo","Path",m_strSysInfoPath,"");
// set register
SetRegistryKey(REGISTRY_KEY);
char szBuffer[MAX_PATH];
GetCurrentDirectory(MAX_PATH,szBuffer );
m_strWorkDir.Format("%s",szBuffer);
::CoInitialize(NULL);
if( !ConnectDB() )
{
MessageBox(NULL,"数据库错误!","错误",MB_OK|MB_ICONERROR);
return FALSE;
}
CGlobal::GetInstance().CreateTeacherList(CTime::GetCurrentTime().GetYear());
CLogonDlg LogonDlg;
if( LogonDlg.DoModal() != IDOK )
{
return FALSE;
}
m_bAdmin = LogonDlg.m_bAdmin;
m_strLogin = LogonDlg.m_strOperator;
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CGPMISDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CGPMISView));
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
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CStatic m_ctrlVersion;
CStatic m_ctrlProgram;
CButton m_ctrlSysInfo;
CStatic m_ctrlProductID;
//}}AFX_DATA
CHyperLink m_CompanyLink;
CHyperLink m_ContactLink;
CString m_strVersion;
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
public:
virtual BOOL PreTranslateMessage(MSG* pMsg);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSysinfo();
afx_msg void OnClose();
afx_msg void OnMytip();
virtual void OnOK();
afx_msg void OnTimer(UINT nIDEvent);
//}}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_VERSION, m_ctrlVersion);
DDX_Control(pDX, IDC_PROGRAM, m_ctrlProgram);
DDX_Control(pDX, ID_SYSINFO, m_ctrlSysInfo);
DDX_Control(pDX, IDC_PRODUCT_ID, m_ctrlProductID);
//}}AFX_DATA_MAP
DDX_Control(pDX, IDC_COMPANY, m_CompanyLink);
DDX_Control(pDX, IDC_CONTACT, m_ContactLink);
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_BN_CLICKED(ID_SYSINFO, OnSysinfo)
ON_WM_CLOSE()
ON_COMMAND(ID_MYTIP, OnMytip)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// Set HyperLink for
HICON hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
SetIcon(hIcon, TRUE); // Set big icon
SetIcon(hIcon, FALSE);// Set small icon
CString strCompanyLink;
strCompanyLink.LoadString(IDS_COMPANY_LINK);
m_CompanyLink.SetURL(strCompanyLink);
m_CompanyLink.SetUnderline(TRUE);
m_CompanyLink.SetLinkCursor(AfxGetApp()->LoadCursor(IDC_HAND));
m_CompanyLink.SetAutoSize(TRUE);
CString strContactLink;
strContactLink.LoadString(IDS_CONTACT_LINK);
m_ContactLink.SetURL(strContactLink);
m_ContactLink.SetUnderline(TRUE);
m_ContactLink.SetLinkCursor(AfxGetApp()->LoadCursor(IDC_HAND));
m_ContactLink.SetAutoSize(TRUE);
CString strTemp, strProductID, strProgram;
CMainFrame* pMainFrm = (CMainFrame*)GetParentFrame();
CString strExeName = AfxGetApp()->m_pszExeName;
strExeName += ".exe";
CString strVersionInfo = theApp.GetVersionInformation(strExeName);
theApp.GetRegistryValue("","CurrentVersion",strTemp,strVersionInfo);
strProgram.Format("毕业设计管理系统 %s 版",strTemp);
m_ctrlProgram.SetWindowText(strProgram);
theApp.GetRegistryValue("Main","User_Name",strTemp,"zeng fanfeng");
strProductID = " " + strTemp + "\n";
theApp.GetRegistryValue("Main","User_Company",strTemp,"NCUT, Computer Department");
strProductID += " ";
strProductID += strTemp;
strProductID += "\n";
theApp.GetRegistryValue("Main","Product_ID",strTemp,"未注册");
strProductID += " ";
if( strTemp != "未注册" )
strProductID += "产品编号: ";
strProductID += strTemp;
m_ctrlProductID.SetWindowText(strProductID);
m_ctrlVersion.GetWindowText(m_strVersion);
if( theApp.m_strSysInfoPath == _T("") )
m_ctrlSysInfo.EnableWindow(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(!TranslateAccelerator(this->m_hWnd, ((CGPMISApp *)AfxGetApp())->m_hAccel, pMsg))
return CDialog::PreTranslateMessage(pMsg);
else return 1;
}
void CAboutDlg::OnSysinfo()
{
// TODO: Add your control notification handler code here
WinExec((LPCSTR)theApp.m_strSysInfoPath,SW_SHOW);
}
void CAboutDlg::OnOK()
{
// TODO: Add extra validation here
OnClose();
CDialog::OnOK();
}
#define MY_TIP "2007-3-12开始"
void CAboutDlg::OnMytip()
{
// TODO: Add your command handler code here
CPoint point;
CRect Rect;
GetClientRect(&Rect);
point.x = Rect.left+(Rect.Width()-60)/2;
point.y = Rect.top;
ClientToScreen(&point);
CString strVersion;
strVersion.Format("%s(%s)", m_strVersion, MY_TIP);
m_ctrlVersion.SetWindowText(strVersion);
SetTimer(0x0001, 5000, NULL);
}
void CAboutDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
KillTimer(0x0001);
m_ctrlVersion.SetWindowText(m_strVersion);
CDialog::OnTimer(nIDEvent);
}
void CAboutDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
KillTimer(0x0001);
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -