| 52 |
#include "buffer.h" |
#include "buffer.h" |
| 53 |
#include "helpid.h" |
#include "helpid.h" |
| 54 |
#include "layer_for_unicode.h" |
#include "layer_for_unicode.h" |
| 55 |
|
#include "layer_for_unicode_crt.h" |
| 56 |
|
#include "codeconv.h" |
| 57 |
|
|
| 58 |
#include "filesys.h" |
#include "filesys.h" |
| 59 |
#include "tt_res.h" |
//#include "tt_res.h" |
| 60 |
#include "filesys_log_res.h" |
#include "filesys_log_res.h" |
| 61 |
|
|
| 62 |
#define FS_BRACKET_NONE 0 |
#define FS_BRACKET_NONE 0 |
| 131 |
Line_FileHead = 2, |
Line_FileHead = 2, |
| 132 |
}; |
}; |
| 133 |
|
|
| 134 |
enum enumLineEnd eLineEnd = Line_LineHead; |
static enum enumLineEnd eLineEnd = Line_LineHead; |
| 135 |
|
|
| 136 |
|
|
| 137 |
// 遅延書き込み用スレッドのメッセージ |
// 遅延書き込み用スレッドのメッセージ |
| 521 |
* 2 UTF-16LE |
* 2 UTF-16LE |
| 522 |
* 3 UTF-16BE |
* 3 UTF-16BE |
| 523 |
*/ |
*/ |
| 524 |
static void CheckLogFile(const char *filename, BOOL *exist, int *bom) |
static void CheckLogFile(const wchar_t *filename, BOOL *exist, int *bom) |
| 525 |
{ |
{ |
| 526 |
|
*exist = FALSE; |
| 527 |
|
*bom = 0; |
| 528 |
|
|
| 529 |
// ファイルが存在する? |
// ファイルが存在する? |
| 530 |
DWORD logdir = GetFileAttributes(filename); |
DWORD logdir = _GetFileAttributesW(filename); |
| 531 |
if ((logdir != INVALID_FILE_ATTRIBUTES) && ((logdir & FILE_ATTRIBUTE_DIRECTORY) == 0)) { |
if ((logdir != INVALID_FILE_ATTRIBUTES) && ((logdir & FILE_ATTRIBUTE_DIRECTORY) == 0)) { |
| 532 |
// ファイルがあった , アペンドするつもり |
// ファイルがあった |
| 533 |
*exist = TRUE; |
*exist = TRUE; |
| 534 |
|
|
| 535 |
// BOM有り/無しチェック |
// BOM有り/無しチェック |
| 536 |
FILE *fp = fopen(filename, "rb"); |
FILE *fp = __wfopen(filename, L"rb"); |
| 537 |
unsigned char tmp[4]; |
if (fp != NULL) { |
| 538 |
size_t l = fread(tmp, 1, sizeof(tmp), fp); |
unsigned char tmp[4]; |
| 539 |
fclose(fp); |
size_t l = fread(tmp, 1, sizeof(tmp), fp); |
| 540 |
if (l < 2) { |
fclose(fp); |
| 541 |
*bom = 0; |
if (l < 2) { |
| 542 |
} else if (l >= 2 && tmp[0] == 0xff && tmp[1] == 0xfe) { |
*bom = 0; |
| 543 |
// UTF-16LE |
} else if (l >= 2 && tmp[0] == 0xff && tmp[1] == 0xfe) { |
| 544 |
*bom = 2; |
// UTF-16LE |
| 545 |
} else if (l >= 2 && tmp[0] == 0xfe && tmp[1] == 0xff) { |
*bom = 2; |
| 546 |
// UTF-16BE |
} else if (l >= 2 && tmp[0] == 0xfe && tmp[1] == 0xff) { |
| 547 |
*bom = 3; |
// UTF-16BE |
| 548 |
} else if (l >= 3 && tmp[0] == 0xef && tmp[1] == 0xbb && tmp[2] == 0xbf) { |
*bom = 3; |
| 549 |
// UTF-8 |
} else if (l >= 3 && tmp[0] == 0xef && tmp[1] == 0xbb && tmp[2] == 0xbf) { |
| 550 |
*bom = 1; |
// UTF-8 |
| 551 |
} else { |
*bom = 1; |
| 552 |
*bom = 0; |
} else { |
| 553 |
|
*bom = 0; |
| 554 |
|
} |
| 555 |
} |
} |
| 556 |
} |
} |
|
else { |
|
|
// ファイルがない、新規 |
|
|
*exist = FALSE; |
|
|
*bom = 0; |
|
|
} |
|
| 557 |
} |
} |
| 558 |
|
|
| 559 |
static void CheckLogFile(HWND Dialog, const char *filename) |
typedef struct { |
| 560 |
|
FLogDlgInfo_t *info; |
| 561 |
|
// work |
| 562 |
|
BOOL file_exist; |
| 563 |
|
int current_bom; |
| 564 |
|
TTTSet *pts; |
| 565 |
|
} LogDlgWork_t; |
| 566 |
|
|
| 567 |
|
static void ArrangeControls(HWND Dialog, LogDlgWork_t *work) |
| 568 |
{ |
{ |
| 569 |
BOOL exist; |
if (work->file_exist) { |
| 570 |
int bom; |
EnableWindow(GetDlgItem(Dialog, IDC_APPEND), TRUE); |
| 571 |
CheckLogFile(filename, &exist, &bom); |
} |
| 572 |
if (exist) { |
else { |
| 573 |
// ファイルが存在する -> アペンドするつもり? |
// ファイルがない -> 新規 |
| 574 |
CheckDlgButton(Dialog, IDC_FOPTAPPEND, BST_CHECKED); |
EnableWindow(GetDlgItem(Dialog, IDC_APPEND), FALSE); |
| 575 |
|
CheckRadioButton(Dialog, IDC_NEW_OVERWRITE, IDC_APPEND, IDC_NEW_OVERWRITE); |
| 576 |
|
} |
| 577 |
|
|
| 578 |
|
if (work->file_exist && IsDlgButtonChecked(Dialog, IDC_APPEND) == BST_CHECKED) { |
| 579 |
|
// ファイルが存在する && append |
| 580 |
|
int bom = work->current_bom; |
| 581 |
if (bom != 0) { |
if (bom != 0) { |
| 582 |
// BOM有り |
// BOM有り |
| 583 |
CheckDlgButton(Dialog, IDC_BOM, BST_CHECKED); |
CheckDlgButton(Dialog, IDC_BOM, BST_CHECKED); |
| 584 |
|
int cur = |
| 585 |
|
bom == 1 ? 0 : |
| 586 |
|
bom == 2 ? 1 : |
| 587 |
|
bom == 3 ? 2 : 0; |
| 588 |
|
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_SETCURSEL, cur, 0); |
| 589 |
} |
} |
| 590 |
else { |
else { |
| 591 |
// BOMなし |
// BOMなし |
| 592 |
CheckDlgButton(Dialog, IDC_BOM, BST_UNCHECKED); |
CheckDlgButton(Dialog, IDC_BOM, BST_UNCHECKED); |
| 593 |
|
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_SETCURSEL, 0, 0); |
| 594 |
|
} |
| 595 |
|
if (IsDlgButtonChecked(Dialog, IDC_FOPTTEXT) == BST_CHECKED) { |
| 596 |
|
EnableWindow(GetDlgItem(Dialog, IDC_BOM), FALSE); |
| 597 |
|
if (bom != 0) { |
| 598 |
|
// BOM有り |
| 599 |
|
EnableWindow(GetDlgItem(Dialog, IDC_TEXTCODING_DROPDOWN), FALSE); |
| 600 |
|
} |
| 601 |
|
else { |
| 602 |
|
// BOMなし |
| 603 |
|
EnableWindow(GetDlgItem(Dialog, IDC_TEXTCODING_DROPDOWN), TRUE); |
| 604 |
|
} |
| 605 |
} |
} |
| 606 |
} |
} |
| 607 |
else { |
else { |
| 608 |
// ファイルがない、新規 |
// ファイルがない、新規 |
| 609 |
CheckDlgButton(Dialog, IDC_FOPTAPPEND, BST_UNCHECKED); |
CheckRadioButton(Dialog, IDC_NEW_OVERWRITE, IDC_APPEND, IDC_NEW_OVERWRITE); |
| 610 |
CheckDlgButton(Dialog, IDC_BOM, BST_CHECKED); |
CheckDlgButton(Dialog, IDC_BOM, BST_CHECKED); |
| 611 |
|
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_SETCURSEL, 0, 0); |
| 612 |
|
if (IsDlgButtonChecked(Dialog, IDC_FOPTTEXT) == BST_CHECKED) { |
| 613 |
|
EnableWindow(GetDlgItem(Dialog, IDC_BOM), TRUE); |
| 614 |
|
} |
| 615 |
} |
} |
| 616 |
} |
} |
| 617 |
|
|
| 618 |
typedef struct { |
static void CheckLogFile(HWND Dialog, const wchar_t *filename, LogDlgWork_t *work) |
| 619 |
char *filename; |
{ |
| 620 |
BOOL append; |
BOOL exist; |
| 621 |
BOOL bom; |
int bom; |
| 622 |
} LogDlgData_t; |
CheckLogFile(filename, &exist, &bom); |
| 623 |
|
work->file_exist = exist; |
| 624 |
|
work->current_bom = bom; |
| 625 |
|
ArrangeControls(Dialog, work); |
| 626 |
|
} |
| 627 |
|
|
| 628 |
static INT_PTR CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam) |
static INT_PTR CALLBACK LogFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam) |
| 629 |
{ |
{ |
| 630 |
static const DlgTextInfo TextInfos[] = { |
static const DlgTextInfo TextInfos[] = { |
| 631 |
{ 0, "DLG_TABSHEET_TITLE_LOG" }, |
{ 0, "DLG_TABSHEET_TITLE_LOG" }, |
| 632 |
{ IDC_FOPTBIN, "DLG_FOPT_BINARY" }, |
{ IDC_FOPTBIN, "DLG_FOPT_BINARY" }, |
| 633 |
{ IDC_FOPTAPPEND, "DLG_FOPT_APPEND" }, |
// { IDC_FOPTAPPEND, "DLG_FOPT_APPEND" }, |
| 634 |
{ IDC_PLAINTEXT, "DLG_FOPT_PLAIN" }, |
{ IDC_PLAINTEXT, "DLG_FOPT_PLAIN" }, |
| 635 |
{ IDC_HIDEDIALOG, "DLG_FOPT_HIDEDIALOG" }, |
{ IDC_HIDEDIALOG, "DLG_FOPT_HIDEDIALOG" }, |
| 636 |
{ IDC_ALLBUFF_INFIRST, "DLG_FOPT_ALLBUFFINFIRST" }, |
{ IDC_ALLBUFF_INFIRST, "DLG_FOPT_ALLBUFFINFIRST" }, |
| 642 |
{ "DLG_FOPT_TIMESTAMP_ELAPSED_LOGGING", L"Elapsed Time (Logging)" }, |
{ "DLG_FOPT_TIMESTAMP_ELAPSED_LOGGING", L"Elapsed Time (Logging)" }, |
| 643 |
{ "DLG_FOPT_TIMESTAMP_ELAPSED_CONNECTION", L"Elapsed Time (Connection)" }, |
{ "DLG_FOPT_TIMESTAMP_ELAPSED_CONNECTION", L"Elapsed Time (Connection)" }, |
| 644 |
}; |
}; |
| 645 |
const char *UILanguageFile = ts.UILanguageFile; |
LogDlgWork_t *work = (LogDlgWork_t *)GetWindowLongPtr(Dialog, DWLP_USER); |
|
LogDlgData_t *data = (LogDlgData_t *)GetWindowLongPtr(Dialog, DWLP_USER); |
|
| 646 |
|
|
| 647 |
if (Message == RegisterWindowMessage(HELPMSGSTRING)) { |
if (Message == RegisterWindowMessage(HELPMSGSTRING)) { |
| 648 |
// コモンダイアログからのヘルプメッセージを付け替える |
// コモンダイアログからのヘルプメッセージを付け替える |
| 651 |
} |
} |
| 652 |
switch (Message) { |
switch (Message) { |
| 653 |
case WM_INITDIALOG: { |
case WM_INITDIALOG: { |
| 654 |
data = (LogDlgData_t *)lParam; |
work = (LogDlgWork_t *)lParam; |
| 655 |
SetWindowLongPtr(Dialog, DWLP_USER, (LONG_PTR)data); |
TTTSet *pts = work->pts; |
| 656 |
|
const char *UILanguageFile = pts->UILanguageFile; |
| 657 |
|
SetWindowLongPtr(Dialog, DWLP_USER, (LONG_PTR)work); |
| 658 |
::DragAcceptFiles(Dialog, TRUE); |
::DragAcceptFiles(Dialog, TRUE); |
| 659 |
|
|
| 660 |
SetDlgTexts(Dialog, TextInfos, _countof(TextInfos), UILanguageFile); |
SetDlgTexts(Dialog, TextInfos, _countof(TextInfos), UILanguageFile); |
| 662 |
UILanguageFile, 0); |
UILanguageFile, 0); |
| 663 |
|
|
| 664 |
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_ADDSTRING, 0, (LPARAM)"UTF-8"); |
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_ADDSTRING, 0, (LPARAM)"UTF-8"); |
| 665 |
|
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_ADDSTRING, 0, (LPARAM)"UTF-16LE"); |
| 666 |
|
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_ADDSTRING, 0, (LPARAM)"UTF-16BE"); |
| 667 |
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_SETCURSEL, 0, 0); |
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_SETCURSEL, 0, 0); |
| 668 |
|
|
| 669 |
SetDlgItemTextA(Dialog, IDC_FOPT_FILENAME_EDIT, data->filename); |
_SetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, work->info->filename); |
| 670 |
free(data->filename); |
work->info->filename = NULL; |
|
data->filename = NULL; |
|
| 671 |
|
|
| 672 |
// Binary/Text チェックボックス |
// Binary/Text チェックボックス |
| 673 |
if (ts.LogBinary) { |
if (pts->LogBinary) { |
| 674 |
SendDlgItemMessage(Dialog, IDC_FOPTBIN, BM_SETCHECK, BST_CHECKED, 0); |
CheckRadioButton(Dialog, IDC_FOPTBIN, IDC_FOPTTEXT, IDC_FOPTBIN); |
| 675 |
} |
} |
| 676 |
else { |
else { |
| 677 |
SendDlgItemMessage(Dialog, IDC_FOPTTEXT, BM_SETCHECK, BST_CHECKED, 0); |
CheckRadioButton(Dialog, IDC_FOPTBIN, IDC_FOPTTEXT, IDC_FOPTTEXT); |
|
} |
|
|
|
|
|
// Append チェックボックス |
|
|
if (ts.Append) { |
|
|
SetRB(Dialog, 1, IDC_FOPTAPPEND, IDC_FOPTAPPEND); |
|
| 678 |
} |
} |
| 679 |
|
|
| 680 |
// Plain Text チェックボックス |
// Plain Text チェックボックス |
| 681 |
if (ts.LogBinary) { |
if (pts->LogBinary) { |
| 682 |
// Binaryフラグが有効なときはチェックできない |
// Binaryフラグが有効なときはチェックできない |
| 683 |
DisableDlgItem(Dialog, IDC_PLAINTEXT, IDC_PLAINTEXT); |
DisableDlgItem(Dialog, IDC_PLAINTEXT, IDC_PLAINTEXT); |
| 684 |
} |
} |
| 685 |
else if (ts.LogTypePlainText) { |
else if (pts->LogTypePlainText) { |
| 686 |
SetRB(Dialog, 1, IDC_PLAINTEXT, IDC_PLAINTEXT); |
SetRB(Dialog, 1, IDC_PLAINTEXT, IDC_PLAINTEXT); |
| 687 |
} |
} |
| 688 |
|
|
| 689 |
// Hide dialogチェックボックス (2008.1.30 maya) |
// Hide dialogチェックボックス (2008.1.30 maya) |
| 690 |
if (ts.LogHideDialog) { |
if (pts->LogHideDialog) { |
| 691 |
SetRB(Dialog, 1, IDC_HIDEDIALOG, IDC_HIDEDIALOG); |
SetRB(Dialog, 1, IDC_HIDEDIALOG, IDC_HIDEDIALOG); |
| 692 |
} |
} |
| 693 |
|
|
| 694 |
// Include screen bufferチェックボックス (2013.9.29 yutaka) |
// Include screen bufferチェックボックス (2013.9.29 yutaka) |
| 695 |
if (ts.LogAllBuffIncludedInFirst) { |
if (pts->LogAllBuffIncludedInFirst) { |
| 696 |
SetRB(Dialog, 1, IDC_ALLBUFF_INFIRST, IDC_ALLBUFF_INFIRST); |
SetRB(Dialog, 1, IDC_ALLBUFF_INFIRST, IDC_ALLBUFF_INFIRST); |
| 697 |
} |
} |
| 698 |
|
|
| 699 |
// timestampチェックボックス (2006.7.23 maya) |
// timestampチェックボックス (2006.7.23 maya) |
| 700 |
if (ts.LogBinary) { |
if (pts->LogBinary) { |
| 701 |
// Binaryフラグが有効なときはチェックできない |
// Binaryフラグが有効なときはチェックできない |
| 702 |
DisableDlgItem(Dialog, IDC_TIMESTAMP, IDC_TIMESTAMP); |
DisableDlgItem(Dialog, IDC_TIMESTAMP, IDC_TIMESTAMP); |
| 703 |
} |
} |
| 704 |
else if (ts.LogTimestamp) { |
else if (pts->LogTimestamp) { |
| 705 |
SetRB(Dialog, 1, IDC_TIMESTAMP, IDC_TIMESTAMP); |
SetRB(Dialog, 1, IDC_TIMESTAMP, IDC_TIMESTAMP); |
| 706 |
} |
} |
| 707 |
|
|
| 708 |
// timestamp 種別 |
// timestamp 種別 |
| 709 |
int tstype = ts.LogTimestampType == TIMESTAMP_LOCAL ? 0 : |
int tstype = pts->LogTimestampType == TIMESTAMP_LOCAL ? 0 : |
| 710 |
ts.LogTimestampType == TIMESTAMP_UTC ? 1 : |
pts->LogTimestampType == TIMESTAMP_UTC ? 1 : |
| 711 |
ts.LogTimestampType == TIMESTAMP_ELAPSED_LOGSTART ? 2 : |
pts->LogTimestampType == TIMESTAMP_ELAPSED_LOGSTART ? 2 : |
| 712 |
ts.LogTimestampType == TIMESTAMP_ELAPSED_CONNECTED ? 3 : 0; |
pts->LogTimestampType == TIMESTAMP_ELAPSED_CONNECTED ? 3 : 0; |
| 713 |
SendDlgItemMessage(Dialog, IDC_TIMESTAMPTYPE, CB_SETCURSEL, tstype, 0); |
SendDlgItemMessage(Dialog, IDC_TIMESTAMPTYPE, CB_SETCURSEL, tstype, 0); |
| 714 |
if (ts.LogBinary || !ts.LogTimestamp) { |
if (pts->LogBinary || !pts->LogTimestamp) { |
| 715 |
DisableDlgItem(Dialog, IDC_TIMESTAMPTYPE, IDC_TIMESTAMPTYPE); |
DisableDlgItem(Dialog, IDC_TIMESTAMPTYPE, IDC_TIMESTAMPTYPE); |
| 716 |
} |
} |
| 717 |
|
|
| 723 |
case WM_COMMAND: |
case WM_COMMAND: |
| 724 |
switch (LOWORD(wParam)) { |
switch (LOWORD(wParam)) { |
| 725 |
case IDOK: { |
case IDOK: { |
| 726 |
char filename[MAX_PATH]; |
wchar_t filename[MAX_PATH]; |
| 727 |
GetDlgItemTextA(Dialog, IDC_FOPT_FILENAME_EDIT, filename, _countof(filename)); |
_GetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, filename, _countof(filename)); |
| 728 |
data->filename = _strdup(filename); |
work->info->filename = _wcsdup(filename); |
| 729 |
data->append = IsDlgButtonChecked(Dialog, IDC_FOPTAPPEND) == BST_CHECKED; |
work->info->append = IsDlgButtonChecked(Dialog, IDC_FOPTAPPEND) == BST_CHECKED; |
| 730 |
data->bom = IsDlgButtonChecked(Dialog, IDC_BOM) == BST_CHECKED; |
work->info->bom = IsDlgButtonChecked(Dialog, IDC_BOM) == BST_CHECKED; |
| 731 |
|
work->info->code = (int)SendDlgItemMessageA(Dialog, IDC_TEXTCODING_DROPDOWN, CB_GETCURSEL, 0, 0); |
| 732 |
SetLogFlags(Dialog); |
SetLogFlags(Dialog); |
| 733 |
EndDialog(Dialog, IDOK); |
EndDialog(Dialog, IDOK); |
| 734 |
break; |
break; |
| 737 |
EndDialog(Dialog, IDCANCEL); |
EndDialog(Dialog, IDCANCEL); |
| 738 |
break; |
break; |
| 739 |
case IDHELP: |
case IDHELP: |
| 740 |
OpenHelp(HH_HELP_CONTEXT, HlpFileLog, ts.UILanguageFile); |
OpenHelp(HH_HELP_CONTEXT, HlpFileLog, work->pts->UILanguageFile); |
| 741 |
break; |
break; |
| 742 |
case IDC_FOPT_FILENAME_BUTTON: { |
case IDC_FOPT_FILENAME_BUTTON: { |
| 743 |
/* save current dir */ |
/* save current dir */ |
| 744 |
|
const char *UILanguageFile = work->pts->UILanguageFile; |
| 745 |
wchar_t curdir[MAXPATHLEN]; |
wchar_t curdir[MAXPATHLEN]; |
| 746 |
_GetCurrentDirectoryW(_countof(curdir), curdir); |
_GetCurrentDirectoryW(_countof(curdir), curdir); |
| 747 |
|
|
| 748 |
char fname[MAX_PATH]; |
wchar_t fname[MAX_PATH]; |
| 749 |
GetDlgItemTextA(Dialog, IDC_FOPT_FILENAME_EDIT, fname, _countof(fname)); |
GetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, fname, _countof(fname)); |
| 750 |
|
|
| 751 |
char FNFilter[128*3]; |
wchar_t FNFilter[128*3]; |
| 752 |
get_lang_msg("FILEDLG_ALL_FILTER", FNFilter, sizeof(FNFilter), "All(*.*)\\0*.*\\0\\0", UILanguageFile); |
get_lang_msgW("FILEDLG_ALL_FILTER", FNFilter, sizeof(FNFilter), L"All(*.*)\\0*.*\\0\\0", UILanguageFile); |
| 753 |
|
|
| 754 |
char caption[MAX_PATH]; |
wchar_t caption[MAX_PATH]; |
| 755 |
char uimsg[MAX_UIMSG]; |
wchar_t uimsg[MAX_UIMSG]; |
| 756 |
get_lang_msg("FILEDLG_TRANS_TITLE_LOG", uimsg, sizeof(uimsg), TitLog, UILanguageFile); |
#define TitLogW L"Log" |
| 757 |
strncpy_s(caption, sizeof(caption),"Tera Term: ", _TRUNCATE); |
get_lang_msgW("FILEDLG_TRANS_TITLE_LOG", uimsg, _countof(uimsg), TitLogW, UILanguageFile); |
| 758 |
strncat_s(caption, sizeof(caption), uimsg, _TRUNCATE); |
wcsncpy_s(caption, _countof(caption), L"Tera Term: ", _TRUNCATE); |
| 759 |
|
wcsncat_s(caption, _countof(caption), uimsg, _TRUNCATE); |
| 760 |
|
|
| 761 |
OPENFILENAME ofn = {}; |
OPENFILENAMEW ofn = {}; |
| 762 |
ofn.lStructSize = get_OPENFILENAME_SIZEA(); |
ofn.lStructSize = get_OPENFILENAME_SIZEW(); |
| 763 |
//ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; |
//ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; |
| 764 |
ofn.Flags |= OFN_EXPLORER | OFN_ENABLESIZING; |
ofn.Flags |= OFN_EXPLORER | OFN_ENABLESIZING; |
| 765 |
ofn.Flags |= OFN_SHOWHELP; |
ofn.Flags |= OFN_SHOWHELP; |
| 768 |
ofn.lpstrFilter = FNFilter; |
ofn.lpstrFilter = FNFilter; |
| 769 |
ofn.nFilterIndex = 1; |
ofn.nFilterIndex = 1; |
| 770 |
ofn.lpstrFile = fname; |
ofn.lpstrFile = fname; |
| 771 |
ofn.nMaxFile = sizeof(fname); |
ofn.nMaxFile = _countof(fname); |
| 772 |
ofn.lpstrTitle = caption; |
ofn.lpstrTitle = caption; |
| 773 |
BOOL Ok = GetSaveFileName(&ofn); |
BOOL Ok = GetSaveFileNameW(&ofn); |
| 774 |
if (Ok) { |
if (Ok) { |
| 775 |
SetDlgItemTextA(Dialog, IDC_FOPT_FILENAME_EDIT, fname); |
SetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, fname); |
| 776 |
} |
} |
| 777 |
|
|
| 778 |
/* restore dir */ |
/* restore dir */ |
| 781 |
break; |
break; |
| 782 |
} |
} |
| 783 |
case IDC_FOPTBIN: |
case IDC_FOPTBIN: |
| 784 |
|
EnableWindow(GetDlgItem(Dialog, IDC_TEXTCODING_DROPDOWN), FALSE); |
| 785 |
|
EnableWindow(GetDlgItem(Dialog, IDC_BOM), FALSE); |
| 786 |
DisableDlgItem(Dialog, IDC_PLAINTEXT, IDC_TIMESTAMP); |
DisableDlgItem(Dialog, IDC_PLAINTEXT, IDC_TIMESTAMP); |
| 787 |
DisableDlgItem(Dialog, IDC_TIMESTAMPTYPE, IDC_TIMESTAMPTYPE); |
DisableDlgItem(Dialog, IDC_TIMESTAMPTYPE, IDC_TIMESTAMPTYPE); |
|
EnableWindow(GetDlgItem(Dialog, IDC_TEXTCODING_DROPDOWN), FALSE); |
|
| 788 |
break; |
break; |
| 789 |
case IDC_FOPTTEXT: |
case IDC_FOPTTEXT: |
| 790 |
EnableWindow(GetDlgItem(Dialog, IDC_TEXTCODING_DROPDOWN), TRUE); |
ArrangeControls(Dialog, work); |
| 791 |
EnableDlgItem(Dialog, IDC_PLAINTEXT, IDC_TIMESTAMP); |
EnableDlgItem(Dialog, IDC_PLAINTEXT, IDC_TIMESTAMP); |
| 792 |
// FALLTHROUGH -- BinFlag が off の時は Timestamp 種別の有効/無効を設定する |
// FALLTHROUGH -- BinFlag が off の時は Timestamp 種別の有効/無効を設定する |
| 793 |
case IDC_TIMESTAMP: |
case IDC_TIMESTAMP: |
| 800 |
break; |
break; |
| 801 |
case IDC_FOPT_FILENAME_EDIT: |
case IDC_FOPT_FILENAME_EDIT: |
| 802 |
if (HIWORD(wParam) == EN_CHANGE){ |
if (HIWORD(wParam) == EN_CHANGE){ |
| 803 |
char filename[MAX_PATH]; |
wchar_t filename[MAX_PATH]; |
| 804 |
GetDlgItemTextA(Dialog, IDC_FOPT_FILENAME_EDIT, filename, _countof(filename)); |
GetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, filename, _countof(filename)); |
| 805 |
CheckLogFile(Dialog, filename); |
CheckLogFile(Dialog, filename, work); |
| 806 |
} |
} |
| 807 |
break; |
break; |
| 808 |
|
case IDC_NEW_OVERWRITE: |
| 809 |
|
if (IsDlgButtonChecked(Dialog, IDC_FOPTTEXT) == BST_CHECKED) { |
| 810 |
|
EnableWindow(GetDlgItem(Dialog, IDC_BOM), TRUE); |
| 811 |
|
EnableWindow(GetDlgItem(Dialog, IDC_TEXTCODING_DROPDOWN), TRUE); |
| 812 |
|
CheckDlgButton(Dialog, IDC_BOM, BST_CHECKED); |
| 813 |
|
SendDlgItemMessage(Dialog, IDC_TEXTCODING_DROPDOWN, CB_SETCURSEL, 0, 0); |
| 814 |
|
} |
| 815 |
|
break; |
| 816 |
|
case IDC_APPEND: |
| 817 |
|
ArrangeControls(Dialog, work); |
| 818 |
|
break; |
| 819 |
} |
} |
| 820 |
break; |
break; |
| 821 |
case WM_DROPFILES: { |
case WM_DROPFILES: { |
| 829 |
wchar_t *filename = (wchar_t *)malloc(sizeof(wchar_t) * (len + 1)); |
wchar_t *filename = (wchar_t *)malloc(sizeof(wchar_t) * (len + 1)); |
| 830 |
_DragQueryFileW(hDrop, 0, filename, len + 1); |
_DragQueryFileW(hDrop, 0, filename, len + 1); |
| 831 |
filename[len] = '\0'; |
filename[len] = '\0'; |
| 832 |
|
CheckRadioButton(Dialog, IDC_NEW_OVERWRITE, IDC_APPEND, IDC_APPEND); |
| 833 |
_SetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, filename); |
_SetDlgItemTextW(Dialog, IDC_FOPT_FILENAME_EDIT, filename); |
| 834 |
SendDlgItemMessage(Dialog, IDC_FOPT_FILENAME_EDIT, EM_SETSEL, len, len); |
SendDlgItemMessage(Dialog, IDC_FOPT_FILENAME_EDIT, EM_SETSEL, len, len); |
| 835 |
free(filename); |
free(filename); |
| 2315 |
|
|
| 2316 |
/** |
/** |
| 2317 |
* ログダイアログを開く |
* ログダイアログを開く |
| 2318 |
|
* @param[in,out] info.filename ファイル名初期値 |
| 2319 |
|
* OK時、ファイル名、不要になったらfree()すること |
| 2320 |
* @retval TRUE [ok] が押された |
* @retval TRUE [ok] が押された |
| 2321 |
* @retval FALSE キャンセルされた |
* @retval FALSE キャンセルされた |
|
* @param[in,out] filename OK時、ファイル名、不要になったらfree()すること |
|
| 2322 |
*/ |
*/ |
| 2323 |
BOOL FLogOpenDialog(char **filename) |
BOOL FLogOpenDialog(HINSTANCE hInst, HWND hWnd, FLogDlgInfo_t *info) |
| 2324 |
{ |
{ |
| 2325 |
LogDlgData_t *data = (LogDlgData_t *)calloc(sizeof(LogDlgData_t), 1); |
LogDlgWork_t *work = (LogDlgWork_t *)calloc(sizeof(LogDlgWork_t), 1); |
| 2326 |
data->filename = FLogGetLogFilename(NULL); |
char *filenameA = ToCharW(info->filename); |
| 2327 |
|
char *srcfnameA = FLogGetLogFilename(filenameA); |
| 2328 |
|
wchar_t *srcfnameW = ToWcharA(srcfnameA); |
| 2329 |
|
free(filenameA); |
| 2330 |
|
free(srcfnameA); |
| 2331 |
|
work->info = info; |
| 2332 |
|
work->info->filename = srcfnameW; |
| 2333 |
|
work->pts = &ts; |
| 2334 |
INT_PTR ret = TTDialogBoxParam( |
INT_PTR ret = TTDialogBoxParam( |
| 2335 |
hInst, MAKEINTRESOURCE(IDD_LOGDLG), |
hInst, MAKEINTRESOURCE(IDD_LOGDLG), |
| 2336 |
HVTWin, LogFnHook, (LPARAM)data); |
hWnd, LogFnHook, (LPARAM)work); |
| 2337 |
if (ret == IDOK) { |
free(srcfnameW); |
| 2338 |
*filename = data->filename; |
free(work); |
|
} |
|
|
free(data); |
|
| 2339 |
return ret == IDOK ? TRUE : FALSE; |
return ret == IDOK ? TRUE : FALSE; |
| 2340 |
} |
} |
| 2341 |
|
|