1、 尹能 《小区住户信息管理系统》 第11页 共11页
设计源程序清单
#include "stdafx.h"
#include "住户管理系统.h"
#include "MainFrm.h"
#include "住户管理系统Doc.h"
#include "住户管理系统View.h"
#include
2、IS_FILE[] = __FILE__; #endif BEGIN_MESSAGE_MAP(CMyApp, CWinApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) END_MESSAGE_MAP() CMyApp::
3、CMyApp() { } CMyApp theApp; BOOL CMyApp::InitInstance() { if (!InitATL()) return FALSE; AfxEnableControlContainer(); #ifdef _AFXDLL Enable3dControls(); #else Enable3dControlsStatic(); #endif SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdP
4、rofileSettings(); CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMyDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CMyView)); AddDocTemplate(pDocTemplate); CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo);
5、 if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated) { return TRUE; } if (!ProcessShellCommand(cmdInfo)) return FALSE; m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; } class CAboutDlg : public CDialog { public: CAboutDlg(); e
6、num { IDD = IDD_ABOUTBOX }; protected: virtual void DoDataExchange(CDataExchange* pDX); protected: DECLARE_MESSAGE_MAP() }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); }
7、BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) END_MESSAGE_MAP() void CMyApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } CMyModule _Module; BEGIN_OBJECT_MAP(ObjectMap) END_OBJECT_MAP() LONG CMyModule::Unlock() { AfxOleUnlockApp(); return 0; } LONG CMyModule:
8、Lock() { AfxOleLockApp(); return 1; } LPCTSTR CMyModule::FindOneOf(LPCTSTR p1, LPCTSTR p2) { while (*p1 != NULL) { LPCTSTR p = p2; while (*p != NULL) { if (*p1 == *p) return CharNext(p1); p = CharNext(p); } p1++; } return NULL; } int CMyApp::ExitIns
9、tance() { if (m_bATLInited) { _Module.RevokeClassObjects(); _Module.Term(); CoUninitialize(); } return CWinApp::ExitInstance(); } BOOL CMyApp::InitATL() { m_bATLInited = TRUE; #if _WIN32_WINNT >= 0x0400 HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED); #el
10、se HRESULT hRes = CoInitialize(NULL); #endif if (FAILED(hRes)) { m_bATLInited = FALSE; return FALSE; } _Module.Init(ObjectMap, AfxGetInstanceHandle()); _Module.dwThreadID = GetCurrentThreadId(); LPTSTR lpCmdLine = GetCommandLine(); TCHAR szTokens[] = _T("-/"); BOOL
11、bRun = TRUE; LPCTSTR lpszToken = _Module.FindOneOf(lpCmdLine, szTokens); while (lpszToken != NULL) { if (lstrcmpi(lpszToken, _T("UnregServer"))==0) { _Module.UpdateRegistryFromResource(IDR_MY, FALSE); _Module.UnregisterServer(TRUE); bRun = FALSE; break; } if (lstrc
12、mpi(lpszToken, _T("RegServer"))==0) { _Module.UpdateRegistryFromResource(IDR_MY, TRUE); _Module.RegisterServer(TRUE); bRun = FALSE; break; } lpszToken = _Module.FindOneOf(lpszToken, szTokens); } if (!bRun) { m_bATLInited = FALSE; _Module.Term(); CoUninitiali
13、ze(); return FALSE; } hRes = _Module.RegisterClassObjects(CLSCTX_LOCAL_SERVER, REGCLS_MULTIPLEUSE); if (FAILED(hRes)) { m_bATLInited = FALSE; CoUninitialize(); return FALSE; } return TRUE; } #if !defined(AFX_STDAFX_H__483D5902_B6F6_44D7_8C03_CA16BD202818__INCLUDE
14、D_)
#define AFX_STDAFX_H__483D5902_B6F6_44D7_8C03_CA16BD202818__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define VC_EXTRALEAN
#include
15、FXCMN_SUPPORT
#include 16、m.h>
#include 17、
} USER;
#if !defined(AFX__H__25F512A0_43D5_4305_9320_094CAF711563__INCLUDED_)
#define AFX__H__25F512A0_43D5_4305_9320_094CAF711563__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
18、endif
#include "resource.h"
#include "住户管理系统_i.h"
/////////////////////////////////////////////////////////////////////////////
class CMyApp : public CWinApp
{
public:
CMyApp();
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
afx_msg void OnAppAbo 19、ut();
DECLARE_MESSAGE_MAP()
private:
BOOL m_bATLInited;
private:
BOOL InitATL();
};
#if !defined(AFX_MAINFRM_H__E3A6002B_0354_4316_A925_471B0C72330C__INCLUDED_)
#define AFX_MAINFRM_H__E3A6002B_0354_4316_A925_471B0C72330C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MS 20、C_VER > 1000
//定义右边视的类型
#define USERSVIEW 0
#define USERINFOVIEW 1
#define WRONGVIEW -1
class CLeftTreeView;
class CUserinfoView;
class CUsersListView;
class CMainFrame : public CFrameWnd
{
protected:
CMainFrame();
DECLARE_DYNCREATE(CMainFrame)
public:
CLeftTreeView 21、 m_pLeftView; //树视图
CUsersListView* m_pUsersView; //住户列表视图
CUserinfoView* m_pUserinfoView; //住户详细信息视图
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
void SwitchToView(int nViewType);
virtual BOOL OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext);
22、virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
protected:
CSplitterWnd m_wndSplitter;
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
23、
afx_msg void OnOperateAdduser();
afx_msg void OnOperateQuery();
DECLARE_MESSAGE_MAP()
};
#if !defined(AFX_DOC_H__02131BA6_D967_47F2_8EB9_D01C557AF9E9__INCLUDED_)
#define AFX_DOC_H__02131BA6_D967_47F2_8EB9_D01C557AF9E9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 24、1000
#include "house.H"
class CMyDoc : public CDocument
{
protected:
CMyDoc();
DECLARE_DYNCREATE(CMyDoc)
public:
// Operations
public:
public:
virtual BOOL OnNewDocument();
virtual void Serialize(CArchive& ar);
public:
BOOL DeleteUser(CString strSql);
int AddUser( 25、USER &user);
virtual void DeleteContents();
Chouse m_dbHouse;
virtual ~CMyDoc();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
protected:
DECLARE_MESSAGE_MAP()
};
#if !defined(AFX_VIEW_H__716A0CEB_AFB6_41BE_8102_0 26、349ECF38AD3__INCLUDED_)
#define AFX_VIEW_H__716A0CEB_AFB6_41BE_8102_0349ECF38AD3__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CMyView : public CView
{
protected:
CMyView();
DECLARE_DYNCREATE(CMyView)
public:
CMyDoc* GetDocument();
public:
p 27、ublic:
virtual void OnDraw(CDC* pDC);
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
public:
virtual ~ 28、CMyView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in 住户管理系统View.cpp
inline CMyDoc* CMyView::GetDocument()
29、
{ return (CMyDoc*)m_pDocument; }
#endif
#ifdef __cplusplus
extern "C"{
#endif
#ifndef __IID_DEFINED__
#define __IID_DEFINED__
typedef struct _IID
{
unsigned long x;
unsigned short s1;
unsigned short s2;
unsigned char c[8];
} IID;
#endif
#ifndef CLSID_DEFINED
#define CLSID_DEFINED
typedef IID CLSID;
#endif
const IID LIBID_MyLib = {0xBC7E0972,0xBC75,0x4632,{0xA9,0xA1,0xE8,0xDA,0xFE,0x52,0xC9,0xDB}};
#ifdef __cplusplus
}
#endif






