-rw-r--r-- | KLogDlg.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/KLogDlg.cpp b/KLogDlg.cpp index 5f1c6c0..bdcb881 100644 --- a/KLogDlg.cpp +++ b/KLogDlg.cpp | |||
@@ -73,64 +73,65 @@ END_MESSAGE_MAP() | |||
73 | CKLogDlg::CKLogDlg(CWnd* pParent /*=NULL*/) | 73 | CKLogDlg::CKLogDlg(CWnd* pParent /*=NULL*/) |
74 | : CDialog(CKLogDlg::IDD, pParent) | 74 | : CDialog(CKLogDlg::IDD, pParent) |
75 | { | 75 | { |
76 | m_Logger=NULL; | 76 | m_Logger=NULL; |
77 | m_LogItems=15; | 77 | m_LogItems=15; |
78 | m_bShown=TRUE; | 78 | m_bShown=TRUE; |
79 | m_bExiting=FALSE; | 79 | m_bExiting=FALSE; |
80 | m_bWarnBlocking=TRUE; | 80 | m_bWarnBlocking=TRUE; |
81 | m_bDontWarn=TRUE; | 81 | m_bDontWarn=TRUE; |
82 | //{{AFX_DATA_INIT(CKLogDlg) | 82 | //{{AFX_DATA_INIT(CKLogDlg) |
83 | m_Logto = -1; | 83 | m_Logto = -1; |
84 | m_Desc = _T(""); | 84 | m_Desc = _T(""); |
85 | m_Facility = _T(""); | 85 | m_Facility = _T(""); |
86 | m_HFName = _T(""); | 86 | m_HFName = _T(""); |
87 | m_HFNameCaption = _T(""); | 87 | m_HFNameCaption = _T(""); |
88 | m_hlIP = _T(""); | 88 | m_hlIP = _T(""); |
89 | m_hlMask = _T(""); | 89 | m_hlMask = _T(""); |
90 | m_Sound = _T(""); | 90 | m_Sound = _T(""); |
91 | //}}AFX_DATA_INIT | 91 | //}}AFX_DATA_INIT |
92 | // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 | 92 | // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 |
93 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); | 93 | m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); |
94 | m_bmpBack.LoadBitmap(IDB_BACKGROUND); | 94 | m_bmpBack.LoadBitmap(IDB_BACKGROUND); |
95 | m_bmpBack.GetBitmap(&m_bitmapBack); | 95 | m_bmpBack.GetBitmap(&m_bitmapBack); |
96 | m_Trayer = new CTrayer(this); | 96 | m_Trayer = new CTrayer(this); |
97 | ASSERT(m_Trayer); | 97 | ASSERT(m_Trayer); |
98 | LoadSettings(); | 98 | LoadSettings(); |
99 | } | 99 | } |
100 | 100 | ||
101 | void CKLogDlg::DoDataExchange(CDataExchange* pDX) | 101 | void CKLogDlg::DoDataExchange(CDataExchange* pDX) |
102 | { | 102 | { |
103 | CDialog::DoDataExchange(pDX); | 103 | CDialog::DoDataExchange(pDX); |
104 | //{{AFX_DATA_MAP(CKLogDlg) | 104 | //{{AFX_DATA_MAP(CKLogDlg) |
105 | DDX_Control(pDX, IDCANCEL, m_CancelCtl); | ||
105 | DDX_Control(pDX, IDC_LOGPATTERN, m_LogPatternCtl); | 106 | DDX_Control(pDX, IDC_LOGPATTERN, m_LogPatternCtl); |
106 | DDX_Control(pDX, IDC_FILES, m_FilesCtl); | 107 | DDX_Control(pDX, IDC_FILES, m_FilesCtl); |
107 | DDX_Control(pDX, IDC_LOGLENSPIN, m_LogLenSpinCtl); | 108 | DDX_Control(pDX, IDC_LOGLENSPIN, m_LogLenSpinCtl); |
108 | DDX_Control(pDX, IDC_LOGLENGTH, m_LogLengthCtl); | 109 | DDX_Control(pDX, IDC_LOGLENGTH, m_LogLengthCtl); |
109 | DDX_Control(pDX, IDC_INVERT, m_PriInvertCtl); | 110 | DDX_Control(pDX, IDC_INVERT, m_PriInvertCtl); |
110 | DDX_Control(pDX, IDC_TYPE_FILE, m_LogtoFileCtl); | 111 | DDX_Control(pDX, IDC_TYPE_FILE, m_LogtoFileCtl); |
111 | DDX_Control(pDX, IDC_TYPE_HOST, m_LogtoHostCtl); | 112 | DDX_Control(pDX, IDC_TYPE_HOST, m_LogtoHostCtl); |
112 | DDX_Control(pDX, IDC_TYPE_NONE, m_LogtoNoneCtl); | 113 | DDX_Control(pDX, IDC_TYPE_NONE, m_LogtoNoneCtl); |
113 | DDX_Control(pDX, IDC_HOSTORFILE, m_HFNameCaptionCtl); | 114 | DDX_Control(pDX, IDC_HOSTORFILE, m_HFNameCaptionCtl); |
114 | DDX_Control(pDX, IDC_HOSTS, m_hlCtl); | 115 | DDX_Control(pDX, IDC_HOSTS, m_hlCtl); |
115 | DDX_Control(pDX, IDC_BROWSESOUND, m_BrowseSoundCtl); | 116 | DDX_Control(pDX, IDC_BROWSESOUND, m_BrowseSoundCtl); |
116 | DDX_Control(pDX, IDC_NONE, m_PriNoneCtl); | 117 | DDX_Control(pDX, IDC_NONE, m_PriNoneCtl); |
117 | DDX_Control(pDX, IDC_HL_REMOVE, m_hlRemoveCtl); | 118 | DDX_Control(pDX, IDC_HL_REMOVE, m_hlRemoveCtl); |
118 | DDX_Control(pDX, IDC_HL_MASK, m_hlMaskCtl); | 119 | DDX_Control(pDX, IDC_HL_MASK, m_hlMaskCtl); |
119 | DDX_Control(pDX, IDC_HL_IP, m_hlIPCtl); | 120 | DDX_Control(pDX, IDC_HL_IP, m_hlIPCtl); |
120 | DDX_Control(pDX, IDC_HL_ADD, m_hlAddCtl); | 121 | DDX_Control(pDX, IDC_HL_ADD, m_hlAddCtl); |
121 | DDX_Control(pDX, IDC_ALL, m_PriAllCtl); | 122 | DDX_Control(pDX, IDC_ALL, m_PriAllCtl); |
122 | DDX_Control(pDX, IDC_SOUND, m_SoundCtl); | 123 | DDX_Control(pDX, IDC_SOUND, m_SoundCtl); |
123 | DDX_Control(pDX, IDC_REMOVE, m_RemoveCtl); | 124 | DDX_Control(pDX, IDC_REMOVE, m_RemoveCtl); |
124 | DDX_Control(pDX, IDC_PLAYSOUND, m_PlaySoundCtl); | 125 | DDX_Control(pDX, IDC_PLAYSOUND, m_PlaySoundCtl); |
125 | DDX_Control(pDX, IDC_LOG, m_Log); | 126 | DDX_Control(pDX, IDC_LOG, m_Log); |
126 | DDX_Control(pDX, IDC_HOSTFILE, m_HFNameCtl); | 127 | DDX_Control(pDX, IDC_HOSTFILE, m_HFNameCtl); |
127 | DDX_Control(pDX, IDC_FACILITY, m_FacilityCtl); | 128 | DDX_Control(pDX, IDC_FACILITY, m_FacilityCtl); |
128 | DDX_Control(pDX, IDC_BROWSE, m_BrowseCtl); | 129 | DDX_Control(pDX, IDC_BROWSE, m_BrowseCtl); |
129 | DDX_Control(pDX, IDC_DESC, m_DescCtl); | 130 | DDX_Control(pDX, IDC_DESC, m_DescCtl); |
130 | DDX_Control(pDX, IDC_TABS, m_Tabs); | 131 | DDX_Control(pDX, IDC_TABS, m_Tabs); |
131 | DDX_Radio(pDX, IDC_TYPE_FILE, m_Logto); | 132 | DDX_Radio(pDX, IDC_TYPE_FILE, m_Logto); |
132 | DDX_Text(pDX, IDC_DESC, m_Desc); | 133 | DDX_Text(pDX, IDC_DESC, m_Desc); |
133 | DDV_MaxChars(pDX, m_Desc, 50); | 134 | DDV_MaxChars(pDX, m_Desc, 50); |
134 | DDX_CBString(pDX, IDC_FACILITY, m_Facility); | 135 | DDX_CBString(pDX, IDC_FACILITY, m_Facility); |
135 | DDX_Text(pDX, IDC_HOSTFILE, m_HFName); | 136 | DDX_Text(pDX, IDC_HOSTFILE, m_HFName); |
136 | DDX_Text(pDX, IDC_HOSTORFILE, m_HFNameCaption); | 137 | DDX_Text(pDX, IDC_HOSTORFILE, m_HFNameCaption); |
@@ -152,73 +153,75 @@ BEGIN_MESSAGE_MAP(CKLogDlg, CDialog) | |||
152 | ON_NOTIFY(TCN_SELCHANGE, IDC_TABS, OnSelchangeTabs) | 153 | ON_NOTIFY(TCN_SELCHANGE, IDC_TABS, OnSelchangeTabs) |
153 | ON_CBN_SELCHANGE(IDC_FACILITY, OnSelchangeFacility) | 154 | ON_CBN_SELCHANGE(IDC_FACILITY, OnSelchangeFacility) |
154 | ON_BN_CLICKED(IDC_ALERT, OnPriority) | 155 | ON_BN_CLICKED(IDC_ALERT, OnPriority) |
155 | ON_BN_CLICKED(IDC_TYPE_FILE, OnLogto) | 156 | ON_BN_CLICKED(IDC_TYPE_FILE, OnLogto) |
156 | ON_BN_CLICKED(IDC_ALL, OnPriAll) | 157 | ON_BN_CLICKED(IDC_ALL, OnPriAll) |
157 | ON_BN_CLICKED(IDC_NONE, OnPriNone) | 158 | ON_BN_CLICKED(IDC_NONE, OnPriNone) |
158 | ON_EN_CHANGE(IDC_DESC, OnChangeDesc) | 159 | ON_EN_CHANGE(IDC_DESC, OnChangeDesc) |
159 | ON_BN_CLICKED(IDC_INVERT, OnPriInvert) | 160 | ON_BN_CLICKED(IDC_INVERT, OnPriInvert) |
160 | ON_BN_CLICKED(IDC_HL_ADD, OnHlAdd) | 161 | ON_BN_CLICKED(IDC_HL_ADD, OnHlAdd) |
161 | ON_LBN_SELCHANGE(IDC_HOSTS, OnSelchangeHosts) | 162 | ON_LBN_SELCHANGE(IDC_HOSTS, OnSelchangeHosts) |
162 | ON_BN_CLICKED(IDC_HL_REMOVE, OnHlRemove) | 163 | ON_BN_CLICKED(IDC_HL_REMOVE, OnHlRemove) |
163 | ON_BN_CLICKED(IDC_REMOVE, OnRemove) | 164 | ON_BN_CLICKED(IDC_REMOVE, OnRemove) |
164 | ON_BN_CLICKED(IDC_PLAYSOUND, OnPlaysound) | 165 | ON_BN_CLICKED(IDC_PLAYSOUND, OnPlaysound) |
165 | ON_CBN_EDITCHANGE(IDC_SOUND, OnEditchangeSound) | 166 | ON_CBN_EDITCHANGE(IDC_SOUND, OnEditchangeSound) |
166 | ON_CBN_KILLFOCUS(IDC_SOUND, OnKillfocusSound) | 167 | ON_CBN_KILLFOCUS(IDC_SOUND, OnKillfocusSound) |
167 | ON_NOTIFY(UDN_DELTAPOS, IDC_LOGLENSPIN, OnDeltaposLoglenspin) | 168 | ON_NOTIFY(UDN_DELTAPOS, IDC_LOGLENSPIN, OnDeltaposLoglenspin) |
168 | ON_BN_CLICKED(IDC_EXIT, OnExit) | 169 | ON_BN_CLICKED(IDC_EXIT, OnExit) |
169 | ON_BN_CLICKED(IDC_FILES, OnFiles) | 170 | ON_BN_CLICKED(IDC_FILES, OnFiles) |
170 | ON_COMMAND(ID_FILES_EXPORT, OnFilesExport) | 171 | ON_COMMAND(ID_FILES_EXPORT, OnFilesExport) |
171 | ON_COMMAND(ID_FILES_IMPORT, OnFilesImport) | 172 | ON_COMMAND(ID_FILES_IMPORT, OnFilesImport) |
172 | ON_BN_CLICKED(IDC_BROWSESOUND, OnBrowsesound) | 173 | ON_BN_CLICKED(IDC_BROWSESOUND, OnBrowsesound) |
173 | ON_EN_KILLFOCUS(IDC_HOSTFILE, OnKillfocusHostfile) | 174 | ON_EN_KILLFOCUS(IDC_HOSTFILE, OnKillfocusHostfile) |
174 | ON_BN_CLICKED(IDC_BROWSE, OnBrowse) | 175 | ON_BN_CLICKED(IDC_BROWSE, OnBrowse) |
175 | ON_COMMAND(ID_FILES_RESET, OnFilesReset) | 176 | ON_COMMAND(ID_FILES_RESET, OnFilesReset) |
176 | ON_LBN_SELCHANGE(IDC_LOG, OnSelchangeLog) | 177 | ON_LBN_SELCHANGE(IDC_LOG, OnSelchangeLog) |
177 | ON_WM_CREATE() | 178 | ON_WM_CREATE() |
178 | ON_WM_CLOSE() | 179 | ON_WM_CLOSE() |
179 | ON_COMMAND(ID_TRAY_ABOUTKLOG, OnTrayAboutklog) | 180 | ON_COMMAND(ID_TRAY_ABOUTKLOG, OnTrayAboutklog) |
180 | ON_COMMAND(ID_TRAY_EXIT, OnTrayExit) | 181 | ON_COMMAND(ID_TRAY_EXIT, OnTrayExit) |
181 | ON_COMMAND(ID_TRAY_SHOWKLOGWINDOW, OnTrayShowklogwindow) | 182 | ON_COMMAND(ID_TRAY_SHOWKLOGWINDOW, OnTrayShowklogwindow) |
182 | ON_WM_WINDOWPOSCHANGING() | 183 | ON_WM_WINDOWPOSCHANGING() |
183 | ON_BN_CLICKED(IDC_LOGPATTERN, OnLogpattern) | 184 | ON_BN_CLICKED(IDC_LOGPATTERN, OnLogpattern) |
185 | ON_WM_GETMINMAXINFO() | ||
184 | ON_BN_CLICKED(IDC_CRIT, OnPriority) | 186 | ON_BN_CLICKED(IDC_CRIT, OnPriority) |
185 | ON_BN_CLICKED(IDC_DEBUG, OnPriority) | 187 | ON_BN_CLICKED(IDC_DEBUG, OnPriority) |
186 | ON_BN_CLICKED(IDC_EMERG, OnPriority) | 188 | ON_BN_CLICKED(IDC_EMERG, OnPriority) |
187 | ON_BN_CLICKED(IDC_ERR, OnPriority) | 189 | ON_BN_CLICKED(IDC_ERR, OnPriority) |
188 | ON_BN_CLICKED(IDC_INFO, OnPriority) | 190 | ON_BN_CLICKED(IDC_INFO, OnPriority) |
189 | ON_BN_CLICKED(IDC_NOTICE, OnPriority) | 191 | ON_BN_CLICKED(IDC_NOTICE, OnPriority) |
190 | ON_BN_CLICKED(IDC_WARNING, OnPriority) | 192 | ON_BN_CLICKED(IDC_WARNING, OnPriority) |
191 | ON_BN_CLICKED(IDC_TYPE_HOST, OnLogto) | 193 | ON_BN_CLICKED(IDC_TYPE_HOST, OnLogto) |
192 | ON_BN_CLICKED(IDC_TYPE_NONE, OnLogto) | 194 | ON_BN_CLICKED(IDC_TYPE_NONE, OnLogto) |
195 | ON_WM_SIZE() | ||
193 | //}}AFX_MSG_MAP | 196 | //}}AFX_MSG_MAP |
194 | END_MESSAGE_MAP() | 197 | END_MESSAGE_MAP() |
195 | 198 | ||
196 | ///////////////////////////////////////////////////////////////////////////// | 199 | ///////////////////////////////////////////////////////////////////////////// |
197 | // CKLogDlg message handlers | 200 | // CKLogDlg message handlers |
198 | 201 | ||
199 | BOOL CKLogDlg::OnInitDialog() | 202 | BOOL CKLogDlg::OnInitDialog() |
200 | { | 203 | { |
201 | CDialog::OnInitDialog(); | 204 | CDialog::OnInitDialog(); |
202 | 205 | ||
203 | // Add "About..." menu item to system menu. | 206 | // Add "About..." menu item to system menu. |
204 | 207 | ||
205 | // IDM_ABOUTBOX must be in the system command range. | 208 | // IDM_ABOUTBOX must be in the system command range. |
206 | ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); | 209 | ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); |
207 | ASSERT(IDM_ABOUTBOX < 0xF000); | 210 | ASSERT(IDM_ABOUTBOX < 0xF000); |
208 | 211 | ||
209 | CMenu* pSysMenu = GetSystemMenu(FALSE); | 212 | CMenu* pSysMenu = GetSystemMenu(FALSE); |
210 | CString strAboutMenu; | 213 | CString strAboutMenu; |
211 | strAboutMenu.LoadString(IDS_ABOUTBOX); | 214 | strAboutMenu.LoadString(IDS_ABOUTBOX); |
212 | if (!strAboutMenu.IsEmpty()) | 215 | if (!strAboutMenu.IsEmpty()) |
213 | { | 216 | { |
214 | pSysMenu->AppendMenu(MF_SEPARATOR); | 217 | pSysMenu->AppendMenu(MF_SEPARATOR); |
215 | pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); | 218 | pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); |
216 | } | 219 | } |
217 | 220 | ||
218 | // Set the icon for this dialog. The framework does this automatically | 221 | // Set the icon for this dialog. The framework does this automatically |
219 | // when the application's main window is not a dialog | 222 | // when the application's main window is not a dialog |
220 | SetIcon(m_hIcon, TRUE); // Set big icon | 223 | SetIcon(m_hIcon, TRUE); // Set big icon |
221 | SetIcon(m_hIcon, FALSE); // Set small icon | 224 | SetIcon(m_hIcon, FALSE); // Set small icon |
222 | 225 | ||
223 | m_KLS.m_Daddy=this; | 226 | m_KLS.m_Daddy=this; |
224 | VERIFY(m_KLS.CreateListen()); | 227 | VERIFY(m_KLS.CreateListen()); |
@@ -1336,32 +1339,59 @@ CLogPattern lp(IDS_LOGPATTERN_TITLE,this); | |||
1336 | UpdatePriface(FALSE,TRUE); | 1339 | UpdatePriface(FALSE,TRUE); |
1337 | } | 1340 | } |
1338 | } | 1341 | } |
1339 | 1342 | ||
1340 | void CLogger::LookupHost(CKLogDlg *daddy) | 1343 | void CLogger::LookupHost(CKLogDlg *daddy) |
1341 | { | 1344 | { |
1342 | m_LogToHost.sin_addr.s_addr=inet_addr((LPCTSTR)m_LogToName); | 1345 | m_LogToHost.sin_addr.s_addr=inet_addr((LPCTSTR)m_LogToName); |
1343 | if(m_LogToHost.sin_addr.s_addr==INADDR_NONE){ | 1346 | if(m_LogToHost.sin_addr.s_addr==INADDR_NONE){ |
1344 | if(daddy->m_bWarnBlocking){ | 1347 | if(daddy->m_bWarnBlocking){ |
1345 | CWarnBlocking wb(::IsWindow(daddy->m_hWnd)?daddy:NULL); | 1348 | CWarnBlocking wb(::IsWindow(daddy->m_hWnd)?daddy:NULL); |
1346 | wb.m_bDontWarn = daddy->m_bDontWarn; | 1349 | wb.m_bDontWarn = daddy->m_bDontWarn; |
1347 | if(wb.DoModal()!=IDOK) | 1350 | if(wb.DoModal()!=IDOK) |
1348 | return; | 1351 | return; |
1349 | daddy->m_bDontWarn=wb.m_bDontWarn; | 1352 | daddy->m_bDontWarn=wb.m_bDontWarn; |
1350 | daddy->m_bWarnBlocking=!wb.m_bDontWarn; | 1353 | daddy->m_bWarnBlocking=!wb.m_bDontWarn; |
1351 | } | 1354 | } |
1352 | daddy->BeginWaitCursor(); | 1355 | daddy->BeginWaitCursor(); |
1353 | hostent *he = gethostbyname(m_LogToName); | 1356 | hostent *he = gethostbyname(m_LogToName); |
1354 | daddy->EndWaitCursor(); | 1357 | daddy->EndWaitCursor(); |
1355 | if(he){ | 1358 | if(he){ |
1356 | m_LogToHost.sin_addr.s_addr = *(DWORD*)he->h_addr; | 1359 | m_LogToHost.sin_addr.s_addr = *(DWORD*)he->h_addr; |
1357 | }else{ | 1360 | }else{ |
1358 | m_LogToHost.sin_addr.s_addr = INADDR_NONE; | 1361 | m_LogToHost.sin_addr.s_addr = INADDR_NONE; |
1359 | if(daddy->m_bWarnBlocking){ | 1362 | if(daddy->m_bWarnBlocking){ |
1360 | CString sux; | 1363 | CString sux; |
1361 | sux.Format(IDS_MSG_LOOKUPFAILED,(LPCTSTR)m_LogToName); | 1364 | sux.Format(IDS_MSG_LOOKUPFAILED,(LPCTSTR)m_LogToName); |
1362 | daddy->MessageBox(sux,NULL,MB_ICONSTOP|MB_OK); | 1365 | daddy->MessageBox(sux,NULL,MB_ICONSTOP|MB_OK); |
1363 | }else | 1366 | }else |
1364 | MessageBeep(MB_ICONHAND); | 1367 | MessageBeep(MB_ICONHAND); |
1365 | } | 1368 | } |
1366 | } | 1369 | } |
1367 | } | 1370 | } |
1371 | |||
1372 | void CKLogDlg::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) | ||
1373 | { | ||
1374 | CDialog::OnGetMinMaxInfo(lpMMI); | ||
1375 | WINDOWPLACEMENT wp; | ||
1376 | if(IsWindow(m_CancelCtl.m_hWnd) && m_CancelCtl.GetWindowPlacement(&wp)) { | ||
1377 | CRect wr; GetWindowRect(wr); | ||
1378 | CRect cr; GetClientRect(cr); | ||
1379 | CSize ncs = (wr-cr).Size(); | ||
1380 | CRect ctlr = wp.rcNormalPosition; | ||
1381 | CSize corner = ctlr.BottomRight()+ncs; | ||
1382 | lpMMI->ptMaxTrackSize.x = lpMMI->ptMinTrackSize.x = corner.cx; | ||
1383 | lpMMI->ptMinTrackSize.y = corner.cy; | ||
1384 | } | ||
1385 | } | ||
1386 | |||
1387 | void CKLogDlg::OnSize(UINT nType, int cx, int cy) | ||
1388 | { | ||
1389 | CDialog::OnSize(nType, cx, cy); | ||
1390 | if(!IsWindow(m_Log.m_hWnd)) | ||
1391 | return; | ||
1392 | WINDOWPLACEMENT lp; m_Log.GetWindowPlacement(&lp); | ||
1393 | CRect lr = lp.rcNormalPosition; | ||
1394 | lr.bottom = cy-2; | ||
1395 | CSize ls = lr.Size(); | ||
1396 | m_Log.SetWindowPos(0,0,0,ls.cx,ls.cy,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOZORDER); | ||
1397 | } | ||