1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
 
// PLCConnector.cpp : ÀÀ¿ë ÇÁ·Î±×·¥¿¡ ´ëÇѠŬ·¡½º µ¿ÀÛÀ» Á¤ÀÇÇÕ´Ï´Ù.
//
 
#include "stdafx.h"
#include "afxwinappex.h"
#include "PLCConnector.h"
#include "MainFrm.h"
 
#include "PLCConnectorDoc.h"
#include "PLCConnectorView.h"
 
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
 
 
// CPLCConnectorApp
 
BEGIN_MESSAGE_MAP(CPLCConnectorApp, CWinAppEx)
    ON_COMMAND(ID_APP_ABOUT, &CPLCConnectorApp::OnAppAbout)
    // Ç¥ÁØ ÆÄÀÏÀ» ±âÃʷΠÇϴ ¹®¼­ ¸í·ÉÀÔ´Ï´Ù.
    ON_COMMAND(ID_FILE_NEW, &CWinAppEx::OnFileNew)
    ON_COMMAND(ID_FILE_OPEN, &CWinAppEx::OnFileOpen)
END_MESSAGE_MAP()
 
 
// CPLCConnectorApp »ý¼º
 
CPLCConnectorApp::CPLCConnectorApp()
{
 
    m_bHiColorIcons = TRUE;
    m_hDupCheck = NULL;
 
    // TODO: ¿©±â¿¡ »ý¼º Äڵ带 Ãß°¡ÇÕ´Ï´Ù.
    // InitInstance¿¡ ¸ðµç Áß¿äÇÑ ÃʱâÈ­ ÀÛ¾÷À» ¹èÄ¡ÇÕ´Ï´Ù.
}
 
// À¯ÀÏÇÑ CPLCConnectorApp °³Ã¼ÀÔ´Ï´Ù.
 
CPLCConnectorApp theApp;
 
 
// CPLCConnectorApp ÃʱâÈ­
 
BOOL CPLCConnectorApp::InitInstance()
{
    // ÀÀ¿ë ÇÁ·Î±×·¥ ¸Å´ÏÆä½ºÆ®°¡ ComCtl32.dll ¹öÀü 6 ÀÌ»óÀ» »ç¿ëÇÏ¿© ºñÁ־󠽺ŸÀÏÀ»
    // »ç¿ëÇϵµ·Ï ÁöÁ¤Çϴ °æ¿ì, Windows XP »ó¿¡¼­ ¹Ýµå½Ã InitCommonControlsEx()°¡ ÇÊ¿äÇÕ´Ï´Ù. 
    // InitCommonControlsEx()¸¦ »ç¿ëÇÏÁö ¾ÊÀ¸¸é Ã¢À» ¸¸µé ¼ö ¾ø½À´Ï´Ù.
    INITCOMMONCONTROLSEX InitCtrls;
    InitCtrls.dwSize = sizeof(InitCtrls);
    // ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼­ »ç¿ëÇÒ ¸ðµç °ø¿ë ÄÁÆ®·Ñ Å¬·¡½º¸¦ Æ÷ÇÔÇϵµ·Ï
    // ÀÌ Ç׸ñÀ» ¼³Á¤ÇϽʽÿÀ.
    InitCtrls.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&InitCtrls);
 
    CWinAppEx::InitInstance();
 
    // OLE ¶óÀ̺귯¸®¸¦ ÃʱâÈ­ÇÕ´Ï´Ù.
    if (!AfxOleInit())
    {
        AfxMessageBox(IDP_OLE_INIT_FAILED);
        return FALSE;
    }
    AfxEnableControlContainer();
    // Ç¥ÁØ ÃʱâÈ­
    // À̵頱â´ÉÀ» »ç¿ëÇÏÁö ¾Ê°í ÃÖÁ¾ ½ÇÇà ÆÄÀÏÀÇ Å©±â¸¦ ÁÙÀÌ·Á¸é
    // ¾Æ·¡¿¡¼­ Çʿ䠾ø´Â Æ¯Á¤ ÃʱâÈ­
    // ·çƾÀ» Á¦°ÅÇØ¾ß ÇÕ´Ï´Ù.
    // ÇØ´ç ¼³Á¤ÀÌ ÀúÀåµÈ ·¹Áö½ºÆ®¸® Å°¸¦ º¯°æÇϽʽÿÀ.
 
    m_hDupCheck = ::CreateEvent(NULL,FALSE, FALSE,
                                _T("DUPLICATION_CHECK_EVENT"));
    if(::GetLastError() == ERROR_ALREADY_EXISTS)
    {
        //AfxMessageBox(_T("ERROR::Application is running!"));
        return FALSE;
    }
    // TODO: ÀÌ ¹®ÀÚ¿­À» È¸»ç ¶Ç´Â Á¶Á÷ÀÇ À̸§°ú °°Àº
    // ÀûÀýÇÑ ³»¿ëÀ¸·Î ¼öÁ¤ÇؾߠÇÕ´Ï´Ù.
    SetRegistryKey(_T("·ÎÄàÀÀ¿ë ÇÁ·Î±×·¥ ¸¶¹ý»ç¿¡¼­ »ý¼ºµÈ ÀÀ¿ë ÇÁ·Î±×·¥"));
    LoadStdProfileSettings(4);  // MRU¸¦ Æ÷ÇÔÇÏ¿© Ç¥ÁØ INI ÆÄÀÏ ¿É¼ÇÀ» ·ÎµåÇÕ´Ï´Ù.
 
    InitContextMenuManager();
 
    InitKeyboardManager();
 
    InitTooltipManager();
    CMFCToolTipInfo ttParams;
    ttParams.m_bVislManagerTheme = TRUE;
    theApp.GetTooltipManager()->SetTooltipParams(AFX_TOOLTIP_TYPE_ALL,
        RUNTIME_CLASS(CMFCToolTipCtrl), &ttParams);
 
    // ÀÀ¿ë ÇÁ·Î±×·¥ÀÇ ¹®¼­ ÅÛÇø´À» µî·ÏÇÕ´Ï´Ù. ¹®¼­ ÅÛÇø´Àº
    //  ¹®¼­, ÇÁ·¹ÀӠâ ¹× ºä »çÀÌÀÇ ¿¬°á ¿ªÇÒÀ» ÇÕ´Ï´Ù.
    CSingleDocTemplate* pDocTemplate;
    pDocTemplate = new CSingleDocTemplate(
        IDR_MAINFRAME,
        RUNTIME_CLASS(CPLCConnectorDoc),
        RUNTIME_CLASS(CMainFrame),       // ÁÖ SDI ÇÁ·¹ÀӠâÀÔ´Ï´Ù.
        RUNTIME_CLASS(CPLCConnectorView));
    if (!pDocTemplate)
        return FALSE;
    AddDocTemplate(pDocTemplate);
 
 
 
    // Ç¥ÁØ ¼Ð ¸í·É, DDE, ÆÄÀÏ ¿­±â¿¡ ´ëÇÑ ¸í·ÉÁÙÀ» ±¸¹® ºÐ¼®ÇÕ´Ï´Ù.
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo);
 
 
    // ¸í·ÉÁÙ¿¡ ÁöÁ¤µÈ ¸í·ÉÀ» µð½ºÆÐÄ¡ÇÕ´Ï´Ù.
    // ÀÀ¿ë ÇÁ·Î±×·¥ÀÌ /RegServer, /Register, /Unregserver ¶Ç´Â /Unregister·Î ½ÃÀ۵Ƞ°æ¿ì FALSE¸¦ ¹ÝȯÇÕ´Ï´Ù.
    if (!ProcessShellCommand(cmdInfo))
        return FALSE;
 
    // Ã¢ Çϳª¸¸ ÃʱâÈ­µÇ¾úÀ¸¹Ç·Î À̸¦ Ç¥½ÃÇÏ°í ¾÷µ¥ÀÌÆ®ÇÕ´Ï´Ù.
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();
    // Á¢¹Ì»ç°¡ ÀÖÀ» °æ¿ì¿¡¸¸ DragAcceptFiles¸¦ È£ÃâÇÕ´Ï´Ù.
    //  SDI ÀÀ¿ë ÇÁ·Î±×·¥¿¡¼­´Â ProcessShellCommand ÈÄ¿¡ ÀÌ·¯ÇѠȣÃâÀÌ ¹ß»ýÇØ¾ß ÇÕ´Ï´Ù.
    return TRUE;
}
 
 
 
// ÀÀ¿ë ÇÁ·Î±×·¥ Á¤º¸¿¡ »ç¿ëµÇ´Â CAboutDlg ´ëÈ­ »óÀÚÀÔ´Ï´Ù.
 
class CAboutDlg : public CDialog
{
public:
    CAboutDlg();
 
// ´ëÈ­ »óÀÚ µ¥ÀÌÅÍÀÔ´Ï´Ù.
    enum { IDD = IDD_ABOUTBOX };
 
protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV Áö¿øÀÔ´Ï´Ù.
 
// ±¸ÇöÀÔ´Ï´Ù.
protected:
    DECLARE_MESSAGE_MAP()
};
 
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}
 
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
    CDialog::DoDataExchange(pDX);
}
 
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()
 
// ´ëÈ­ »óÀÚ¸¦ ½ÇÇàÇϱâ À§ÇÑ ÀÀ¿ë ÇÁ·Î±×·¥ ¸í·ÉÀÔ´Ï´Ù.
void CPLCConnectorApp::OnAppAbout()
{
    CAboutDlg aboutDlg;
    aboutDlg.DoModal();
}
 
// CPLCConnectorApp »ç¿ëÀÚ ÁöÁ¤ ·Îµå/ÀúÀå ¸Þ¼­µå
 
void CPLCConnectorApp::PreLoadState()
{
    BOOL bNameValid;
    CString strName;
    bNameValid = strName.LoadString(IDS_EDIT_MENU);
    ASSERT(bNameValid);
    GetContextMenuManager()->AddMenu(strName, IDR_POPUP_EDIT);
}
 
void CPLCConnectorApp::LoadCustomState()
{
}
 
void CPLCConnectorApp::SaveCustomState()
{
}
 
// CPLCConnectorApp ¸Þ½ÃÁö Ã³¸®±â
 
 
 
 
int CPLCConnectorApp::ExitInstance()
{
    // TODO: ¿©±â¿¡ Æ¯¼öÈ­µÈ Äڵ带 Ãß°¡ ¹×/¶Ç´Â ±âº» Å¬·¡½º¸¦ È£ÃâÇÕ´Ï´Ù.
    if( m_hDupCheck != NULL)
        ::CloseHandle(m_hDupCheck);
 
    return CWinAppEx::ExitInstance();
}