diff options
Diffstat (limited to 'options.cpp')
-rw-r--r-- | options.cpp | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/options.cpp b/options.cpp index 632be78..39639cb 100644 --- a/options.cpp +++ b/options.cpp @@ -53,12 +53,14 @@ int ReplacerOptInit(WPARAM wParam,LPARAM lParam) } HWND hwnd_list_p = NULL; +int item_num = 0; +bool bTargetWord = false; +bool bEdit = false; static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { HWND hwndList1 = GetDlgItem(hwndDlg, IDC_LIST1); HWND hwndList2 = GetDlgItem(hwndDlg, IDC_LIST2); - static int item_num = 0; LVCOLUMN col = {0}; LVITEM item = {0}; NMLISTVIEW * hdr = (NMLISTVIEW *) lParam; @@ -109,6 +111,7 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { case IDC_ADD: { + bEdit = false; ShowWordEditDialog(); if(hwnd_list_p == hwndList1) { @@ -120,6 +123,7 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, break; case IDC_CHANGE: { + bEdit = true; ShowWordEditDialog(); if(hwnd_list_p == hwndList1) { @@ -150,12 +154,15 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, { if(hdr && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != (-1)) { - if(hdr->hdr.code == LVN_ITEMCHANGED) + if(hdr->hdr.code == NM_CLICK) { + hwnd_list_p = hdr->hdr.hwndFrom; item_num = hdr->iItem; + bTargetWord = (hwnd_list_p==hwndList2)?true:false; int iRow = 0; if(hdr->hdr.hwndFrom == hwndList1) { + ListView_DeleteAllItems(hwndList2); char *setting = new char [32]; TCHAR *buf = NULL; mir_snprintf(setting, 31, "szTargetWords%d", hdr->iItem); @@ -167,7 +174,19 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, for(;;) { if(p1 = wstring::npos) + { + if(end == 0) + { + item.mask = LVIF_TEXT; + item.iSubItem = 0; + item.pszText = _T("<Click here for add word>"); + iRow = ListView_InsertItem(hwndList2, &item); + ListView_SetItemText(hwndList2, iRow, 0, _T("<Click here for add word>")); + ZeroMemory(&item,sizeof(item)); + ListView_SetColumnWidth(hwndList2, 0, LVSCW_AUTOSIZE); + } break; + } p2 = str.find(_T("\n"), p1); if(p2 < end || p2 == p1) break; @@ -186,7 +205,6 @@ static BOOL CALLBACK DlgProcReplacerOpts(HWND hwndDlg, UINT msg, WPARAM wParam, if(hdr->hdr.hwndFrom == hwndList2) { } - hwnd_list_p = hdr->hdr.hwndFrom; } } switch (((LPNMHDR)lParam)->code) @@ -212,6 +230,16 @@ static BOOL CALLBACK DlgProcWordEditDialog(HWND hwndDlg, UINT msg, WPARAM wParam case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); + if(bEdit) + { + SetWindowText(hwndDlg, bTargetWord?_T("Edit target word or phrase"):_T("Edit source word or phrase")); + TCHAR word[512]; + ListView_GetItemText(hwnd_list_p, item_num, 0, word, 16); + MessageBox(0, word, _T(""), MB_OK); + } + else + SetWindowText(hwndDlg, bTargetWord?_T("Add target word or phrase"):_T("Add source word or phrase")); + return TRUE; } |