From 9d482ed81c2a6a3361a5a9b2d0efbfc4b6b815c5 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 15 Mar 2013 21:47:10 +0000 Subject: - POPUPDATAT_V2 replaced with POPUPDATAT in all possible cases; - fix: wrong popup initialization code; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@4057 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/ChangeKeyboardLayout/src/options.cpp | 803 +++++++++------------ .../ChangeKeyboardLayout/src/text_operations.cpp | 24 +- 2 files changed, 366 insertions(+), 461 deletions(-) (limited to 'plugins/ChangeKeyboardLayout/src') diff --git a/plugins/ChangeKeyboardLayout/src/options.cpp b/plugins/ChangeKeyboardLayout/src/options.cpp index 63a811b212..44571e1352 100644 --- a/plugins/ChangeKeyboardLayout/src/options.cpp +++ b/plugins/ChangeKeyboardLayout/src/options.cpp @@ -7,493 +7,406 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP LPSTR pszNameLay; BYTE i; - switch (uiMessage) - { + switch (uiMessage) { case WM_INITDIALOG: - { - MainDialogLock = TRUE; - TranslateDialogDefault(hWnd); + MainDialogLock = TRUE; + TranslateDialogDefault(hWnd); - //Горячие клавиши - // Запрещаем вводить в контролы все, кроме обычных кнопок - SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_SETRULES, 0xFF, 0); - SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_SETRULES, 0xFF, 0); - SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_SETRULES, 0xFF, 0); + //Горячие клавиши + // Запрещаем вводить в контролы все, кроме обычных кнопок + SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_SETRULES, 0xFF, 0); + SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_SETRULES, 0xFF, 0); + SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_SETRULES, 0xFF, 0); - //Отображаем управляющие клавиши - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000100), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000200), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_ALT, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000400), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_WIN, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000800), 0); - - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000100), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000200), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_ALT, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000400), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_WIN, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000800), 0); - - SendDlgItemMessage(hWnd, IDC_CHECK_CASE_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000100), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_CASE_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000200), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_CASE_ALT, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000400), 0); - SendDlgItemMessage(hWnd, IDC_CHECK_CASE_WIN, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000800), 0); - - //Показываем символ из хоткея - SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_SETHOTKEY, moOptions.dwHotkey_Layout&0x000000FF, 0); - SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_SETHOTKEY, moOptions.dwHotkey_Layout2&0x000000FF, 0); - SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_SETHOTKEY, moOptions.dwHotkey_Case&0x000000FF, 0); + //Отображаем управляющие клавиши + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000100), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000200), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_ALT, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000400), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_WIN, BM_SETCHECK, (moOptions.dwHotkey_Layout&0x00000800), 0); + + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000100), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000200), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_ALT, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000400), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_WIN, BM_SETCHECK, (moOptions.dwHotkey_Layout2&0x00000800), 0); + + SendDlgItemMessage(hWnd, IDC_CHECK_CASE_SHIFT, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000100), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_CASE_CTRL, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000200), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_CASE_ALT, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000400), 0); + SendDlgItemMessage(hWnd, IDC_CHECK_CASE_WIN, BM_SETCHECK, (moOptions.dwHotkey_Case&0x00000800), 0); + + //Показываем символ из хоткея + SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_SETHOTKEY, moOptions.dwHotkey_Layout&0x000000FF, 0); + SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_SETHOTKEY, moOptions.dwHotkey_Layout2&0x000000FF, 0); + SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_SETHOTKEY, moOptions.dwHotkey_Case&0x000000FF, 0); - //Остальные опции - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE, BM_SETCHECK, moOptions.CurrentWordLayout, 0); - SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE2, BM_SETCHECK, moOptions.CurrentWordLayout2, 0); - SendDlgItemMessage(hWnd, IDC_CHECK_CASE_MODE, BM_SETCHECK, moOptions.CurrentWordCase, 0); - SendDlgItemMessage(hWnd, IDC_CHECK_TWOWAY, BM_SETCHECK, moOptions.TwoWay, 0); - SendDlgItemMessage(hWnd, IDC_CHECK_SYSTEMLAYOUT, BM_SETCHECK, moOptions.ChangeSystemLayout, 0); - SendDlgItemMessage(hWnd, IDC_CHECK_CLIPBOARD, BM_SETCHECK, moOptions.CopyToClipboard, 0); - SendDlgItemMessage(hWnd, IDC_CHECK_POPUP, BM_SETCHECK, moOptions.ShowPopup, 0); - - //Смена состояния CapsLock - switch(moOptions.bCaseOperations) - { - case 1: - SendDlgItemMessage(hWnd, IDC_RADIO_OFFCAPS, BM_SETCHECK, 1, 0); - break; - case 2: - SendDlgItemMessage(hWnd, IDC_RADIO_IGNORECAPS, BM_SETCHECK, 1, 0); - break; - default: - SendDlgItemMessage(hWnd, IDC_RADIO_INVERTCAPS, BM_SETCHECK, 1, 0); - break; - } + //Остальные опции + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE, BM_SETCHECK, moOptions.CurrentWordLayout, 0); + SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE2, BM_SETCHECK, moOptions.CurrentWordLayout2, 0); + SendDlgItemMessage(hWnd, IDC_CHECK_CASE_MODE, BM_SETCHECK, moOptions.CurrentWordCase, 0); + SendDlgItemMessage(hWnd, IDC_CHECK_TWOWAY, BM_SETCHECK, moOptions.TwoWay, 0); + SendDlgItemMessage(hWnd, IDC_CHECK_SYSTEMLAYOUT, BM_SETCHECK, moOptions.ChangeSystemLayout, 0); + SendDlgItemMessage(hWnd, IDC_CHECK_CLIPBOARD, BM_SETCHECK, moOptions.CopyToClipboard, 0); + SendDlgItemMessage(hWnd, IDC_CHECK_POPUP, BM_SETCHECK, moOptions.ShowPopup, 0); + + //Смена состояния CapsLock + switch(moOptions.bCaseOperations) { + case 1: + SendDlgItemMessage(hWnd, IDC_RADIO_OFFCAPS, BM_SETCHECK, 1, 0); + break; + case 2: + SendDlgItemMessage(hWnd, IDC_RADIO_IGNORECAPS, BM_SETCHECK, 1, 0); + break; + default: + SendDlgItemMessage(hWnd, IDC_RADIO_INVERTCAPS, BM_SETCHECK, 1, 0); + break; + } - // Отображаем пример конфиг.строки - ptszMemLay = ptszLayStrings[0]; - SendDlgItemMessage(hWnd, IDC_EDIT_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszMemLay); - ptszShortNameLay = GetShortNameOfLayout(hklLayouts[0]); - SendDlgItemMessage(hWnd, IDC_STATIC_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszShortNameLay); + // Отображаем пример конфиг.строки + ptszMemLay = ptszLayStrings[0]; + SendDlgItemMessage(hWnd, IDC_EDIT_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszMemLay); + ptszShortNameLay = GetShortNameOfLayout(hklLayouts[0]); + SendDlgItemMessage(hWnd, IDC_STATIC_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszShortNameLay); + mir_free(ptszShortNameLay); + + // Заполняем комбобокс с текущими раскладками + for(i = 0; i < bLayNum; i++) { + ptszShortNameLay = GetShortNameOfLayout(hklLayouts[i]); + SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_ADDSTRING, 0, (LPARAM)ptszShortNameLay); mir_free(ptszShortNameLay); - - // Заполняем комбобокс с текущими раскладками - for(i = 0; i < bLayNum; i++) - { - ptszShortNameLay = GetShortNameOfLayout(hklLayouts[i]); - SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_ADDSTRING, 0, (LPARAM)ptszShortNameLay); - mir_free(ptszShortNameLay); - } - //Отображаем первую раскладку в списке - SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_SETCURSEL, 0, 0); - ptszMemLay = ptszLayStrings[0]; - SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszMemLay); - - if (bLayNum != 2) EnableWindow(GetDlgItem(hWnd, IDC_CHECK_TWOWAY), FALSE); - MainDialogLock = FALSE; - return TRUE; } + //Отображаем первую раскладку в списке + SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_SETCURSEL, 0, 0); + ptszMemLay = ptszLayStrings[0]; + SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszMemLay); + + if (bLayNum != 2) EnableWindow(GetDlgItem(hWnd, IDC_CHECK_TWOWAY), FALSE); + MainDialogLock = FALSE; + return TRUE; + case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_HOTKEY_LAYOUT: - case IDC_HOTKEY_LAYOUT2: - case IDC_HOTKEY_CASE: - - { - if ((HIWORD(wParam) == EN_CHANGE)) - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - break; - } - case IDC_CHECK_DETECT: - case IDC_CHECK_LAYOUT_MODE: - case IDC_CHECK_LAYOUT_MODE2: - case IDC_CHECK_CASE_MODE: - case IDC_CHECK_TWOWAY: - case IDC_CHECK_SYSTEMLAYOUT: - case IDC_CHECK_POPUP: - case IDC_CHECK_CLIPBOARD: - case IDC_CHECK_LAYOUT_SHIFT: - case IDC_CHECK_LAYOUT_ALT: - case IDC_CHECK_LAYOUT_CTRL: - case IDC_CHECK_LAYOUT_WIN: - case IDC_CHECK_LAYOUT2_SHIFT: - case IDC_CHECK_LAYOUT2_ALT: - case IDC_CHECK_LAYOUT2_CTRL: - case IDC_CHECK_LAYOUT2_WIN: - case IDC_CHECK_CASE_SHIFT: - case IDC_CHECK_CASE_ALT: - case IDC_CHECK_CASE_CTRL: - case IDC_CHECK_CASE_WIN: - case IDC_RADIO_IGNORECAPS: - case IDC_RADIO_INVERTCAPS: - case IDC_RADIO_OFFCAPS: - - { - if ((HIWORD(wParam) == BN_CLICKED)) - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - break; - } - case IDC_COMBO_LANG: - { - if ((HIWORD(wParam) == CBN_SELCHANGE)) - { - MainDialogLock = TRUE; - ptszMemLay = ptszLayStrings[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)]; - SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszMemLay); - MainDialogLock = FALSE; - } - break; - } - case IDC_EDIT_SET: - { - if ((HIWORD(wParam) == EN_CHANGE) && (!MainDialogLock)) - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - break; - } + switch (LOWORD(wParam)) { + case IDC_HOTKEY_LAYOUT: + case IDC_HOTKEY_LAYOUT2: + case IDC_HOTKEY_CASE: + if ((HIWORD(wParam) == EN_CHANGE)) + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + break; - case IDC_BUTTON_DEFAULT: - { - if ((HIWORD(wParam) == BN_CLICKED )) - { - ptszGenLay = GenerateLayoutString(hklLayouts[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)]); - SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszGenLay); - mir_free(ptszGenLay); - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } - break; - } + case IDC_CHECK_DETECT: + case IDC_CHECK_LAYOUT_MODE: + case IDC_CHECK_LAYOUT_MODE2: + case IDC_CHECK_CASE_MODE: + case IDC_CHECK_TWOWAY: + case IDC_CHECK_SYSTEMLAYOUT: + case IDC_CHECK_POPUP: + case IDC_CHECK_CLIPBOARD: + case IDC_CHECK_LAYOUT_SHIFT: + case IDC_CHECK_LAYOUT_ALT: + case IDC_CHECK_LAYOUT_CTRL: + case IDC_CHECK_LAYOUT_WIN: + case IDC_CHECK_LAYOUT2_SHIFT: + case IDC_CHECK_LAYOUT2_ALT: + case IDC_CHECK_LAYOUT2_CTRL: + case IDC_CHECK_LAYOUT2_WIN: + case IDC_CHECK_CASE_SHIFT: + case IDC_CHECK_CASE_ALT: + case IDC_CHECK_CASE_CTRL: + case IDC_CHECK_CASE_WIN: + case IDC_RADIO_IGNORECAPS: + case IDC_RADIO_INVERTCAPS: + case IDC_RADIO_OFFCAPS: + if ((HIWORD(wParam) == BN_CLICKED)) + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + break; - } - break; - } - case WM_NOTIFY: - { - switch(((LPNMHDR)lParam)->idFrom) - { - case 0: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - // Прочитаем хоткеи - moOptions.dwHotkey_Layout = SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_GETHOTKEY, 0, 0); - moOptions.dwHotkey_Layout2 = SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_GETHOTKEY, 0, 0); - moOptions.dwHotkey_Case = SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_GETHOTKEY, 0, 0); - - //Допишем к символам управляющие клавиши - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_SHIFT, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout |= 0x00000100; - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_CTRL, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout |= 0x00000200; - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_ALT, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout |= 0x00000400; - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_WIN, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout |= 0x00000800; - - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_SHIFT, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout2 |= 0x00000100; - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_CTRL, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout2 |= 0x00000200; - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_ALT, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout2 |= 0x00000400; - if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_WIN, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Layout2 |= 0x00000800; - - if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_SHIFT, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Case |= 0x00000100; - if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_CTRL, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Case |= 0x00000200; - if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_ALT, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Case |= 0x00000400; - if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_WIN, BM_GETCHECK, 0, 0)) - moOptions.dwHotkey_Case |= 0x00000800; - - - //Прочие опции - moOptions.CurrentWordLayout = SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE, BM_GETCHECK, 0, 0); - moOptions.CurrentWordLayout2 = SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE2, BM_GETCHECK, 0, 0); - moOptions.CurrentWordCase = SendDlgItemMessage(hWnd, IDC_CHECK_CASE_MODE, BM_GETCHECK, 0, 0); - moOptions.TwoWay = SendDlgItemMessage(hWnd, IDC_CHECK_TWOWAY, BM_GETCHECK, 0, 0); - moOptions.ChangeSystemLayout = SendDlgItemMessage(hWnd, IDC_CHECK_SYSTEMLAYOUT, BM_GETCHECK, 0, 0); - moOptions.CopyToClipboard = SendDlgItemMessage(hWnd, IDC_CHECK_CLIPBOARD, BM_GETCHECK, 0, 0); - moOptions.ShowPopup = SendDlgItemMessage(hWnd, IDC_CHECK_POPUP, BM_GETCHECK, 0, 0); - - // CapsLock - if (SendDlgItemMessage(hWnd, IDC_RADIO_OFFCAPS, BM_GETCHECK, 0, 0) == BST_CHECKED) - moOptions.bCaseOperations = 1; - else if (SendDlgItemMessage(hWnd, IDC_RADIO_IGNORECAPS, BM_GETCHECK, 0, 0) == BST_CHECKED) - moOptions.bCaseOperations = 2; - else moOptions.bCaseOperations = 0; - - WriteMainOptions(); - - ptszFormLay = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR)); - SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_GETTEXT, (WPARAM) MaxTextSize, (LPARAM)ptszFormLay); - i = SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0); - ptszMemLay = ptszLayStrings[i]; - if(_tcscmp(ptszMemLay, ptszFormLay) != 0) - { - _tcscpy(ptszMemLay, ptszFormLay); - ptszGenLay = GenerateLayoutString(hklLayouts[i]); - pszNameLay = GetNameOfLayout(hklLayouts[i]); - - if(_tcscmp(ptszMemLay, ptszGenLay) != 0) - DBWriteContactSettingTString(NULL, ModuleName, pszNameLay, ptszMemLay); - else - DBDeleteContactSetting(NULL, ModuleName, pszNameLay); - - mir_free(pszNameLay); - mir_free(ptszGenLay); - } - mir_free(ptszFormLay); - - ptszMemLay = ptszLayStrings[0]; - SendDlgItemMessage(hWnd, IDC_EDIT_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszMemLay); - - UnhookWindowsHookEx(kbHook_All); - kbHook_All = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)Keyboard_Hook, NULL, GetCurrentThreadId()); - - break; - } - } - break; - } + case IDC_COMBO_LANG: + if ((HIWORD(wParam) == CBN_SELCHANGE)) { + MainDialogLock = TRUE; + ptszMemLay = ptszLayStrings[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)]; + SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszMemLay); + MainDialogLock = FALSE; } break; - } - case WM_DESTROY: - { + case IDC_EDIT_SET: + if ((HIWORD(wParam) == EN_CHANGE) && (!MainDialogLock)) + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + break; + + case IDC_BUTTON_DEFAULT: + if ((HIWORD(wParam) == BN_CLICKED )) { + ptszGenLay = GenerateLayoutString(hklLayouts[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)]); + SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_SETTEXT, 0, (LPARAM)ptszGenLay); + mir_free(ptszGenLay); + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + } break; } + break; + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + // Прочитаем хоткеи + moOptions.dwHotkey_Layout = SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT, HKM_GETHOTKEY, 0, 0); + moOptions.dwHotkey_Layout2 = SendDlgItemMessage(hWnd, IDC_HOTKEY_LAYOUT2, HKM_GETHOTKEY, 0, 0); + moOptions.dwHotkey_Case = SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_GETHOTKEY, 0, 0); + + //Допишем к символам управляющие клавиши + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_SHIFT, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout |= 0x00000100; + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_CTRL, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout |= 0x00000200; + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_ALT, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout |= 0x00000400; + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_WIN, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout |= 0x00000800; + + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_SHIFT, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout2 |= 0x00000100; + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_CTRL, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout2 |= 0x00000200; + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_ALT, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout2 |= 0x00000400; + if (SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT2_WIN, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Layout2 |= 0x00000800; + + if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_SHIFT, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Case |= 0x00000100; + if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_CTRL, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Case |= 0x00000200; + if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_ALT, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Case |= 0x00000400; + if (SendDlgItemMessage(hWnd, IDC_CHECK_CASE_WIN, BM_GETCHECK, 0, 0)) + moOptions.dwHotkey_Case |= 0x00000800; + + + //Прочие опции + moOptions.CurrentWordLayout = SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE, BM_GETCHECK, 0, 0); + moOptions.CurrentWordLayout2 = SendDlgItemMessage(hWnd, IDC_CHECK_LAYOUT_MODE2, BM_GETCHECK, 0, 0); + moOptions.CurrentWordCase = SendDlgItemMessage(hWnd, IDC_CHECK_CASE_MODE, BM_GETCHECK, 0, 0); + moOptions.TwoWay = SendDlgItemMessage(hWnd, IDC_CHECK_TWOWAY, BM_GETCHECK, 0, 0); + moOptions.ChangeSystemLayout = SendDlgItemMessage(hWnd, IDC_CHECK_SYSTEMLAYOUT, BM_GETCHECK, 0, 0); + moOptions.CopyToClipboard = SendDlgItemMessage(hWnd, IDC_CHECK_CLIPBOARD, BM_GETCHECK, 0, 0); + moOptions.ShowPopup = SendDlgItemMessage(hWnd, IDC_CHECK_POPUP, BM_GETCHECK, 0, 0); + + // CapsLock + if (SendDlgItemMessage(hWnd, IDC_RADIO_OFFCAPS, BM_GETCHECK, 0, 0) == BST_CHECKED) + moOptions.bCaseOperations = 1; + else if (SendDlgItemMessage(hWnd, IDC_RADIO_IGNORECAPS, BM_GETCHECK, 0, 0) == BST_CHECKED) + moOptions.bCaseOperations = 2; + else moOptions.bCaseOperations = 0; + + WriteMainOptions(); + + ptszFormLay = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR)); + SendDlgItemMessage(hWnd, IDC_EDIT_SET, WM_GETTEXT, (WPARAM) MaxTextSize, (LPARAM)ptszFormLay); + i = SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0); + ptszMemLay = ptszLayStrings[i]; + if(_tcscmp(ptszMemLay, ptszFormLay) != 0) { + _tcscpy(ptszMemLay, ptszFormLay); + ptszGenLay = GenerateLayoutString(hklLayouts[i]); + pszNameLay = GetNameOfLayout(hklLayouts[i]); + + if(_tcscmp(ptszMemLay, ptszGenLay) != 0) + DBWriteContactSettingTString(NULL, ModuleName, pszNameLay, ptszMemLay); + else + DBDeleteContactSetting(NULL, ModuleName, pszNameLay); + + mir_free(pszNameLay); + mir_free(ptszGenLay); + } + mir_free(ptszFormLay); + + ptszMemLay = ptszLayStrings[0]; + SendDlgItemMessage(hWnd, IDC_EDIT_EXAMPLE, WM_SETTEXT, 0, (LPARAM)ptszMemLay); + + UnhookWindowsHookEx(kbHook_All); + kbHook_All = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)Keyboard_Hook, NULL, GetCurrentThreadId()); + } + } + break; } return FALSE; } - INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam) { - POPUPDATAT_V2 pdtData; static BOOL PopupDialogLock = FALSE; LPTSTR ptszPopupPreviewText; DWORD dwTimeOut; - switch (uiMessage) - { + switch (uiMessage) { case WM_INITDIALOG: - { - PopupDialogLock = TRUE; - TranslateDialogDefault(hWnd); - poOptionsTemp = poOptions; - - //Цвета - SendDlgItemMessage(hWnd, IDC_CUSTOM_BACK, CPM_SETCOLOUR, 0, poOptionsTemp.crBackColour); - SendDlgItemMessage(hWnd, IDC_CUSTOM_TEXT, CPM_SETCOLOUR, 0, poOptionsTemp.crTextColour); - CheckDlgButton(hWnd, IDC_RADIO_COLOURS_POPUP, poOptionsTemp.bColourType == PPC_POPUP); - CheckDlgButton(hWnd, IDC_RADIO_COLOURS_WINDOWS, poOptionsTemp.bColourType == PPC_WINDOWS); - CheckDlgButton(hWnd, IDC_RADIO_COLOURS_CUSTOM, poOptionsTemp.bColourType == PPC_CUSTOM); - EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_BACK), poOptionsTemp.bColourType == PPC_CUSTOM); - EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_TEXT), poOptionsTemp.bColourType == PPC_CUSTOM); - - // Таймаут - CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_POPUP, poOptionsTemp.bTimeoutType == PPT_POPUP); - CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_PERMANENT, poOptionsTemp.bTimeoutType == PPT_PERMANENT); - CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_CUSTOM, poOptionsTemp.bTimeoutType == PPT_CUSTOM); - SetDlgItemInt(hWnd, IDC_EDIT_TIMEOUT, poOptionsTemp.bTimeout, FALSE); - EnableWindow(GetDlgItem(hWnd, IDC_EDIT_TIMEOUT), poOptionsTemp.bTimeoutType == PPT_CUSTOM); - - // Клик левой - CheckDlgButton(hWnd, IDC_RADIO_LEFT_CLIPBOARD, poOptionsTemp.bLeftClick == 0); - CheckDlgButton(hWnd, IDC_RADIO_LEFT_DISMISS, poOptionsTemp.bLeftClick == 1); - // Клик правой - CheckDlgButton(hWnd, IDC_RADIO_RIGHT_CLIPBOARD, poOptionsTemp.bRightClick == 0); - CheckDlgButton(hWnd, IDC_RADIO_RIGHT_DISMISS, poOptionsTemp.bRightClick == 1); - PopupDialogLock = FALSE; - return TRUE; - } - + PopupDialogLock = TRUE; + TranslateDialogDefault(hWnd); + poOptionsTemp = poOptions; + + //Цвета + SendDlgItemMessage(hWnd, IDC_CUSTOM_BACK, CPM_SETCOLOUR, 0, poOptionsTemp.crBackColour); + SendDlgItemMessage(hWnd, IDC_CUSTOM_TEXT, CPM_SETCOLOUR, 0, poOptionsTemp.crTextColour); + CheckDlgButton(hWnd, IDC_RADIO_COLOURS_POPUP, poOptionsTemp.bColourType == PPC_POPUP); + CheckDlgButton(hWnd, IDC_RADIO_COLOURS_WINDOWS, poOptionsTemp.bColourType == PPC_WINDOWS); + CheckDlgButton(hWnd, IDC_RADIO_COLOURS_CUSTOM, poOptionsTemp.bColourType == PPC_CUSTOM); + EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_BACK), poOptionsTemp.bColourType == PPC_CUSTOM); + EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_TEXT), poOptionsTemp.bColourType == PPC_CUSTOM); + + // Таймаут + CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_POPUP, poOptionsTemp.bTimeoutType == PPT_POPUP); + CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_PERMANENT, poOptionsTemp.bTimeoutType == PPT_PERMANENT); + CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_CUSTOM, poOptionsTemp.bTimeoutType == PPT_CUSTOM); + SetDlgItemInt(hWnd, IDC_EDIT_TIMEOUT, poOptionsTemp.bTimeout, FALSE); + EnableWindow(GetDlgItem(hWnd, IDC_EDIT_TIMEOUT), poOptionsTemp.bTimeoutType == PPT_CUSTOM); + + // Клик левой + CheckDlgButton(hWnd, IDC_RADIO_LEFT_CLIPBOARD, poOptionsTemp.bLeftClick == 0); + CheckDlgButton(hWnd, IDC_RADIO_LEFT_DISMISS, poOptionsTemp.bLeftClick == 1); + // Клик правой + CheckDlgButton(hWnd, IDC_RADIO_RIGHT_CLIPBOARD, poOptionsTemp.bRightClick == 0); + CheckDlgButton(hWnd, IDC_RADIO_RIGHT_DISMISS, poOptionsTemp.bRightClick == 1); + PopupDialogLock = FALSE; + return TRUE; + case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_RADIO_COLOURS_POPUP: - case IDC_RADIO_COLOURS_WINDOWS: - case IDC_RADIO_COLOURS_CUSTOM: - { - if ((HIWORD(wParam) == BN_CLICKED)) - { - if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_POPUP)) - poOptionsTemp.bColourType = PPC_POPUP; - else if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_WINDOWS)) - poOptionsTemp.bColourType = PPC_WINDOWS; - else if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_CUSTOM)) - poOptionsTemp.bColourType = PPC_CUSTOM; - - EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_BACK), poOptionsTemp.bColourType == PPC_CUSTOM); - EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_TEXT), poOptionsTemp.bColourType == PPC_CUSTOM); - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } - } + switch (LOWORD(wParam)) { + case IDC_RADIO_COLOURS_POPUP: + case IDC_RADIO_COLOURS_WINDOWS: + case IDC_RADIO_COLOURS_CUSTOM: + if ((HIWORD(wParam) == BN_CLICKED)) { + if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_POPUP)) + poOptionsTemp.bColourType = PPC_POPUP; + else if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_WINDOWS)) + poOptionsTemp.bColourType = PPC_WINDOWS; + else if (IsDlgButtonChecked(hWnd, IDC_RADIO_COLOURS_CUSTOM)) + poOptionsTemp.bColourType = PPC_CUSTOM; + + EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_BACK), poOptionsTemp.bColourType == PPC_CUSTOM); + EnableWindow(GetDlgItem(hWnd, IDC_CUSTOM_TEXT), poOptionsTemp.bColourType == PPC_CUSTOM); + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_RADIO_TIMEOUT_POPUP: + case IDC_RADIO_TIMEOUT_PERMANENT: + case IDC_RADIO_TIMEOUT_CUSTOM: + if ((HIWORD(wParam) == BN_CLICKED)) { + if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_POPUP)) + poOptionsTemp.bTimeoutType = PPT_POPUP; + else if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_PERMANENT)) + poOptionsTemp.bTimeoutType = PPT_PERMANENT; + if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_CUSTOM)) + poOptionsTemp.bTimeoutType = PPT_CUSTOM; + + EnableWindow(GetDlgItem(hWnd, IDC_EDIT_TIMEOUT), poOptionsTemp.bTimeoutType == PPT_CUSTOM); + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_RADIO_LEFT_CLIPBOARD: + case IDC_RADIO_LEFT_DISMISS: + if ((HIWORD(wParam) == BN_CLICKED)) { + if (IsDlgButtonChecked(hWnd, IDC_RADIO_LEFT_CLIPBOARD)) + poOptionsTemp.bLeftClick = 0; + else if (IsDlgButtonChecked(hWnd, IDC_RADIO_LEFT_DISMISS)) + poOptionsTemp.bLeftClick = 1; + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_RADIO_RIGHT_CLIPBOARD: + case IDC_RADIO_RIGHT_DISMISS: + if ((HIWORD(wParam) == BN_CLICKED)) { + if (IsDlgButtonChecked(hWnd, IDC_RADIO_RIGHT_CLIPBOARD)) + poOptionsTemp.bRightClick = 0; + else if (IsDlgButtonChecked(hWnd, IDC_RADIO_RIGHT_DISMISS)) + poOptionsTemp.bRightClick = 1; + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_CUSTOM_BACK: + case IDC_CUSTOM_TEXT: + if (HIWORD(wParam) == CBN_SELCHANGE) { + poOptionsTemp.crBackColour = SendDlgItemMessage(hWnd, IDC_CUSTOM_BACK, CPM_GETCOLOUR, 0, 0); + poOptionsTemp.crTextColour = SendDlgItemMessage(hWnd, IDC_CUSTOM_TEXT, CPM_GETCOLOUR, 0, 0); + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + } + break; + + case IDC_EDIT_TIMEOUT: + if (HIWORD(wParam) == EN_CHANGE) { + dwTimeOut = GetDlgItemInt(hWnd, IDC_EDIT_TIMEOUT, NULL, FALSE); + if (dwTimeOut>255) + poOptionsTemp.bTimeout = 255; + else + poOptionsTemp.bTimeout = dwTimeOut; + + if (!PopupDialogLock) + SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); + } + break; - - case IDC_RADIO_TIMEOUT_POPUP: - case IDC_RADIO_TIMEOUT_PERMANENT: - case IDC_RADIO_TIMEOUT_CUSTOM: - { - if ((HIWORD(wParam) == BN_CLICKED)) - { - if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_POPUP)) - poOptionsTemp.bTimeoutType = PPT_POPUP; - else if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_PERMANENT)) - poOptionsTemp.bTimeoutType = PPT_PERMANENT; - if (IsDlgButtonChecked(hWnd, IDC_RADIO_TIMEOUT_CUSTOM)) - poOptionsTemp.bTimeoutType = PPT_CUSTOM; - - EnableWindow(GetDlgItem(hWnd, IDC_EDIT_TIMEOUT), poOptionsTemp.bTimeoutType == PPT_CUSTOM); - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } + case IDC_BUTTON_PREVIEW: + if ((HIWORD(wParam) == BN_CLICKED )) { + ptszPopupPreviewText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR)); + + POPUPDATAT_V2 pdtData = { 0 }; + pdtData.cbSize = sizeof(POPUPDATAT_V2); + _tcsncpy(pdtData.lptzContactName, TranslateT(ModuleName), MAX_CONTACTNAME); + _tcsncpy(pdtData.lptzText, _T("Ghbdtn? rfr ltkf&"), MAX_SECONDLINE); + + switch(poOptionsTemp.bColourType) { + case PPC_POPUP: + pdtData.colorBack = pdtData.colorText = 0; break; - } - - case IDC_RADIO_LEFT_CLIPBOARD: - case IDC_RADIO_LEFT_DISMISS: - { - if ((HIWORD(wParam) == BN_CLICKED)) - { - if (IsDlgButtonChecked(hWnd, IDC_RADIO_LEFT_CLIPBOARD)) - poOptionsTemp.bLeftClick = 0; - else if (IsDlgButtonChecked(hWnd, IDC_RADIO_LEFT_DISMISS)) - poOptionsTemp.bLeftClick = 1; - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } + case PPC_WINDOWS: + pdtData.colorBack = GetSysColor(COLOR_BTNFACE); + pdtData.colorText = GetSysColor(COLOR_WINDOWTEXT); break; - } - - case IDC_RADIO_RIGHT_CLIPBOARD: - case IDC_RADIO_RIGHT_DISMISS: - { - if ((HIWORD(wParam) == BN_CLICKED)) - { - if (IsDlgButtonChecked(hWnd, IDC_RADIO_RIGHT_CLIPBOARD)) - poOptionsTemp.bRightClick = 0; - else if (IsDlgButtonChecked(hWnd, IDC_RADIO_RIGHT_DISMISS)) - poOptionsTemp.bRightClick = 1; - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } + case PPC_CUSTOM: + pdtData.colorBack = poOptionsTemp.crBackColour; + pdtData.colorText = poOptionsTemp.crTextColour; break; - } + } - case IDC_CUSTOM_BACK: - case IDC_CUSTOM_TEXT: - { - if (HIWORD(wParam) == CBN_SELCHANGE) - { - poOptionsTemp.crBackColour = SendDlgItemMessage(hWnd, IDC_CUSTOM_BACK, CPM_GETCOLOUR, 0, 0); - poOptionsTemp.crTextColour = SendDlgItemMessage(hWnd, IDC_CUSTOM_TEXT, CPM_GETCOLOUR, 0, 0); - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } + switch(poOptionsTemp.bTimeoutType) { + case PPT_POPUP: + pdtData.iSeconds = 0; break; - } - case IDC_EDIT_TIMEOUT: - { - if (HIWORD(wParam) == EN_CHANGE) - { - dwTimeOut = GetDlgItemInt(hWnd, IDC_EDIT_TIMEOUT, NULL, FALSE); - if (dwTimeOut>255) - poOptionsTemp.bTimeout = 255; - else - poOptionsTemp.bTimeout = dwTimeOut; - - if (!PopupDialogLock) - SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0); - } + case PPT_PERMANENT: + pdtData.iSeconds = -1; break; - } - - case IDC_BUTTON_PREVIEW: - { - if ((HIWORD(wParam) == BN_CLICKED )) - { - ptszPopupPreviewText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR)); - - pdtData.cbSize = sizeof(POPUPDATAT_V2); - ZeroMemory(&pdtData, sizeof(pdtData)); - _tcsncpy(pdtData.lptzContactName, TranslateT(ModuleName), MAX_CONTACTNAME); - _tcsncpy(pdtData.lptzText, _T("Ghbdtn? rfr ltkf&"), MAX_SECONDLINE); - - switch(poOptionsTemp.bColourType) - { - case PPC_POPUP: - pdtData.colorBack = pdtData.colorText = 0; - break; - case PPC_WINDOWS: - pdtData.colorBack = GetSysColor(COLOR_BTNFACE); - pdtData.colorText = GetSysColor(COLOR_WINDOWTEXT); - break; - case PPC_CUSTOM: - pdtData.colorBack = poOptionsTemp.crBackColour; - pdtData.colorText = poOptionsTemp.crTextColour; - break; - default: - break; - } - switch(poOptionsTemp.bTimeoutType) - { - case PPT_POPUP: - pdtData.iSeconds = 0; - break; - case PPT_PERMANENT: - pdtData.iSeconds = -1; - break; - case PPC_CUSTOM: - pdtData.iSeconds = poOptionsTemp.bTimeout; - break; - } - _tcscpy(ptszPopupPreviewText, pdtData.lptzText); - pdtData.PluginData = ptszPopupPreviewText; - pdtData.lchIcon = hPopupIcon; - poOptions.paActions[0].lchIcon = hCopyIcon; - pdtData.lpActions = poOptions.paActions; - pdtData.actionCount = 1; - pdtData.PluginWindowProc = (WNDPROC)CKLPopupDlgProc; - - if (CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pdtData, APF_NEWDATA)<0) - mir_free(ptszPopupPreviewText); - } + case PPC_CUSTOM: + pdtData.iSeconds = poOptionsTemp.bTimeout; break; } - - default: - break; - } - break; -} - - case WM_NOTIFY: - { - switch(((LPNMHDR)lParam)->idFrom) - { - case 0: - { - switch (((LPNMHDR)lParam)->code) - { - case PSN_APPLY: - { - poOptions = poOptionsTemp; - WritePopupOptions(); - break; - } - } - break; + _tcscpy(ptszPopupPreviewText, pdtData.lptzText); + pdtData.PluginData = ptszPopupPreviewText; + pdtData.lchIcon = hPopupIcon; + poOptions.paActions[0].lchIcon = hCopyIcon; + pdtData.lpActions = poOptions.paActions; + pdtData.actionCount = 1; + pdtData.PluginWindowProc = (WNDPROC)CKLPopupDlgProc; + + if ( CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pdtData, APF_NEWDATA) < 0) + mir_free(ptszPopupPreviewText); } + break; } break; - } - case WM_DESTROY: - { + case WM_NOTIFY: + switch(((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_APPLY: + poOptions = poOptionsTemp; + WritePopupOptions(); + } + } break; } - - } return FALSE; } - diff --git a/plugins/ChangeKeyboardLayout/src/text_operations.cpp b/plugins/ChangeKeyboardLayout/src/text_operations.cpp index f35610625a..a7c00aa4ea 100644 --- a/plugins/ChangeKeyboardLayout/src/text_operations.cpp +++ b/plugins/ChangeKeyboardLayout/src/text_operations.cpp @@ -268,8 +268,6 @@ int ChangeLayout(HWND hTextWnd, BYTE TextOperation, BOOL CurrentWord) EDITSTREAM esStream = {0}; struct EditStreamData esdData; - POPUPDATAT_V2 pdtData; - esStream.dwCookie = (DWORD)&esdData; esStream.pfnCallback = EditStreamOutRtf; @@ -524,17 +522,16 @@ int ChangeLayout(HWND hTextWnd, BYTE TextOperation, BOOL CurrentWord) if (moOptions.CopyToClipboard) CopyTextToClipboard(ptszMBox); //-------------------------------Покажем попапы------------------------------------------ - if (moOptions.ShowPopup) - { + if (moOptions.ShowPopup) { ptszPopupText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(TCHAR)); _tcscpy(ptszPopupText, ptszMBox); + POPUPDATAT_V2 pdtData = { 0 }; pdtData.cbSize = sizeof(POPUPDATAT_V2); - ZeroMemory(&pdtData, sizeof(pdtData)); _tcsncpy(pdtData.lptzContactName, TranslateT(ModuleName), MAX_CONTACTNAME); _tcsncpy(pdtData.lptzText, ptszPopupText, MAX_SECONDLINE); - switch(poOptions.bColourType) - { + + switch(poOptions.bColourType) { case PPC_POPUP: pdtData.colorBack = pdtData.colorText = 0; break; @@ -546,11 +543,9 @@ int ChangeLayout(HWND hTextWnd, BYTE TextOperation, BOOL CurrentWord) pdtData.colorBack = poOptions.crBackColour; pdtData.colorText = poOptions.crTextColour; break; - default: - break; } - switch(poOptions.bTimeoutType) - { + + switch(poOptions.bTimeoutType) { case PPT_POPUP: pdtData.iSeconds = 0; break; @@ -562,22 +557,19 @@ int ChangeLayout(HWND hTextWnd, BYTE TextOperation, BOOL CurrentWord) break; } pdtData.PluginData = ptszPopupText; + pdtData.PluginWindowProc = (WNDPROC)CKLPopupDlgProc; pdtData.lchIcon = hPopupIcon; poOptions.paActions[0].lchIcon = hCopyIcon; pdtData.lpActions = poOptions.paActions; pdtData.actionCount = 1; - - pdtData.PluginWindowProc = (WNDPROC)CKLPopupDlgProc; - if (CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pdtData, APF_NEWDATA)<0) - { + if ( CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pdtData, APF_NEWDATA) < 0) { mir_free(ptszPopupText); MessageBox(NULL, ptszMBox, TranslateT(ModuleName), MB_ICONINFORMATION); } } mir_free(ptszMBox); - } //------------------Редактируемые поля ---------------------------- else -- cgit v1.2.3