【VC开源代码栏目提醒】:网学会员VC开源代码为您提供aaa.cpp参考,解决您在aaa.cpp学习中工作中的难题,参考学习。
// 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("仓库管理信息系统");
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("Provider=SQLOLEDB.1;Password=%s;Persist Security Info=True;User ID=%s;Initial Catalog=%s;Data Source=%s",m_pzPassWord, m_pzUser,m_pzDataBase,m_pzServer);
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, "请您检查配置文件(Login.ini)的残缺项!", "配置文件错误", MB_ICONERROR);
return FALSE();
}
//显示登录对话框
CDlgLogin dlg;
if (dlg.DoModal() != IDOK)
{
return FALSE;
}
if (dlg.strUser.IsEmpty() || dlg.strPassWord.IsEmpty())
{
::MessageBox(NULL, "操作员名称或密码错误\n\n 请您重新登录!", "登录错误", 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();
}
上一篇:
aa.cpp
下一篇:
让我掉下眼泪的