【正文】
yApp, CWinApp)//{{AFX_MSG_MAP(CMyApp)// NOTE the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code!//}}AFX_MSG5 ON_COMMAND(ID_HELP, CWinApp::OnHelp)END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////// CMyApp constructionCMyApp::CMyApp(){// TODO: add construction code here,// Place all significant initialization in InitInstance}// The one and only CMyApp objectCMyApp theApp。CDaoDatabase db。//建立全局變量,在其他地方調(diào)用時要加extern // CMyApp initializationBOOL CMyApp::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 _AFXDLLEnable3dControls()。 // Call this when using MFC in a shared DLL elseEnable3dControlsStatic()。 // Call this when linking to MFC statically endif//這里就是程序入口,在這里添加數(shù)據(jù)庫檢查代碼CString Filepath=amp。quot。amp。quot。CDaoRecordset Dbset(amp。amp。db)。CFileFind Ffind。//先看看存不存在數(shù)據(jù)庫文件BOOL flag=(Filepath)。()。if(!flag)//如果沒有就創(chuàng)建{CString sqlcmd=amp。quot。CREATE TABLE DataTable(NameVARCHAR(20),Psw VARCHAR(20))amp。quot。(Filepath)。(sqlcmd)。(AFX_DAO_USE_DEFAULT_TYPE,amp。quot。SELECT * FROM DataTableamp。quot。,0)。()。(amp。quot。Nameamp。quot。,_variant_t(amp。quot。wzhamp。quot。))。(amp。quot。Pswamp。quot。,_variant_t(amp。quot。123456amp。quot。))。()。()。6 } ()。 }//建立數(shù)據(jù)庫文件,設置初始化賬號 CMyDlg dlg。 m_pMainWnd = amp。amp。dlg。 int nResponse = ()。 if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application’s message pump. return FALSE。 void CMyDlg::OnPaint(){if (IsIconic()){CPaintDC dc(this)。 // device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) (),0)。7 // Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON)。int cyIcon = GetSystemMetrics(SM_CYICON)。CRect rect。GetClientRect(amp。amp。rect)。int x = (() cxIcon + 1) / 2。int y = (() cyIcon + 1) / 2。// Draw the icon(x, y, m_hIcon)。}else{// 給窗體添加背景CPaintDC dc(this)。CRect rc。GetClientRect(amp。amp。rc)。CDC dcMem。(amp。amp。dc)。CBitmap bmpBackground。(IDB_BITMAP1)。BITMAP bitmap。(amp。amp。bitmap)。//取得bmpBackground中圖片的信息,放在bitmap所指的指針中CBitmap* pbmpPri = (a