Develop and Download Open Source Software

Browse Subversion Repository

Contents of /trunk/teraterm/teraterm/addsetting.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3227 - (hide annotations) (download) (as text)
Tue Mar 24 15:10:33 2009 UTC (5 years, 7 months ago) by maya
File MIME type: text/x-c++src
File size: 47604 byte(s)
CVS から SVN へ移行: 改行コードを LF から CR+LF へ変換
1 maya 3227 /*
2     * Additional settings dialog
3     */
4    
5     #include <afxwin.h>
6     #include <afxdlgs.h>
7     #include <afxcmn.h>
8     #include <commctrl.h>
9    
10     #include "addsetting.h"
11     #include "teraterm.h"
12     #include "tttypes.h"
13     #include "ttwinman.h"
14    
15     mouse_cursor_t MouseCursor[] = {
16     {"ARROW", IDC_ARROW},
17     {"IBEAM", IDC_IBEAM},
18     {"CROSS", IDC_CROSS},
19     {"HAND", IDC_HAND},
20     {NULL, NULL},
21     };
22     #define MOUSE_CURSOR_MAX (sizeof(MouseCursor)/sizeof(MouseCursor[0]) - 1)
23    
24     // 本体は vtwin.cpp
25     extern void SetWindowStyle(TTTSet *ts);
26    
27     void split_buffer(char *buffer, int delimiter, char **head, char **body)
28     {
29     char *p1, *p2;
30    
31     *head = *body = NULL;
32    
33     if (!isalnum(*buffer) || (p1 = strchr(buffer, delimiter)) == NULL) {
34     return;
35     }
36    
37     *head = buffer;
38    
39     p2 = buffer;
40     while (p2 < p1 && !isspace(*p2)) {
41     p2++;
42     }
43    
44     *p2 = '\0';
45    
46     p1++;
47     while (*p1 && isspace(*p1)) {
48     p1++;
49     }
50    
51     *body = p1;
52     }
53    
54    
55     static void SetupRGBbox(HWND hDlgWnd, int index)
56     {
57     HWND hWnd;
58     BYTE c;
59     char buf[10];
60    
61     hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_RED);
62     c = GetRValue(ts.ANSIColor[index]);
63     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", c);
64     SendMessage(hWnd, WM_SETTEXT , 0, (LPARAM)buf);
65    
66     hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_GREEN);
67     c = GetGValue(ts.ANSIColor[index]);
68     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", c);
69     SendMessage(hWnd, WM_SETTEXT , 0, (LPARAM)buf);
70    
71     hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_BLUE);
72     c = GetBValue(ts.ANSIColor[index]);
73     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", c);
74     SendMessage(hWnd, WM_SETTEXT , 0, (LPARAM)buf);
75     }
76    
77    
78    
79     // CGeneralPropPageDlg ダイアログ
80    
81     IMPLEMENT_DYNAMIC(CGeneralPropPageDlg, CPropertyPage)
82    
83     CGeneralPropPageDlg::CGeneralPropPageDlg()
84     : CPropertyPage(CGeneralPropPageDlg::IDD)
85     {
86     }
87    
88     CGeneralPropPageDlg::~CGeneralPropPageDlg()
89     {
90     if (DlgGeneralFont != NULL) {
91     DeleteObject(DlgGeneralFont);
92     }
93     }
94    
95     BEGIN_MESSAGE_MAP(CGeneralPropPageDlg, CPropertyPage)
96     END_MESSAGE_MAP()
97    
98     // CGeneralPropPageDlg メッセージ ハンドラ
99    
100     BOOL CGeneralPropPageDlg::OnInitDialog()
101     {
102     char uimsg[MAX_UIMSG];
103     char buf[64];
104     CButton *btn, *btn2;
105     CComboBox *cmb;
106    
107     CPropertyPage::OnInitDialog();
108    
109     font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
110     GetObject(font, sizeof(LOGFONT), &logfont);
111     if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgGeneralFont, ts.UILanguageFile)) {
112     SendDlgItemMessage(IDC_CLICKABLE_URL, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
113     SendDlgItemMessage(IDC_DISABLE_SENDBREAK, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
114     SendDlgItemMessage(IDC_ACCEPT_BROADCAST, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0)); // 337: 2007/03/20
115     SendDlgItemMessage(IDC_MOUSEWHEEL_SCROLL_LINE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
116     SendDlgItemMessage(IDC_SCROLL_LINE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
117     SendDlgItemMessage(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
118     SendDlgItemMessage(IDC_ACCEPT_MOUSE_EVENT_TRACKING, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
119     SendDlgItemMessage(IDC_DISABLE_MOUSE_TRACKING_CTRL, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
120     SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING_LABEL, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
121     SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, WM_SETFONT, (WPARAM)DlgGeneralFont, MAKELPARAM(TRUE,0));
122     }
123     else {
124     DlgGeneralFont = NULL;
125     }
126    
127     GetDlgItemText(IDC_CLICKABLE_URL, uimsg, sizeof(uimsg));
128     get_lang_msg("DLG_TAB_GENERAL_CLICKURL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
129     SetDlgItemText(IDC_CLICKABLE_URL, ts.UIMsg);
130     GetDlgItemText(IDC_DISABLE_SENDBREAK, uimsg, sizeof(uimsg));
131     get_lang_msg("DLG_TAB_GENERAL_DISABLESENDBREAK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
132     SetDlgItemText(IDC_DISABLE_SENDBREAK, ts.UIMsg);
133     GetDlgItemText(IDC_ACCEPT_BROADCAST, uimsg, sizeof(uimsg));
134     get_lang_msg("DLG_TAB_GENERAL_ACCEPTBROADCAST", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
135     SetDlgItemText(IDC_ACCEPT_BROADCAST, ts.UIMsg);
136     GetDlgItemText(IDC_MOUSEWHEEL_SCROLL_LINE, uimsg, sizeof(uimsg));
137     get_lang_msg("DLG_TAB_GENERAL_MOUSEWHEEL_SCROLL_LINE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
138     SetDlgItemText(IDC_MOUSEWHEEL_SCROLL_LINE, ts.UIMsg);
139     GetDlgItemText(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, uimsg, sizeof(uimsg));
140     get_lang_msg("DLG_TAB_GENERAL_AUTOSCROLL_ONLY_IN_BOTTOM_LINE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
141     SetDlgItemText(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE, ts.UIMsg);
142     GetDlgItemText(IDC_ACCEPT_MOUSE_EVENT_TRACKING, uimsg, sizeof(uimsg));
143     get_lang_msg("DLG_TAB_GENERAL_ACCEPT_MOUSE_EVENT_TRACKING", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
144     SetDlgItemText(IDC_ACCEPT_MOUSE_EVENT_TRACKING, ts.UIMsg);
145     GetDlgItemText(IDC_DISABLE_MOUSE_TRACKING_CTRL, uimsg, sizeof(uimsg));
146     get_lang_msg("DLG_TAB_GENERAL_DISABLE_MOUSE_TRACKING_CTRL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
147     SetDlgItemText(IDC_DISABLE_MOUSE_TRACKING_CTRL, ts.UIMsg);
148     GetDlgItemText(IDC_ACCEPT_TITLE_CHANGING_LABEL, uimsg, sizeof(uimsg));
149     get_lang_msg("DLG_TAB_GENERAL_ACCEPT_TITLE_CHANGING", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
150     SetDlgItemText(IDC_ACCEPT_TITLE_CHANGING_LABEL, ts.UIMsg);
151    
152     get_lang_msg("DLG_TAB_GENERAL_ACCEPT_TITLE_CHANGING_OFF", ts.UIMsg, sizeof(ts.UIMsg), "off", ts.UILanguageFile);
153     SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
154     get_lang_msg("DLG_TAB_GENERAL_ACCEPT_TITLE_CHANGING_OVERWRITE", ts.UIMsg, sizeof(ts.UIMsg), "overwrite", ts.UILanguageFile);
155     SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
156     get_lang_msg("DLG_TAB_GENERAL_ACCEPT_TITLE_CHANGING_AHEAD", ts.UIMsg, sizeof(ts.UIMsg), "ahead", ts.UILanguageFile);
157     SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
158     get_lang_msg("DLG_TAB_GENERAL_ACCEPT_TITLE_CHANGING_LAST", ts.UIMsg, sizeof(ts.UIMsg), "last", ts.UILanguageFile);
159     SendDlgItemMessage(IDC_ACCEPT_TITLE_CHANGING, CB_ADDSTRING, 0, (LPARAM)ts.UIMsg);
160    
161    
162     // (1)DisableAcceleratorSendBreak
163     btn = (CButton *)GetDlgItem(IDC_DISABLE_SENDBREAK);
164     btn->SetCheck(ts.DisableAcceleratorSendBreak);
165    
166     // (2)EnableClickableUrl
167     btn = (CButton *)GetDlgItem(IDC_CLICKABLE_URL);
168     btn->SetCheck(ts.EnableClickableUrl);
169    
170     // (3)AcceptBroadcast 337: 2007/03/20
171     btn = (CButton *)GetDlgItem(IDC_ACCEPT_BROADCAST);
172     btn->SetCheck(ts.AcceptBroadcast);
173    
174     // (4)IDC_MOUSEWHEEL_SCROLL_LINE
175     _snprintf_s(buf, sizeof(buf), "%d", ts.MouseWheelScrollLine);
176     SetDlgItemText(IDC_SCROLL_LINE, buf);
177    
178     // (5)IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE
179     btn = (CButton *)GetDlgItem(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE);
180     btn->SetCheck(ts.AutoScrollOnlyInBottomLine);
181    
182     // (6)IDC_ACCEPT_MOUSE_EVENT_TRACKING
183     btn = (CButton *)GetDlgItem(IDC_ACCEPT_MOUSE_EVENT_TRACKING);
184     btn2 = (CButton *)GetDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL);
185     btn->SetCheck(ts.MouseEventTracking);
186     if (ts.MouseEventTracking) {
187     btn2->EnableWindow(TRUE);
188     } else {
189     btn2->EnableWindow(FALSE);
190     }
191    
192     // (7)IDC_DISABLE_MOUSE_TRACKING_CTRL
193     btn2->SetCheck(ts.DisableMouseTrackingByCtrl);
194    
195     // (8)IDC_ACCEPT_TITLE_CHANGING
196     cmb = (CComboBox *)GetDlgItem(IDC_ACCEPT_TITLE_CHANGING);
197     cmb->SetCurSel(ts.AcceptTitleChangeRequest);
198    
199     // ダイアログにフォーカスを当てる (2004.12.7 yutaka)
200     ::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_CLICKABLE_URL));
201    
202     return FALSE;
203     }
204    
205     BOOL CGeneralPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
206     {
207     CButton *btn, *btn2;
208    
209     switch (wParam) {
210     case IDC_ACCEPT_MOUSE_EVENT_TRACKING | (BN_CLICKED << 16):
211     btn = (CButton *)GetDlgItem(IDC_ACCEPT_MOUSE_EVENT_TRACKING);
212     btn2 = (CButton *)GetDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL);
213     if (btn->GetCheck()) {
214     btn2->EnableWindow(TRUE);
215     } else {
216     btn2->EnableWindow(FALSE);
217     }
218     return TRUE;
219     }
220     return CPropertyPage::OnCommand(wParam, lParam);
221     }
222    
223     void CGeneralPropPageDlg::OnOK()
224     {
225     CButton *btn;
226     CComboBox *cmb;
227     char buf[64];
228     int val;
229    
230     // (1)
231     btn = (CButton *)GetDlgItem(IDC_DISABLE_SENDBREAK);
232     ts.DisableAcceleratorSendBreak = btn->GetCheck();
233    
234     // (2)
235     btn = (CButton *)GetDlgItem(IDC_CLICKABLE_URL);
236     ts.EnableClickableUrl = btn->GetCheck();
237    
238     // (3) 337: 2007/03/20
239     btn = (CButton *)GetDlgItem(IDC_ACCEPT_BROADCAST);
240     ts.AcceptBroadcast = btn->GetCheck();
241    
242     // (4)IDC_MOUSEWHEEL_SCROLL_LINE
243     GetDlgItemText(IDC_SCROLL_LINE, buf, sizeof(buf));
244     val = atoi(buf);
245     if (val > 0)
246     ts.MouseWheelScrollLine = val;
247    
248     // (5)IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE
249     btn = (CButton *)GetDlgItem(IDC_AUTOSCROLL_ONLY_IN_BOTTOM_LINE);
250     ts.AutoScrollOnlyInBottomLine = btn->GetCheck();
251    
252     // (6)IDC_ACCEPT_MOUSE_EVENT_TRACKING
253     btn = (CButton *)GetDlgItem(IDC_ACCEPT_MOUSE_EVENT_TRACKING);
254     ts.MouseEventTracking = btn->GetCheck();
255    
256     // (7)IDC_DISABLE_MOUSE_TRACKING_CTRL
257     btn = (CButton *)GetDlgItem(IDC_DISABLE_MOUSE_TRACKING_CTRL);
258     ts.DisableMouseTrackingByCtrl = btn->GetCheck();
259    
260     // (8)IDC_ACCEPT_TITLE_CHANGING
261     cmb = (CComboBox *)GetDlgItem(IDC_ACCEPT_TITLE_CHANGING);
262     ts.AcceptTitleChangeRequest = cmb->GetCurSel();
263     }
264    
265    
266    
267     // CCopypastePropPageDlg ダイアログ
268    
269     IMPLEMENT_DYNAMIC(CCopypastePropPageDlg, CPropertyPage)
270    
271     CCopypastePropPageDlg::CCopypastePropPageDlg()
272     : CPropertyPage(CCopypastePropPageDlg::IDD)
273     {
274     }
275    
276     CCopypastePropPageDlg::~CCopypastePropPageDlg()
277     {
278     if (DlgCopypasteFont != NULL) {
279     DeleteObject(DlgCopypasteFont);
280     }
281     }
282    
283     BEGIN_MESSAGE_MAP(CCopypastePropPageDlg, CPropertyPage)
284     END_MESSAGE_MAP()
285    
286     // CCopypastePropPageDlg メッセージ ハンドラ
287    
288     BOOL CCopypastePropPageDlg::OnInitDialog()
289     {
290     char uimsg[MAX_UIMSG];
291     CButton *btn, *btn2;
292    
293     CPropertyPage::OnInitDialog();
294    
295     font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
296     GetObject(font, sizeof(LOGFONT), &logfont);
297     if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgCopypasteFont, ts.UILanguageFile)) {
298     SendDlgItemMessage(IDC_LINECOPY, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
299     SendDlgItemMessage(IDC_DISABLE_PASTE_RBUTTON, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
300     SendDlgItemMessage(IDC_CONFIRM_PASTE_RBUTTON, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
301     SendDlgItemMessage(IDC_SELECT_LBUTTON, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
302     SendDlgItemMessage(IDC_CONFIRM_CHANGE_PASTE, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
303     SendDlgItemMessage(IDC_DELIMITER, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
304     SendDlgItemMessage(IDC_DELIM_LIST, WM_SETFONT, (WPARAM)DlgCopypasteFont, MAKELPARAM(TRUE,0));
305     }
306     else {
307     DlgCopypasteFont = NULL;
308     }
309    
310     GetDlgItemText(IDC_LINECOPY, uimsg, sizeof(uimsg));
311     get_lang_msg("DLG_TAB_COPYPASTE_CONTINUE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
312     SetDlgItemText(IDC_LINECOPY, ts.UIMsg);
313     GetDlgItemText(IDC_DISABLE_PASTE_RBUTTON, uimsg, sizeof(uimsg));
314     get_lang_msg("DLG_TAB_COPYPASTE_MOUSEPASTE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
315     SetDlgItemText(IDC_DISABLE_PASTE_RBUTTON, ts.UIMsg);
316     GetDlgItemText(IDC_CONFIRM_PASTE_RBUTTON, uimsg, sizeof(uimsg));
317     get_lang_msg("DLG_TAB_COPYPASTE_CONFIRMPASTE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
318     SetDlgItemText(IDC_CONFIRM_PASTE_RBUTTON, ts.UIMsg);
319     GetDlgItemText(IDC_SELECT_LBUTTON, uimsg, sizeof(uimsg));
320     get_lang_msg("DLG_TAB_COPYPASTE_SELECTLBUTTON", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
321     SetDlgItemText(IDC_SELECT_LBUTTON, ts.UIMsg);
322     GetDlgItemText(IDC_CONFIRM_CHANGE_PASTE, uimsg, sizeof(uimsg));
323     get_lang_msg("DLG_TAB_COPYPASTE_CONFIRM_CHANGE_PASTE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
324     SetDlgItemText(IDC_CONFIRM_CHANGE_PASTE, ts.UIMsg);
325     GetDlgItemText(IDC_DELIMITER, uimsg, sizeof(uimsg));
326     get_lang_msg("DLG_TAB_COPYPASTE_DELIMITER", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
327     SetDlgItemText(IDC_DELIMITER, ts.UIMsg);
328    
329     // (1)Enable continued-line copy
330     btn = (CButton *)GetDlgItem(IDC_LINECOPY);
331     btn->SetCheck(ts.EnableContinuedLineCopy);
332    
333     // (2)DisablePasteMouseRButton
334     btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_RBUTTON);
335     btn2 = (CButton *)GetDlgItem(IDC_CONFIRM_PASTE_RBUTTON);
336     btn->SetCheck(ts.DisablePasteMouseRButton);
337     if (ts.DisablePasteMouseRButton) {
338     btn2->EnableWindow(FALSE);
339     } else {
340     btn2->EnableWindow(TRUE);
341     }
342    
343     // (3)ConfirmPasteMouseRButton
344     btn2->SetCheck(ts.ConfirmPasteMouseRButton);
345    
346     // (4)SelectOnlyByLButton
347     btn = (CButton *)GetDlgItem(IDC_SELECT_LBUTTON);
348     btn->SetCheck(ts.SelectOnlyByLButton);
349    
350     // (5)ConfirmChangePaste
351     btn = (CButton *)GetDlgItem(IDC_CONFIRM_CHANGE_PASTE);
352     btn->SetCheck(ts.ConfirmChangePaste);
353    
354     // (6)delimiter characters
355     SetDlgItemText(IDC_DELIM_LIST, ts.DelimList);
356    
357    
358     // ダイアログにフォーカスを当てる
359     ::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_LINECOPY));
360    
361     return FALSE;
362     }
363    
364     BOOL CCopypastePropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
365     {
366     CButton *btn, *btn2;
367    
368     switch (wParam) {
369     case IDC_DISABLE_PASTE_RBUTTON | (BN_CLICKED << 16):
370     btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_RBUTTON);
371     btn2 = (CButton *)GetDlgItem(IDC_CONFIRM_PASTE_RBUTTON);
372     if (btn->GetCheck()) {
373     btn2->EnableWindow(FALSE);
374     } else {
375     btn2->EnableWindow(TRUE);
376     }
377     return TRUE;
378     }
379    
380     return CPropertyPage::OnCommand(wParam, lParam);
381     }
382    
383     void CCopypastePropPageDlg::OnOK()
384     {
385     CButton *btn;
386    
387     // (1)
388     btn = (CButton *)GetDlgItem(IDC_LINECOPY);
389     ts.EnableContinuedLineCopy = btn->GetCheck();
390    
391     // (2)
392     btn = (CButton *)GetDlgItem(IDC_DISABLE_PASTE_RBUTTON);
393     ts.DisablePasteMouseRButton = btn->GetCheck();
394    
395     // (3)
396     btn = (CButton *)GetDlgItem(IDC_CONFIRM_PASTE_RBUTTON);
397     ts.ConfirmPasteMouseRButton = btn->GetCheck();
398    
399     // (4)
400     btn = (CButton *)GetDlgItem(IDC_SELECT_LBUTTON);
401     ts.SelectOnlyByLButton = btn->GetCheck();
402    
403     // (5)IDC_CONFIRM_CHANGE_PASTE
404     btn = (CButton *)GetDlgItem(IDC_CONFIRM_CHANGE_PASTE);
405     ts.ConfirmChangePaste = btn->GetCheck();
406    
407     // (6)
408     GetDlgItemText(IDC_DELIM_LIST, ts.DelimList, sizeof(ts.DelimList));
409     }
410    
411    
412    
413     // CVisualPropPageDlg ダイアログ
414    
415     IMPLEMENT_DYNAMIC(CVisualPropPageDlg, CPropertyPage)
416    
417     CVisualPropPageDlg::CVisualPropPageDlg()
418     : CPropertyPage(CVisualPropPageDlg::IDD)
419     {
420    
421     }
422    
423     CVisualPropPageDlg::~CVisualPropPageDlg()
424     {
425     if (DlgVisualFont != NULL) {
426     DeleteObject(DlgVisualFont);
427     }
428     }
429    
430     BEGIN_MESSAGE_MAP(CVisualPropPageDlg, CPropertyPage)
431     END_MESSAGE_MAP()
432    
433     // CVisualPropPageDlg メッセージ ハンドラ
434    
435     BOOL CVisualPropPageDlg::OnInitDialog()
436     {
437     char buf[MAXPATHLEN];
438     char uimsg[MAX_UIMSG];
439     CListBox *listbox;
440     CButton *btn;
441     int i;
442    
443     CPropertyPage::OnInitDialog();
444    
445     font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
446     GetObject(font, sizeof(LOGFONT), &logfont);
447     if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgVisualFont, ts.UILanguageFile)) {
448     SendDlgItemMessage(IDC_ALPHABLEND, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
449     SendDlgItemMessage(IDC_ALPHA_BLEND, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
450     SendDlgItemMessage(IDC_ETERM_LOOKFEEL, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
451     SendDlgItemMessage(IDC_MOUSE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
452     SendDlgItemMessage(IDC_MOUSE_CURSOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
453     SendDlgItemMessage(IDC_ANSICOLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
454     SendDlgItemMessage(IDC_ANSI_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
455     SendDlgItemMessage(IDC_RED, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
456     SendDlgItemMessage(IDC_COLOR_RED, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
457     SendDlgItemMessage(IDC_GREEN, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
458     SendDlgItemMessage(IDC_COLOR_GREEN, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
459     SendDlgItemMessage(IDC_BLUE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
460     SendDlgItemMessage(IDC_COLOR_BLUE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
461     SendDlgItemMessage(IDC_SAMPLE_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
462     SendDlgItemMessage(IDC_ENABLE_ATTR_COLOR_BOLD, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
463     SendDlgItemMessage(IDC_ENABLE_ATTR_COLOR_BLINK, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
464     SendDlgItemMessage(IDC_ENABLE_ATTR_COLOR_REVERSE, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
465     SendDlgItemMessage(IDC_ENABLE_URL_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
466     SendDlgItemMessage(IDC_ENABLE_ANSI_COLOR, WM_SETFONT, (WPARAM)DlgVisualFont, MAKELPARAM(TRUE,0));
467     }
468     else {
469     DlgVisualFont = NULL;
470     }
471    
472     GetDlgItemText(IDC_ALPHABLEND, uimsg, sizeof(uimsg));
473     get_lang_msg("DLG_TAB_VISUAL_ALHPA", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
474     SetDlgItemText(IDC_ALPHABLEND, ts.UIMsg);
475     GetDlgItemText(IDC_ETERM_LOOKFEEL, uimsg, sizeof(uimsg));
476     get_lang_msg("DLG_TAB_VISUAL_ETERM", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
477     SetDlgItemText(IDC_ETERM_LOOKFEEL, ts.UIMsg);
478     GetDlgItemText(IDC_MOUSE, uimsg, sizeof(uimsg));
479     get_lang_msg("DLG_TAB_VISUAL_MOUSE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
480     SetDlgItemText(IDC_MOUSE, ts.UIMsg);
481     GetDlgItemText(IDC_RED, uimsg, sizeof(uimsg));
482     get_lang_msg("DLG_TAB_VISUAL_RED", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
483     SetDlgItemText(IDC_RED, ts.UIMsg);
484     GetDlgItemText(IDC_GREEN, uimsg, sizeof(uimsg));
485     get_lang_msg("DLG_TAB_VISUAL_GREEN", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
486     SetDlgItemText(IDC_GREEN, ts.UIMsg);
487     GetDlgItemText(IDC_BLUE, uimsg, sizeof(uimsg));
488     get_lang_msg("DLG_TAB_VISUAL_BLUE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
489     SetDlgItemText(IDC_BLUE, ts.UIMsg);
490     GetDlgItemText(IDC_ENABLE_ATTR_COLOR_BOLD, uimsg, sizeof(uimsg));
491     get_lang_msg("DLG_TAB_VISUAL_BOLD", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
492     SetDlgItemText(IDC_ENABLE_ATTR_COLOR_BOLD, ts.UIMsg);
493     GetDlgItemText(IDC_ENABLE_ATTR_COLOR_BLINK, uimsg, sizeof(uimsg));
494     get_lang_msg("DLG_TAB_VISUAL_BLINK", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
495     SetDlgItemText(IDC_ENABLE_ATTR_COLOR_BLINK, ts.UIMsg);
496     GetDlgItemText(IDC_ENABLE_ATTR_COLOR_REVERSE, uimsg, sizeof(uimsg));
497     get_lang_msg("DLG_TAB_VISUAL_REVERSE", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
498     SetDlgItemText(IDC_ENABLE_ATTR_COLOR_REVERSE, ts.UIMsg);
499     GetDlgItemText(IDC_ENABLE_URL_COLOR, uimsg, sizeof(uimsg));
500     get_lang_msg("DLG_TAB_VISUAL_URL", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
501     SetDlgItemText(IDC_ENABLE_URL_COLOR, ts.UIMsg);
502     GetDlgItemText(IDC_ENABLE_ANSI_COLOR, uimsg, sizeof(uimsg));
503     get_lang_msg("DLG_TAB_VISUAL_ANSI", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
504     SetDlgItemText(IDC_ENABLE_ANSI_COLOR, ts.UIMsg);
505    
506     // (1)AlphaBlend
507     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", ts.AlphaBlend);
508     SetDlgItemText(IDC_ALPHA_BLEND, buf);
509    
510     // (2)[BG] BGEnable
511     btn = (CButton *)GetDlgItem(IDC_ETERM_LOOKFEEL);
512     btn->SetCheck(ts.EtermLookfeel.BGEnable);
513    
514     // (3)Mouse cursor type
515     listbox = (CListBox *)GetDlgItem(IDC_MOUSE_CURSOR);
516     for (i = 0 ; MouseCursor[i].name ; i++) {
517     listbox->InsertString(i, MouseCursor[i].name);
518     }
519     listbox->SelectString(0, ts.MouseCursorName);
520    
521     // (4)ANSI color
522     listbox = (CListBox *)GetDlgItem(IDC_ANSI_COLOR);
523     for (i = 0 ; i < 16 ; i++) {
524     _snprintf_s(buf, sizeof(buf), _TRUNCATE, "%d", i);
525     listbox->InsertString(i, buf);
526     }
527     SetupRGBbox(GetSafeHwnd(), 0);
528     #if 0
529     SendMessage(WM_CTLCOLORSTATIC,
530     (WPARAM)label_hdc,
531     (LPARAM)GetDlgItem(IDC_SAMPLE_COLOR));
532     #endif
533    
534     // (5)Bold Attr Color
535     btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BOLD);
536     btn->SetCheck((ts.ColorFlag&CF_BOLDCOLOR) != 0);
537    
538     // (6)Blink Attr Color
539     btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BLINK);
540     btn->SetCheck((ts.ColorFlag&CF_BLINKCOLOR) != 0);
541    
542     // (7)Reverse Attr Color
543     btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_REVERSE);
544     btn->SetCheck((ts.ColorFlag&CF_REVERSECOLOR) != 0);
545    
546     // (8)URL Color
547     btn = (CButton *)GetDlgItem(IDC_ENABLE_URL_COLOR);
548     btn->SetCheck((ts.ColorFlag&CF_URLCOLOR) != 0);
549    
550     // (9)Color
551     btn = (CButton *)GetDlgItem(IDC_ENABLE_ANSI_COLOR);
552     btn->SetCheck((ts.ColorFlag&CF_ANSICOLOR) != 0);
553    
554     // ダイアログにフォーカスを当てる
555     ::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_ALPHA_BLEND));
556    
557     return FALSE;
558     }
559    
560     BOOL CVisualPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
561     {
562     CListBox *listbox;
563     int sel;
564     char buf[MAXPATHLEN];
565    
566     switch (wParam) {
567     case IDC_ANSI_COLOR | (LBN_SELCHANGE << 16):
568     listbox = (CListBox *)GetDlgItem(IDC_ANSI_COLOR);
569     sel = listbox->GetCurSel();
570     if (sel != -1) {
571     SetupRGBbox(GetSafeHwnd(), sel);
572     #if 0
573     SendMessage(WM_CTLCOLORSTATIC,
574     (WPARAM)label_hdc,
575     (LPARAM)GetDlgItem(IDC_SAMPLE_COLOR));
576     #endif
577     }
578     return TRUE;
579    
580     case IDC_COLOR_RED | (EN_KILLFOCUS << 16):
581     case IDC_COLOR_GREEN | (EN_KILLFOCUS << 16):
582     case IDC_COLOR_BLUE | (EN_KILLFOCUS << 16):
583     {
584     BYTE r, g, b;
585    
586     listbox = (CListBox *)GetDlgItem(IDC_ANSI_COLOR);
587     sel = listbox->GetCurSel();
588     if (sel < 0 && sel > sizeof(ts.ANSIColor)-1) {
589     return TRUE;
590     }
591    
592     GetDlgItemText(IDC_COLOR_RED, buf, sizeof(buf));
593     r = atoi(buf);
594    
595     GetDlgItemText(IDC_COLOR_GREEN, buf, sizeof(buf));
596     g = atoi(buf);
597    
598     GetDlgItemText(IDC_COLOR_BLUE, buf, sizeof(buf));
599     b = atoi(buf);
600    
601     ts.ANSIColor[sel] = RGB(r, g, b);
602    
603     // 255を超えたRGB値は補正されるので、それをEditに表示する (2007.2.18 maya)
604     SetupRGBbox(GetSafeHwnd(), sel);
605     #if 0
606     SendMessage(WM_CTLCOLORSTATIC,
607     (WPARAM)label_hdc,
608     (LPARAM)GetDlgItem(IDC_SAMPLE_COLOR));
609     #endif
610     }
611    
612     return TRUE;
613     #if 0
614     case WM_CTLCOLORSTATIC:
615     {
616     HDC hDC = (HDC)wp;
617     HWND hWnd = (HWND)lp;
618    
619     //if (label_hdc == NULL) {
620     hDC = GetWindowDC(GetDlgItem(hDlgWnd, IDC_SAMPLE_COLOR));
621     // label_hdc = hDC;
622     //}
623    
624     if ( hWnd == GetDlgItem(hDlgWnd, IDC_SAMPLE_COLOR) ) {
625     BYTE r, g, b;
626    
627     hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_RED);
628     SendMessage(hWnd, WM_GETTEXT , sizeof(buf), (LPARAM)buf);
629     r = atoi(buf);
630    
631     hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_GREEN);
632     SendMessage(hWnd, WM_GETTEXT , sizeof(buf), (LPARAM)buf);
633     g = atoi(buf);
634    
635     hWnd = GetDlgItem(hDlgWnd, IDC_COLOR_BLUE);
636     SendMessage(hWnd, WM_GETTEXT , sizeof(buf), (LPARAM)buf);
637     b = atoi(buf);
638    
639     OutputDebugPrintf("%06x\n", RGB(r, g, b));
640    
641     SetBkMode(hDC, TRANSPARENT);
642     SetTextColor(hDC, RGB(r, g, b) );
643     ReleaseDC(hDlgWnd, hDC);
644    
645     return (BOOL)(HBRUSH)GetStockObject(NULL_BRUSH);
646     }
647     return FALSE;
648     }
649     break ;
650     #endif
651     }
652    
653     return CPropertyPage::OnCommand(wParam, lParam);
654     }
655    
656     void CVisualPropPageDlg::OnOK()
657     {
658     CListBox *listbox;
659     CButton *btn;
660     int sel;
661     int beforeAlphaBlend;
662     char buf[MAXPATHLEN];
663     COLORREF TmpColor;
664    
665     // (1)
666     beforeAlphaBlend = ts.AlphaBlend;
667     GetDlgItemText(IDC_ALPHA_BLEND, buf, sizeof(buf));
668     if (isdigit(buf[0])) {
669     ts.AlphaBlend = atoi(buf);
670     ts.AlphaBlend = max(0, ts.AlphaBlend);
671     ts.AlphaBlend = min(255, ts.AlphaBlend);
672     }
673    
674     // (2)
675     // グローバル変数 BGEnable を直接書き換えると、プログラムが落ちることが
676     // あるのでコピーを修正するのみとする。(2005.4.24 yutaka)
677     btn = (CButton *)GetDlgItem(IDC_ETERM_LOOKFEEL);
678     ts.EtermLookfeel.BGEnable = btn->GetCheck();
679    
680     // (3)
681     listbox = (CListBox *)GetDlgItem(IDC_MOUSE_CURSOR);
682     sel = listbox->GetCurSel();
683     if (sel >= 0 && sel < MOUSE_CURSOR_MAX) {
684     strncpy_s(ts.MouseCursorName, sizeof(ts.MouseCursorName), MouseCursor[sel].name, _TRUNCATE);
685     }
686    
687     // (5) Attr Bold Color
688     btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BOLD);
689     if (((ts.ColorFlag & CF_BOLDCOLOR) != 0) != btn->GetCheck()) {
690     ts.ColorFlag ^= CF_BOLDCOLOR;
691     }
692    
693     // (6) Attr Blink Color
694     btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_BLINK);
695     if (((ts.ColorFlag & CF_BLINKCOLOR) != 0) != btn->GetCheck()) {
696     ts.ColorFlag ^= CF_BLINKCOLOR;
697     }
698    
699     // (7) Attr Reverse Color
700     btn = (CButton *)GetDlgItem(IDC_ENABLE_ATTR_COLOR_REVERSE);
701     if (ts.ColorFlag & CF_REVERSEVIDEO) { // Reverse Videoモード(DECSCNM)時は処理を変える
702     if (ts.ColorFlag & CF_REVERSECOLOR) {
703     if (!btn->GetCheck()) {
704     TmpColor = ts.VTColor[0];
705     ts.VTColor[0] = ts.VTReverseColor[1];
706     ts.VTReverseColor[1] = ts.VTColor[1];
707     ts.VTColor[1] = ts.VTReverseColor[0];
708     ts.VTReverseColor[0] = TmpColor;
709     ts.ColorFlag ^= CF_REVERSECOLOR;
710     }
711     }
712     else if (btn->GetCheck()) {
713     TmpColor = ts.VTColor[0];
714     ts.VTColor[0] = ts.VTReverseColor[0];
715     ts.VTReverseColor[0] = ts.VTColor[1];
716     ts.VTColor[1] = ts.VTReverseColor[1];
717     ts.VTReverseColor[1] = TmpColor;
718     ts.ColorFlag ^= CF_REVERSECOLOR;
719     }
720     }
721     else if (((ts.ColorFlag & CF_REVERSECOLOR) != 0) != btn->GetCheck()) {
722     ts.ColorFlag ^= CF_REVERSECOLOR;
723     }
724    
725     // (8) URL Color
726     btn = (CButton *)GetDlgItem(IDC_ENABLE_URL_COLOR);
727     if (((ts.ColorFlag & CF_URLCOLOR) != 0) != btn->GetCheck()) {
728     ts.ColorFlag ^= CF_URLCOLOR;
729     }
730    
731     // (9) Color
732     btn = (CButton *)GetDlgItem(IDC_ENABLE_ANSI_COLOR);
733     if (((ts.ColorFlag & CF_ANSICOLOR) != 0) != btn->GetCheck()) {
734     ts.ColorFlag ^= CF_ANSICOLOR;
735     }
736    
737     // 2006/03/11 by 337 : Alpha値も即時変更
738     // Layered窓になっていない場合は効果が無い
739     if (ts.EtermLookfeel.BGUseAlphaBlendAPI) {
740     // 起動時に半透明レイヤにしていない場合でも、即座に半透明となるようにする。(2006.4.1 yutaka)
741     //MySetLayeredWindowAttributes(HVTWin, 0, (ts.AlphaBlend > 255) ? 255: ts.AlphaBlend, LWA_ALPHA);
742     // 値が変更されたときのみ設定を反映する。(2007.10.19 maya)
743     if (ts.AlphaBlend != beforeAlphaBlend) {
744     SetWindowStyle(&ts);
745     }
746     }
747     }
748    
749    
750    
751     // CLogPropPageDlg ダイアログ
752    
753     IMPLEMENT_DYNAMIC(CLogPropPageDlg, CPropertyPage)
754    
755     CLogPropPageDlg::CLogPropPageDlg()
756     : CPropertyPage(CLogPropPageDlg::IDD)
757     {
758    
759     }
760    
761     CLogPropPageDlg::~CLogPropPageDlg()
762     {
763     if (DlgLogFont != NULL) {
764     DeleteObject(DlgLogFont);
765     }
766     }
767    
768     BEGIN_MESSAGE_MAP(CLogPropPageDlg, CPropertyPage)
769     END_MESSAGE_MAP()
770    
771     // CLogPropPageDlg メッセージ ハンドラ
772    
773     BOOL CLogPropPageDlg::OnInitDialog()
774     {
775     char uimsg[MAX_UIMSG];
776     CButton *btn;
777    
778     CPropertyPage::OnInitDialog();
779    
780     font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
781     GetObject(font, sizeof(LOGFONT), &logfont);
782     if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgLogFont, ts.UILanguageFile)) {
783     SendDlgItemMessage(IDC_VIEWLOG_LABEL, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
784     SendDlgItemMessage(IDC_VIEWLOG_EDITOR, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
785     SendDlgItemMessage(IDC_VIEWLOG_PATH, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
786     SendDlgItemMessage(IDC_DEFAULTNAME_LABEL, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
787     SendDlgItemMessage(IDC_DEFAULTNAME_EDITOR, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
788     SendDlgItemMessage(IDC_DEFAULTPATH_LABEL, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
789     SendDlgItemMessage(IDC_DEFAULTPATH_EDITOR, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
790     SendDlgItemMessage(IDC_DEFAULTPATH_PUSH, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
791     SendDlgItemMessage(IDC_AUTOSTART, WM_SETFONT, (WPARAM)DlgLogFont, MAKELPARAM(TRUE,0));
792     }
793     else {
794     DlgLogFont = NULL;
795     }
796    
797     GetDlgItemText(IDC_VIEWLOG_LABEL, uimsg, sizeof(uimsg));
798     get_lang_msg("DLG_TAB_LOG_EDITOR", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
799     SetDlgItemText(IDC_VIEWLOG_LABEL, ts.UIMsg);
800     GetDlgItemText(IDC_DEFAULTNAME_LABEL, uimsg, sizeof(uimsg));
801     get_lang_msg("DLG_TAB_LOG_FILENAME", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
802     SetDlgItemText(IDC_DEFAULTNAME_LABEL, ts.UIMsg);
803     GetDlgItemText(IDC_DEFAULTPATH_LABEL, uimsg, sizeof(uimsg));
804     get_lang_msg("DLG_TAB_LOG_FILEPATH", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
805     SetDlgItemText(IDC_DEFAULTPATH_LABEL, ts.UIMsg);
806     GetDlgItemText(IDC_AUTOSTART, uimsg, sizeof(uimsg));
807     get_lang_msg("DLG_TAB_LOG_AUTOSTART", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
808     SetDlgItemText(IDC_AUTOSTART, ts.UIMsg);
809    
810     // Viewlog Editor path (2005.1.29 yutaka)
811     SetDlgItemText(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor);
812    
813     // Log Default File Name (2006.8.28 maya)
814     SetDlgItemText(IDC_DEFAULTNAME_EDITOR, ts.LogDefaultName);
815    
816     // Log Default File Path (2007.5.30 maya)
817     SetDlgItemText(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath);
818    
819     /* Auto start logging (2007.5.31 maya) */
820     btn = (CButton *)GetDlgItem(IDC_AUTOSTART);
821     btn->SetCheck(ts.LogAutoStart);
822    
823     // ダイアログにフォーカスを当てる
824     ::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_VIEWLOG_EDITOR));
825    
826     return FALSE;
827     }
828    
829     BOOL CLogPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
830     {
831     char uimsg[MAX_UIMSG];
832    
833     switch (wParam) {
834     case IDC_VIEWLOG_PATH | (BN_CLICKED << 16):
835     {
836     OPENFILENAME ofn;
837    
838     ZeroMemory(&ofn, sizeof(ofn));
839     ofn.lStructSize = get_OPENFILENAME_SIZE();
840     ofn.hwndOwner = GetSafeHwnd();
841     get_lang_msg("FILEDLG_SELECT_LOGVIEW_APP_FILTER", ts.UIMsg, sizeof(ts.UIMsg),
842     "exe(*.exe)\\0*.exe\\0all(*.*)\\0*.*\\0\\0", ts.UILanguageFile);
843     ofn.lpstrFilter = ts.UIMsg;
844     ofn.lpstrFile = ts.ViewlogEditor;
845     ofn.nMaxFile = sizeof(ts.ViewlogEditor);
846     get_lang_msg("FILEDLG_SELECT_LOGVIEW_APP_TITLE", uimsg, sizeof(uimsg),
847     "Choose a executing file with launching logging file", ts.UILanguageFile);
848     ofn.lpstrTitle = uimsg;
849     ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_FORCESHOWHIDDEN | OFN_HIDEREADONLY;
850     if (GetOpenFileName(&ofn) != 0) {
851     SetDlgItemText(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor);
852     }
853     }
854     return TRUE;
855    
856     case IDC_DEFAULTPATH_PUSH | (BN_CLICKED << 16):
857     // ログディレクトリの選択ダイアログ
858     get_lang_msg("FILEDLG_SELECT_LOGDIR_TITLE", ts.UIMsg, sizeof(ts.UIMsg),
859     "Select log folder", ts.UILanguageFile);
860     doSelectFolder(GetSafeHwnd(), ts.LogDefaultPath, sizeof(ts.LogDefaultPath),
861     ts.UIMsg);
862     SetDlgItemText(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath);
863    
864     return TRUE;
865     }
866    
867     return CPropertyPage::OnCommand(wParam, lParam);
868     }
869    
870     void CLogPropPageDlg::OnOK()
871     {
872     char buf[80], buf2[80];
873     time_t time_local;
874     struct tm *tm_local;
875     char uimsg[MAX_UIMSG];
876     CButton *btn;
877    
878     // Viewlog Editor path (2005.1.29 yutaka)
879     GetDlgItemText(IDC_VIEWLOG_EDITOR, ts.ViewlogEditor, sizeof(ts.ViewlogEditor));
880    
881     // Log Default File Name (2006.8.28 maya)
882     GetDlgItemText(IDC_DEFAULTNAME_EDITOR, buf, sizeof(buf));
883     if (isInvalidStrftimeChar(buf)) {
884     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
885     get_lang_msg("MSG_LOGFILE_INVALID_CHAR_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
886     "Invalid character is included in log file name.", ts.UILanguageFile);
887     MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
888     return;
889     }
890     // 現在時刻を取得
891     time(&time_local);
892     tm_local = localtime(&time_local);
893     // 時刻文字列に変換
894     if (strlen(buf) != 0 && strftime(buf2, sizeof(buf2), buf, tm_local) == 0) {
895     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
896     get_lang_msg("MSG_LOGFILE_TOOLONG_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
897     "The log file name is too long.", ts.UILanguageFile);
898     MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
899     return;
900     }
901     if (isInvalidFileNameChar(buf2)) {
902     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
903     get_lang_msg("MSG_LOGFILE_INVALID_CHAR_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
904     "Invalid character is included in log file name.", ts.UILanguageFile);
905     MessageBox(ts.UIMsg, uimsg, MB_ICONEXCLAMATION);
906     return;
907     }
908     strncpy_s(ts.LogDefaultName, sizeof(ts.LogDefaultName), buf, _TRUNCATE);
909    
910     // Log Default File Path (2007.5.30 maya)
911     GetDlgItemText(IDC_DEFAULTPATH_EDITOR, ts.LogDefaultPath, sizeof(ts.LogDefaultPath));
912    
913     /* Auto start logging (2007.5.31 maya) */
914     btn = (CButton *)GetDlgItem(IDC_AUTOSTART);
915     ts.LogAutoStart = btn->GetCheck();
916     }
917    
918    
919    
920     // CCygwinPropPageDlg ダイアログ
921    
922     IMPLEMENT_DYNAMIC(CCygwinPropPageDlg, CPropertyPage)
923    
924     CCygwinPropPageDlg::CCygwinPropPageDlg()
925     : CPropertyPage(CCygwinPropPageDlg::IDD)
926     {
927     }
928    
929     CCygwinPropPageDlg::~CCygwinPropPageDlg()
930     {
931     if (DlgCygwinFont != NULL) {
932     DeleteObject(DlgCygwinFont);
933     }
934     }
935    
936     BEGIN_MESSAGE_MAP(CCygwinPropPageDlg, CPropertyPage)
937     END_MESSAGE_MAP()
938    
939     // CCygwinPropPageDlg メッセージ ハンドラ
940    
941     BOOL CCygwinPropPageDlg::OnInitDialog()
942     {
943     char *cfgfile = "cygterm.cfg"; // CygTerm configuration file
944     char cfg[MAX_PATH];
945     FILE *fp;
946     char buf[256], *head, *body;
947     char uimsg[MAX_UIMSG];
948     CButton *btn;
949    
950     CPropertyPage::OnInitDialog();
951    
952     font = (HFONT)SendMessage(WM_GETFONT, 0, 0);
953     GetObject(font, sizeof(LOGFONT), &logfont);
954     if (get_lang_font("DLG_TAHOMA_FONT", GetSafeHwnd(), &logfont, &DlgCygwinFont, ts.UILanguageFile)) {
955     SendDlgItemMessage(IDC_CYGWIN_PATH_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
956     SendDlgItemMessage(IDC_CYGWIN_PATH, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
957     SendDlgItemMessage(IDC_SELECT_FILE, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
958     SendDlgItemMessage(IDC_CYGWIN, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
959     SendDlgItemMessage(IDC_TERM_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
960     SendDlgItemMessage(IDC_TERM_EDIT, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
961     SendDlgItemMessage(IDC_TERMTYPE_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
962     SendDlgItemMessage(IDC_TERM_TYPE, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
963     SendDlgItemMessage(IDC_PORTSTART_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
964     SendDlgItemMessage(IDC_PORT_START, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
965     SendDlgItemMessage(IDC_PORTRANGE_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
966     SendDlgItemMessage(IDC_PORT_RANGE, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
967     SendDlgItemMessage(IDC_SHELL_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
968     SendDlgItemMessage(IDC_SHELL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
969     SendDlgItemMessage(IDC_ENV1_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
970     SendDlgItemMessage(IDC_ENV1, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
971     SendDlgItemMessage(IDC_ENV2_LABEL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
972     SendDlgItemMessage(IDC_ENV2, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
973     SendDlgItemMessage(IDC_LOGIN_SHELL, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
974     SendDlgItemMessage(IDC_HOME_CHDIR, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
975     SendDlgItemMessage(IDC_AGENT_PROXY, WM_SETFONT, (WPARAM)DlgCygwinFont, MAKELPARAM(TRUE,0));
976     }
977     else {
978     DlgCygwinFont = NULL;
979     }
980    
981     GetDlgItemText(IDC_CYGWIN_PATH_LABEL, uimsg, sizeof(uimsg));
982     get_lang_msg("DLG_TAB_CYGWIN_PATH", ts.UIMsg, sizeof(ts.UIMsg), uimsg, ts.UILanguageFile);
983     SetDlgItemText(IDC_CYGWIN_PATH_LABEL, ts.UIMsg);
984    
985     // try to read CygTerm config file
986     memset(&settings, 0, sizeof(settings));
987     _snprintf_s(settings.term, sizeof(settings.term), _TRUNCATE, "ttermpro.exe %%s %%d /E /KR=SJIS /KT=SJIS /VTICON=CygTerm /nossh");
988     _snprintf_s(settings.term_type, sizeof(settings.term_type), _TRUNCATE, "vt100");
989     _snprintf_s(settings.port_start, sizeof(settings.port_start), _TRUNCATE, "20000");
990     _snprintf_s(settings.port_range, sizeof(settings.port_range), _TRUNCATE, "40");
991     _snprintf_s(settings.shell, sizeof(settings.shell), _TRUNCATE, "auto");
992     _snprintf_s(settings.env1, sizeof(settings.env1), _TRUNCATE, "MAKE_MODE=unix");
993     _snprintf_s(settings.env2, sizeof(settings.env2), _TRUNCATE, "");
994     settings.login_shell = FALSE;
995     settings.home_chdir = FALSE;
996     settings.agent_proxy = FALSE;
997    
998     strncpy_s(cfg, sizeof(cfg), ts.HomeDir, _TRUNCATE);
999     AppendSlash(cfg, sizeof(cfg));
1000     strncat_s(cfg, sizeof(cfg), cfgfile, _TRUNCATE);
1001    
1002     fp = fopen(cfg, "r");
1003     if (fp != NULL) {
1004     while (fgets(buf, sizeof(buf), fp) != NULL) {
1005     int len = strlen(buf);
1006    
1007     if (buf[len - 1] == '\n')
1008     buf[len - 1] = '\0';
1009    
1010     split_buffer(buf, '=', &head, &body);
1011     if (head == NULL || body == NULL)
1012     continue;
1013    
1014     if (_stricmp(head, "TERM") == 0) {
1015     _snprintf_s(settings.term, sizeof(settings.term), _TRUNCATE, "%s", body);
1016    
1017     } else if (_stricmp(head, "TERM_TYPE") == 0) {
1018     _snprintf_s(settings.term_type, sizeof(settings.term_type), _TRUNCATE, "%s", body);
1019    
1020     } else if (_stricmp(head, "PORT_START") == 0) {
1021     _snprintf_s(settings.port_start, sizeof(settings.port_start), _TRUNCATE, "%s", body);
1022    
1023     } else if (_stricmp(head, "PORT_RANGE") == 0) {
1024     _snprintf_s(settings.port_range, sizeof(settings.port_range), _TRUNCATE, "%s", body);
1025    
1026     } else if (_stricmp(head, "SHELL") == 0) {
1027     _snprintf_s(settings.shell, sizeof(settings.shell), _TRUNCATE, "%s", body);
1028    
1029     } else if (_stricmp(head, "ENV_1") == 0) {
1030     _snprintf_s(settings.env1, sizeof(settings.env1), _TRUNCATE, "%s", body);
1031    
1032     } else if (_stricmp(head, "ENV_2") == 0) {
1033     _snprintf_s(settings.env2, sizeof(settings.env2), _TRUNCATE, "%s", body);
1034    
1035     } else if (_stricmp(head, "LOGIN_SHELL") == 0) {
1036     if (strchr("YyTt", *body)) {
1037     settings.login_shell = TRUE;
1038     }
1039    
1040     } else if (_stricmp(head, "HOME_CHDIR") == 0) {
1041     if (strchr("YyTt", *body)) {
1042     settings.home_chdir = TRUE;
1043     }
1044    
1045     } else if (_stricmp(head, "SSH_AGENT_PROXY") == 0) {
1046     if (strchr("YyTt", *body)) {
1047     settings.agent_proxy = TRUE;
1048     }
1049    
1050     } else {
1051     // TODO: error check
1052    
1053     }
1054     }
1055     fclose(fp);
1056     }
1057     SetDlgItemText(IDC_TERM_EDIT, settings.term);
1058     SetDlgItemText(IDC_TERM_TYPE, settings.term_type);
1059     SetDlgItemText(IDC_PORT_START, settings.port_start);
1060     SetDlgItemText(IDC_PORT_RANGE, settings.port_range);
1061     SetDlgItemText(IDC_SHELL, settings.shell);
1062     SetDlgItemText(IDC_ENV1, settings.env1);
1063     SetDlgItemText(IDC_ENV2, settings.env2);
1064     btn = (CButton *)GetDlgItem(IDC_LOGIN_SHELL);
1065     btn->SetCheck(settings.login_shell);
1066     btn = (CButton *)GetDlgItem(IDC_HOME_CHDIR);
1067     btn->SetCheck(settings.home_chdir);
1068     btn = (CButton *)GetDlgItem(IDC_AGENT_PROXY);
1069     btn->SetCheck(settings.agent_proxy);
1070    
1071     // Cygwin install path
1072     SetDlgItemText(IDC_CYGWIN_PATH, ts.CygwinDirectory);
1073    
1074     // ダイアログにフォーカスを当てる
1075     ::SetFocus(::GetDlgItem(GetSafeHwnd(), IDC_CYGWIN_PATH));
1076    
1077     return FALSE;
1078     }
1079    
1080     BOOL CCygwinPropPageDlg::OnCommand(WPARAM wParam, LPARAM lParam)
1081     {
1082     switch (wParam) {
1083     case IDC_SELECT_FILE | (BN_CLICKED << 16):
1084     // Cygwin install ディレクトリの選択ダイアログ
1085     get_lang_msg("DIRDLG_CYGTERM_DIR_TITLE", ts.UIMsg, sizeof(ts.UIMsg),
1086     "Select Cygwin directory", ts.UILanguageFile);
1087     doSelectFolder(GetSafeHwnd(), ts.CygwinDirectory, sizeof(ts.CygwinDirectory),
1088     ts.UIMsg);
1089     // Cygwin install path
1090     SetDlgItemText(IDC_CYGWIN_PATH, ts.CygwinDirectory);
1091     return TRUE;
1092     }
1093    
1094     return CPropertyPage::OnCommand(wParam, lParam);
1095     }
1096    
1097     void CCygwinPropPageDlg::OnOK()
1098     {
1099     char *cfgfile = "cygterm.cfg"; // CygTerm configuration file
1100     char *tmpfile = "cygterm.tmp";
1101     char cfg[MAX_PATH];
1102     char tmp[MAX_PATH];
1103     FILE *fp;
1104     FILE *tmp_fp;
1105     char buf[256], *head, *body;
1106     char uimsg[MAX_UIMSG];
1107     CButton *btn;
1108    
1109     // writing to CygTerm config file
1110     GetDlgItemText(IDC_TERM_EDIT, settings.term, sizeof(settings.term));
1111     GetDlgItemText(IDC_TERM_TYPE, settings.term_type, sizeof(settings.term_type));
1112     GetDlgItemText(IDC_PORT_START, settings.port_start, sizeof(settings.port_start));
1113     GetDlgItemText(IDC_PORT_RANGE, settings.port_range, sizeof(settings.port_range));
1114     GetDlgItemText(IDC_SHELL, settings.shell, sizeof(settings.shell));
1115     GetDlgItemText(IDC_ENV1, settings.env1, sizeof(settings.env1));
1116     GetDlgItemText(IDC_ENV2, settings.env2, sizeof(settings.env2));
1117     btn = (CButton *)GetDlgItem(IDC_LOGIN_SHELL);
1118     settings.login_shell = btn->GetCheck();
1119     btn = (CButton *)GetDlgItem(IDC_HOME_CHDIR);
1120     settings.home_chdir = btn->GetCheck();
1121     btn = (CButton *)GetDlgItem(IDC_AGENT_PROXY);
1122     settings.agent_proxy = btn->GetCheck();
1123    
1124     strncpy_s(cfg, sizeof(cfg), ts.HomeDir, _TRUNCATE);
1125     AppendSlash(cfg, sizeof(cfg));
1126     strncat_s(cfg, sizeof(cfg), cfgfile, _TRUNCATE);
1127    
1128     strncpy_s(tmp, sizeof(tmp), ts.HomeDir, _TRUNCATE);
1129     AppendSlash(tmp, sizeof(tmp));
1130     strncat_s(tmp, sizeof(tmp), tmpfile, _TRUNCATE);
1131    
1132     fp = fopen(cfg, "r");
1133     tmp_fp = fopen(tmp, "w");
1134     if (tmp_fp == NULL) {
1135     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
1136     get_lang_msg("MSG_CYGTERM_CONF_WRITEFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
1137     "Can't write CygTerm configuration file (%d).", ts.UILanguageFile);
1138     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
1139     MessageBox(buf, uimsg, MB_ICONEXCLAMATION);
1140     } else {
1141     if (fp != NULL) {
1142     while (fgets(buf, sizeof(buf), fp) != NULL) {
1143     int len = strlen(buf);
1144    
1145     if (buf[len - 1] == '\n')
1146     buf[len - 1] = '\0';
1147    
1148     split_buffer(buf, '=', &head, &body);
1149     if (head == NULL || body == NULL) {
1150     fprintf(tmp_fp, "%s\n", buf);
1151     }
1152     else if (_stricmp(head, "TERM") == 0) {
1153     fprintf(tmp_fp, "TERM = %s\n", settings.term);
1154     settings.term[0] = '\0';
1155     }
1156     else if (_stricmp(head, "TERM_TYPE") == 0) {
1157     fprintf(tmp_fp, "TERM_TYPE = %s\n", settings.term_type);
1158     settings.term_type[0] = '\0';
1159     }
1160     else if (_stricmp(head, "PORT_START") == 0) {
1161     fprintf(tmp_fp, "PORT_START = %s\n", settings.port_start);
1162     settings.port_start[0] = '\0';
1163     }
1164     else if (_stricmp(head, "PORT_RANGE") == 0) {
1165     fprintf(tmp_fp, "PORT_RANGE = %s\n", settings.port_range);
1166     settings.port_range[0] = '\0';
1167     }
1168     else if (_stricmp(head, "SHELL") == 0) {
1169     fprintf(tmp_fp, "SHELL = %s\n", settings.shell);
1170     settings.shell[0] = '\0';
1171     }
1172     else if (_stricmp(head, "ENV_1") == 0) {
1173     fprintf(tmp_fp, "ENV_1 = %s\n", settings.env1);
1174     settings.env1[0] = '\0';
1175     }
1176     else if (_stricmp(head, "ENV_2") == 0) {
1177     fprintf(tmp_fp, "ENV_2 = %s\n", settings.env2);
1178     settings.env2[0] = '\0';
1179     }
1180     else if (_stricmp(head, "LOGIN_SHELL") == 0) {
1181     fprintf(tmp_fp, "LOGIN_SHELL = %s\n", (settings.login_shell == TRUE) ? "yes" : "no");
1182     settings.login_shell = FALSE;
1183     }
1184     else if (_stricmp(head, "HOME_CHDIR") == 0) {
1185     fprintf(tmp_fp, "HOME_CHDIR = %s\n", (settings.home_chdir == TRUE) ? "yes" : "no");
1186     settings.home_chdir = FALSE;
1187     }
1188     else if (_stricmp(head, "SSH_AGENT_PROXY") == 0) {
1189     fprintf(tmp_fp, "SSH_AGENT_PROXY = %s\n", (settings.agent_proxy == TRUE) ? "yes" : "no");
1190     settings.agent_proxy = FALSE;
1191     }
1192     else {
1193     fprintf(tmp_fp, "%s = %s\n", head, body);
1194     }
1195     }
1196     fclose(fp);
1197     }
1198     else {
1199     fputs("# CygTerm setting\n", tmp_fp);
1200     fputs("\n", tmp_fp);
1201     }
1202     if (settings.term[0] != '\0') {
1203     fprintf(tmp_fp, "TERM = %s\n", settings.term);
1204     }
1205     if (settings.term_type[0] != '\0') {
1206     fprintf(tmp_fp, "TERM_TYPE = %s\n", settings.term_type);
1207     }
1208     if (settings.port_start[0] != '\0') {
1209     fprintf(tmp_fp, "PORT_START = %s\n", settings.port_start);
1210     }
1211     if (settings.port_range[0] != '\0') {
1212     fprintf(tmp_fp, "PORT_RANGE = %s\n", settings.port_range);
1213     }
1214     if (settings.shell[0] != '\0') {
1215     fprintf(tmp_fp, "SHELL = %s\n", settings.shell);
1216     }
1217     if (settings.env1[0] != '\0') {
1218     fprintf(tmp_fp, "ENV_1 = %s\n", settings.env1);
1219     }
1220     if (settings.env2[0] != '\0') {
1221     fprintf(tmp_fp, "ENV_2 = %s\n", settings.env2);
1222     }
1223     if (settings.login_shell) {
1224     fprintf(tmp_fp, "LOGIN_SHELL = yes\n");
1225     }
1226     if (settings.home_chdir) {
1227     fprintf(tmp_fp, "HOME_CHDIR = yes\n");
1228     }
1229     if (settings.agent_proxy) {
1230     fprintf(tmp_fp, "SSH_AGENT_PROXY = yes\n");
1231     }
1232     fclose(tmp_fp);
1233    
1234     if (remove(cfg) != 0 && errno != ENOENT) {
1235     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
1236     get_lang_msg("MSG_CYGTERM_CONF_REMOVEFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
1237     "Can't remove old CygTerm configuration file (%d).", ts.UILanguageFile);
1238     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
1239     MessageBox(buf, uimsg, MB_ICONEXCLAMATION);
1240     }
1241     else if (rename(tmp, cfg) != 0) {
1242     get_lang_msg("MSG_ERROR", uimsg, sizeof(uimsg), "ERROR", ts.UILanguageFile);
1243     get_lang_msg("MSG_CYGTERM_CONF_RENAMEFILE_ERROR", ts.UIMsg, sizeof(ts.UIMsg),
1244     "Can't rename CygTerm configuration file (%d).", ts.UILanguageFile);
1245     _snprintf_s(buf, sizeof(buf), _TRUNCATE, ts.UIMsg, GetLastError());
1246     MessageBox(buf, uimsg, MB_ICONEXCLAMATION);
1247     }
1248     }
1249    
1250     // Cygwin install path
1251     GetDlgItemText(IDC_CYGWIN_PATH, ts.CygwinDirectory, sizeof(ts.CygwinDirectory));
1252     }
1253    
1254    
1255    
1256     // CAddSettingPropSheetDlg
1257    
1258     IMPLEMENT_DYNAMIC(CAddSettingPropSheetDlg, CPropertySheet)
1259    
1260     CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
1261     :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
1262     {
1263     AddPage(&m_GeneralPage);
1264     AddPage(&m_VisualPage);
1265     AddPage(&m_LogPage);
1266     AddPage(&m_CygwinPage);
1267    
1268     m_psh.dwFlags |= PSH_NOAPPLYNOW;
1269     }
1270    
1271     CAddSettingPropSheetDlg::CAddSettingPropSheetDlg(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
1272     :CPropertySheet(pszCaption, pParentWnd, iSelectPage)
1273     {
1274     AddPage(&m_GeneralPage);
1275     AddPage(&m_CopypastePage);
1276     AddPage(&m_VisualPage);
1277     AddPage(&m_LogPage);
1278     AddPage(&m_CygwinPage);
1279    
1280     m_psh.dwFlags |= PSH_NOAPPLYNOW;
1281     }
1282    
1283     CAddSettingPropSheetDlg::~CAddSettingPropSheetDlg()
1284     {
1285     }
1286    
1287    
1288     BEGIN_MESSAGE_MAP(CAddSettingPropSheetDlg, CPropertySheet)
1289     END_MESSAGE_MAP()
1290    
1291    
1292     // CAddSettingPropSheetDlg メッセージ ハンドラ
1293    
1294     BOOL CAddSettingPropSheetDlg::OnInitDialog()
1295     {
1296     CPropertySheet::OnInitDialog();
1297    
1298     get_lang_msg("DLG_TABSHEET_TITLE", ts.UIMsg, sizeof(ts.UIMsg),
1299     "Tera Term: Additional settings", ts.UILanguageFile);
1300     SetWindowText(ts.UIMsg);
1301    
1302     CTabCtrl *tab = GetTabControl();
1303     TCITEM tc;
1304     tc.mask = TCIF_TEXT;
1305    
1306     get_lang_msg("DLG_TABSHEET_TITLE_GENERAL", ts.UIMsg, sizeof(ts.UIMsg),
1307     "General", ts.UILanguageFile);
1308     tc.pszText = ts.UIMsg;
1309     tab->SetItem(0, &tc);
1310    
1311     get_lang_msg("DLG_TABSHEET_TITLE_COPYPASTE", ts.UIMsg, sizeof(ts.UIMsg),
1312     "Copy and Paste", ts.UILanguageFile);
1313     tc.pszText = ts.UIMsg;
1314     tab->SetItem(1, &tc);
1315    
1316     get_lang_msg("DLG_TABSHEET_TITLE_VISUAL", ts.UIMsg, sizeof(ts.UIMsg),
1317     "Visual", ts.UILanguageFile);
1318     tc.pszText = ts.UIMsg;
1319     tab->SetItem(2, &tc);
1320    
1321     get_lang_msg("DLG_TABSHEET_TITLE_Log", ts.UIMsg, sizeof(ts.UIMsg),
1322     "Log", ts.UILanguageFile);
1323     tc.pszText = ts.UIMsg;
1324     tab->SetItem(3, &tc);
1325    
1326     get_lang_msg("DLG_TABSHEET_TITLE_CYGWIN", ts.UIMsg, sizeof(ts.UIMsg),
1327     "Cygwin", ts.UILanguageFile);
1328     tc.pszText = ts.UIMsg;
1329     tab->SetItem(4, &tc);
1330    
1331     return FALSE;
1332     }