-rw-r--r-- | bigbrother.cpp | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/bigbrother.cpp b/bigbrother.cpp new file mode 100644 index 0000000..0036987 --- a/dev/null +++ b/bigbrother.cpp | |||
@@ -0,0 +1,181 @@ | |||
1 | // BigBrother.cpp : Defines the class behaviors for the application. | ||
2 | // | ||
3 | |||
4 | #include "stdafx.h" | ||
5 | #include "BigBrother.h" | ||
6 | |||
7 | #include "MainFrm.h" | ||
8 | #include "BigBrotherDoc.h" | ||
9 | #include "BigBrotherView.h" | ||
10 | |||
11 | #ifdef _DEBUG | ||
12 | #define new DEBUG_NEW | ||
13 | #undef THIS_FILE | ||
14 | static char THIS_FILE[] = __FILE__; | ||
15 | #endif | ||
16 | |||
17 | ///////////////////////////////////////////////////////////////////////////// | ||
18 | // CBigBrotherApp | ||
19 | |||
20 | BEGIN_MESSAGE_MAP(CBigBrotherApp, CWinApp) | ||
21 | //{{AFX_MSG_MAP(CBigBrotherApp) | ||
22 | ON_COMMAND(ID_APP_ABOUT, OnAppAbout) | ||
23 | ON_UPDATE_COMMAND_UI(ID_FILE_AUTOLOAD, OnUpdateFileAutoload) | ||
24 | ON_COMMAND(ID_FILE_AUTOLOAD, OnFileAutoload) | ||
25 | ON_COMMAND(ID_HELP_LEGEND, OnHelpLegend) | ||
26 | //}}AFX_MSG_MAP | ||
27 | // Standard file based document commands | ||
28 | ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) | ||
29 | ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) | ||
30 | // Standard print setup command | ||
31 | ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup) | ||
32 | END_MESSAGE_MAP() | ||
33 | |||
34 | ///////////////////////////////////////////////////////////////////////////// | ||
35 | // CBigBrotherApp construction | ||
36 | |||
37 | CBigBrotherApp::CBigBrotherApp() | ||
38 | { | ||
39 | m_bLoadMRUOnStartup=TRUE; | ||
40 | } | ||
41 | |||
42 | ///////////////////////////////////////////////////////////////////////////// | ||
43 | // The one and only CBigBrotherApp object | ||
44 | |||
45 | CBigBrotherApp theApp; | ||
46 | |||
47 | ///////////////////////////////////////////////////////////////////////////// | ||
48 | // CBigBrotherApp initialization | ||
49 | |||
50 | BOOL CBigBrotherApp::InitInstance() | ||
51 | { | ||
52 | if (!AfxSocketInit()) | ||
53 | { | ||
54 | AfxMessageBox(IDP_SOCKETS_INIT_FAILED); | ||
55 | return FALSE; | ||
56 | } | ||
57 | |||
58 | // Standard initialization | ||
59 | // If you are not using these features and wish to reduce the size | ||
60 | // of your final executable, you should remove from the following | ||
61 | // the specific initialization routines you do not need. | ||
62 | |||
63 | #ifdef _AFXDLL | ||
64 | Enable3dControls(); // Call this when using MFC in a shared DLL | ||
65 | #else | ||
66 | Enable3dControlsStatic();// Call this when linking to MFC statically | ||
67 | #endif | ||
68 | |||
69 | SetRegistryKey(IDS_REGISTRYKEY); | ||
70 | m_pszHelpFilePath="bigbro.hlp>Default"; | ||
71 | |||
72 | LoadStdProfileSettings(); // Load standard INI file options (including MRU) | ||
73 | m_bLoadMRUOnStartup=GetProfileInt("Settings","LoadMRUOnStartup",m_bLoadMRUOnStartup); | ||
74 | |||
75 | // Register the application's document templates. Document templates | ||
76 | // serve as the connection between documents, frame windows and views. | ||
77 | |||
78 | CSingleDocTemplate* pDocTemplate; | ||
79 | pDocTemplate = new CSingleDocTemplate( | ||
80 | IDR_MAINFRAME, | ||
81 | RUNTIME_CLASS(CBigBrotherDoc), | ||
82 | RUNTIME_CLASS(CMainFrame), // main SDI frame window | ||
83 | RUNTIME_CLASS(CBigBrotherView)); | ||
84 | AddDocTemplate(pDocTemplate); | ||
85 | |||
86 | // Enable DDE Execute open | ||
87 | EnableShellOpen(); | ||
88 | RegisterShellFileTypes(TRUE); | ||
89 | |||
90 | // Parse command line for standard shell commands, DDE, file open | ||
91 | CCommandLineInfo cmdInfo; | ||
92 | ParseCommandLine(cmdInfo); | ||
93 | |||
94 | // Dispatch commands specified on the command line | ||
95 | if (!ProcessShellCommand(cmdInfo)) | ||
96 | return FALSE; | ||
97 | if(m_bLoadMRUOnStartup && (cmdInfo.m_nShellCommand==CCommandLineInfo::FileNew)) | ||
98 | m_pMainWnd->SendMessage(WM_COMMAND,ID_FILE_MRU_FILE1,0); | ||
99 | |||
100 | // Enable drag/drop open | ||
101 | m_pMainWnd->DragAcceptFiles(); | ||
102 | |||
103 | return TRUE; | ||
104 | } | ||
105 | |||
106 | ///////////////////////////////////////////////////////////////////////////// | ||
107 | // CAboutDlg dialog used for App About | ||
108 | |||
109 | class CAboutDlg : public CDialog | ||
110 | { | ||
111 | public: | ||
112 | CAboutDlg(); | ||
113 | |||
114 | // Dialog Data | ||
115 | //{{AFX_DATA(CAboutDlg) | ||
116 | enum { IDD = IDD_ABOUTBOX }; | ||
117 | //}}AFX_DATA | ||
118 | |||
119 | // ClassWizard generated virtual function overrides | ||
120 | //{{AFX_VIRTUAL(CAboutDlg) | ||
121 | protected: | ||
122 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support | ||
123 | //}}AFX_VIRTUAL | ||
124 | |||
125 | // Implementation | ||
126 | protected: | ||
127 | //{{AFX_MSG(CAboutDlg) | ||
128 | // No message handlers | ||
129 | //}}AFX_MSG | ||
130 | DECLARE_MESSAGE_MAP() | ||
131 | }; | ||
132 | |||
133 | CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) | ||
134 | { | ||
135 | //{{AFX_DATA_INIT(CAboutDlg) | ||
136 | //}}AFX_DATA_INIT | ||
137 | } | ||
138 | |||
139 | void CAboutDlg::DoDataExchange(CDataExchange* pDX) | ||
140 | { | ||
141 | CDialog::DoDataExchange(pDX); | ||
142 | //{{AFX_DATA_MAP(CAboutDlg) | ||
143 | //}}AFX_DATA_MAP | ||
144 | } | ||
145 | |||
146 | BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) | ||
147 | //{{AFX_MSG_MAP(CAboutDlg) | ||
148 | // No message handlers | ||
149 | //}}AFX_MSG_MAP | ||
150 | END_MESSAGE_MAP() | ||
151 | |||
152 | // App command to run the dialog | ||
153 | void CBigBrotherApp::OnAppAbout() | ||
154 | { | ||
155 | CAboutDlg aboutDlg; | ||
156 | aboutDlg.DoModal(); | ||
157 | } | ||
158 | |||
159 | ///////////////////////////////////////////////////////////////////////////// | ||
160 | // CBigBrotherApp commands | ||
161 | |||
162 | int CBigBrotherApp::ExitInstance() | ||
163 | { | ||
164 | WriteProfileInt("Settings","LoadMRUOnStartup",m_bLoadMRUOnStartup); | ||
165 | return CWinApp::ExitInstance(); | ||
166 | } | ||
167 | |||
168 | void CBigBrotherApp::OnUpdateFileAutoload(CCmdUI* pCmdUI) | ||
169 | { | ||
170 | pCmdUI->SetCheck(m_bLoadMRUOnStartup?1:0); | ||
171 | } | ||
172 | |||
173 | void CBigBrotherApp::OnFileAutoload() | ||
174 | { | ||
175 | m_bLoadMRUOnStartup=!m_bLoadMRUOnStartup; | ||
176 | } | ||
177 | |||
178 | void CBigBrotherApp::OnHelpLegend() | ||
179 | { | ||
180 | WinHelp(0x10000lu+ID_HELP_LEGEND,HELP_CONTEXTPOPUP); | ||
181 | } | ||