?? aaa.cpp
字號(hào):
// aaa.cpp : Defines the class behaviors for the application.
//
#include "stdafx.h"
#include "aaa.h"
#include "MainFrm.h"
#include "aaaDoc.h"
#include "LeftView.h"
#include "DlgLogin.h"
#include "AaaView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAaaApp
BEGIN_MESSAGE_MAP(CAaaApp, CWinApp)
//{{AFX_MSG_MAP(CAaaApp)
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()
/////////////////////////////////////////////////////////////////////////////
// CAaaApp construction
CAaaApp::CAaaApp()
{
memset(m_pzServer, 0, 128);
memset(m_pzDataBase, 0, 128);
memset(m_pzUser, 0, 128);
memset(m_pzPassWord, 0, 128);
iLevel = 0;
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CAaaApp object
CAaaApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CAaaApp initialization
BOOL CAaaApp::InitInstance()
{
AfxOleInit(); //OLE 初始化
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
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(CAaaDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CLeftView));
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;
m_pMainWnd->SetWindowText("企業(yè)倉(cāng)庫管理系統(tǒng)");
// m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
m_pMainWnd->UpdateWindow();
//讀配置文件
GetPrivateProfileString("OPTION", "Server", "", m_pzServer,
sizeof(m_pzServer), "./Login.ini") ;
GetPrivateProfileString("OPTION", "DataBase", "", m_pzDataBase,
sizeof(m_pzDataBase), "./Login.ini") ;
GetPrivateProfileString("OPTION", "UserId", "", m_pzUser,
sizeof(m_pzUser), "./Login.ini") ;
GetPrivateProfileString("OPTION", "PassWord", "", m_pzPassWord,
sizeof(m_pzPassWord), "./Login.ini") ;
strAdoConn.Format("driver={SQL Server};SERVER=%s;UID=%s;PWD=%s;DATABASE=%s",
m_pzServer, m_pzUser, m_pzPassWord, m_pzDataBase);
if (m_pzServer[0] == 0 || m_pzDataBase[0] == 0 || m_pzUser[0]==0)
{
::MessageBox(NULL, "請(qǐng)您檢查配置文件(Login.ini)!",
"配置文件錯(cuò)誤", MB_ICONERROR);
return FALSE();
}
//顯示登錄對(duì)話框
CDlgLogin dlg;
if (dlg.DoModal() != IDOK)
{
return FALSE;
}
if (dlg.strUser.IsEmpty() || dlg.strPassWord.IsEmpty())
{
::MessageBox(NULL, "Unhandle exception in aaa.exe (MFC42D,DLL): 0xC0000005: Access Violation",
"Microsoft Visual C++", MB_ICONASTERISK);
::MessageBox(NULL, "操作員名稱或密碼錯(cuò)誤\n\n請(qǐng)您重新登錄!",
"登錄錯(cuò)誤", MB_ICONERROR);
return FALSE;
}
this->strUser = dlg.strUser;
this->strPassWord = dlg.strPassWord;
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)
// No message handlers
//}}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)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
// App command to run the dialog
void CAaaApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
/////////////////////////////////////////////////////////////////////////////
// CAaaApp message handlers
int CAaaApp::ExitInstance()
{
// TODO: Add your specialized code here and/or call the base class
//delete (m_pMainWnd);
return CWinApp::ExitInstance();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -