diff options
author | George Hazan <ghazan@miranda.im> | 2019-07-22 13:57:30 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-07-22 13:57:30 +0300 |
commit | bbd16b7f88b4d37767e48911eaa19e18c9fe4957 (patch) | |
tree | e715338e03242eb950db4e3ccc35a95cdbee5db6 /plugins/ChangeKeyboardLayout | |
parent | cdfeb20a09434adaf691c48188c22add5c5102a2 (diff) |
ChangeKeyboardLayout: code cleaning
Diffstat (limited to 'plugins/ChangeKeyboardLayout')
-rw-r--r-- | plugins/ChangeKeyboardLayout/src/hook_events.cpp | 8 | ||||
-rw-r--r-- | plugins/ChangeKeyboardLayout/src/main.cpp | 4 | ||||
-rw-r--r-- | plugins/ChangeKeyboardLayout/src/options.cpp | 173 | ||||
-rw-r--r-- | plugins/ChangeKeyboardLayout/src/stdafx.h | 4 | ||||
-rw-r--r-- | plugins/ChangeKeyboardLayout/src/text_operations.cpp | 37 | ||||
-rw-r--r-- | plugins/ChangeKeyboardLayout/src/text_operations.h | 12 |
6 files changed, 116 insertions, 122 deletions
diff --git a/plugins/ChangeKeyboardLayout/src/hook_events.cpp b/plugins/ChangeKeyboardLayout/src/hook_events.cpp index acb11976be..b72f16046e 100644 --- a/plugins/ChangeKeyboardLayout/src/hook_events.cpp +++ b/plugins/ChangeKeyboardLayout/src/hook_events.cpp @@ -8,13 +8,13 @@ INT_PTR APIChangeLayout(WPARAM wParam, LPARAM) INT_PTR APIGetLayoutOfText(WPARAM, LPARAM lParam)
{
- LPTSTR ptszInText = (wchar_t*)lParam;
+ wchar_t *ptszInText = (wchar_t*)lParam;
return (INT_PTR)GetLayoutOfText(ptszInText);
}
INT_PTR APIChangeTextLayout(WPARAM wParam, LPARAM lParam)
{
- LPTSTR ptszInText = (wchar_t*)wParam;
+ wchar_t *ptszInText = (wchar_t*)wParam;
CKLLayouts *ckllFromToLay = (CKLLayouts*)lParam;
return (INT_PTR)ChangeTextLayout(ptszInText, ckllFromToLay->hklFrom, ckllFromToLay->hklTo, ckllFromToLay->bTwoWay);
@@ -97,7 +97,7 @@ int ModulesLoaded(WPARAM, LPARAM) // Заполняем конфигурационные строки из базы. Если их там нет - генерируем.
for (int i = 0; i < bLayNum; i++) {
- LPTSTR ptszCurrLayout = GenerateLayoutString(hklLayouts[i]);
+ wchar_t *ptszCurrLayout = GenerateLayoutString(hklLayouts[i]);
LPSTR ptszTemp = GetNameOfLayout(hklLayouts[i]);
ptrW tszValue(g_plugin.getWStringA(ptszTemp));
if (tszValue == 0)
@@ -187,7 +187,7 @@ LRESULT CALLBACK Keyboard_Hook(int code, WPARAM wParam, LPARAM lParam) int CALLBACK CKLPopupDlgProc(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
- LPTSTR ptszPopupText = (LPTSTR)PUGetPluginData(hWnd);
+ wchar_t *ptszPopupText = (LPTSTR)PUGetPluginData(hWnd);
switch (uiMessage) {
case WM_COMMAND:
diff --git a/plugins/ChangeKeyboardLayout/src/main.cpp b/plugins/ChangeKeyboardLayout/src/main.cpp index 473f714b74..96e6a7135e 100644 --- a/plugins/ChangeKeyboardLayout/src/main.cpp +++ b/plugins/ChangeKeyboardLayout/src/main.cpp @@ -1,14 +1,14 @@ #include "stdafx.h"
CMPlugin g_plugin;
-LPTSTR ptszLayStrings[20];
+wchar_t *ptszLayStrings[20];
HANDLE hChangeLayout, hGetLayoutOfText, hChangeTextLayout;
HICON hPopupIcon, hCopyIcon;
HKL hklLayouts[20];
BYTE bLayNum;
HHOOK kbHook_All;
MainOptions moOptions;
-PopupOptions poOptions, poOptionsTemp;
+PopupOptions poOptions;
LPCTSTR ptszKeybEng = L"`1234567890- = \\qwertyuiop[]asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+|QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?";
HKL hklEng = (HKL)0x04090409;
diff --git a/plugins/ChangeKeyboardLayout/src/options.cpp b/plugins/ChangeKeyboardLayout/src/options.cpp index ae4c7bc0b8..d1dc5a676a 100644 --- a/plugins/ChangeKeyboardLayout/src/options.cpp +++ b/plugins/ChangeKeyboardLayout/src/options.cpp @@ -3,43 +3,40 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
static BOOL MainDialogLock = FALSE;
- LPTSTR ptszGenLay, ptszMemLay, ptszFormLay, ptszShortNameLay;
- LPSTR pszNameLay;
- BYTE i;
switch (uiMessage) {
case WM_INITDIALOG:
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);
-
- //Отображаем управляющие клавиши
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_SHIFT, (moOptions.dwHotkey_Layout&0x00000100) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_CTRL, (moOptions.dwHotkey_Layout&0x00000200) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_ALT, (moOptions.dwHotkey_Layout&0x00000400) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_WIN, (moOptions.dwHotkey_Layout&0x00000800) ? BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_SHIFT, (moOptions.dwHotkey_Layout2&0x00000100) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_CTRL, (moOptions.dwHotkey_Layout2&0x00000200) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_ALT, (moOptions.dwHotkey_Layout2&0x00000400) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_WIN, (moOptions.dwHotkey_Layout2&0x00000800) ? BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hWnd, IDC_CHECK_CASE_SHIFT, (moOptions.dwHotkey_Case&0x00000100) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_CASE_CTRL, (moOptions.dwHotkey_Case&0x00000200) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_CASE_ALT, (moOptions.dwHotkey_Case&0x00000400) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_CHECK_CASE_WIN, (moOptions.dwHotkey_Case&0x00000800) ? BST_CHECKED : BST_UNCHECKED);
-
- //Показываем символ из хоткея
- 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);
-
- //Остальные опции
+
+ // Отображаем управляющие клавиши
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_SHIFT, (moOptions.dwHotkey_Layout & 0x00000100) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_CTRL, (moOptions.dwHotkey_Layout & 0x00000200) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_ALT, (moOptions.dwHotkey_Layout & 0x00000400) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_WIN, (moOptions.dwHotkey_Layout & 0x00000800) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_SHIFT, (moOptions.dwHotkey_Layout2 & 0x00000100) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_CTRL, (moOptions.dwHotkey_Layout2 & 0x00000200) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_ALT, (moOptions.dwHotkey_Layout2 & 0x00000400) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_LAYOUT2_WIN, (moOptions.dwHotkey_Layout2 & 0x00000800) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hWnd, IDC_CHECK_CASE_SHIFT, (moOptions.dwHotkey_Case & 0x00000100) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_CASE_CTRL, (moOptions.dwHotkey_Case & 0x00000200) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_CASE_ALT, (moOptions.dwHotkey_Case & 0x00000400) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_CHECK_CASE_WIN, (moOptions.dwHotkey_Case & 0x00000800) ? BST_CHECKED : BST_UNCHECKED);
+
+ // Показываем символ из хоткея
+ 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);
+
+ // Остальные опции
CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_MODE, moOptions.CurrentWordLayout ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_CHECK_LAYOUT_MODE2, moOptions.CurrentWordLayout2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_CHECK_CASE_MODE, moOptions.CurrentWordCase ? BST_CHECKED : BST_UNCHECKED);
@@ -48,7 +45,7 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP CheckDlgButton(hWnd, IDC_CHECK_CLIPBOARD, moOptions.CopyToClipboard ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_CHECK_POPUP, moOptions.ShowPopup ? BST_CHECKED : BST_UNCHECKED);
- //Смена состояния CapsLock
+ // Смена состояния CapsLock
switch (moOptions.bCaseOperations) {
case 1:
CheckDlgButton(hWnd, IDC_RADIO_OFFCAPS, BST_CHECKED);
@@ -62,24 +59,19 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP }
// Отображаем пример конфиг.строки
- ptszMemLay = ptszLayStrings[0];
- SetDlgItemText(hWnd, IDC_EDIT_EXAMPLE, ptszMemLay);
- ptszShortNameLay = GetShortNameOfLayout(hklLayouts[0]);
- SetDlgItemText(hWnd, IDC_STATIC_EXAMPLE, ptszShortNameLay);
- mir_free(ptszShortNameLay);
+ SetDlgItemTextW(hWnd, IDC_EDIT_EXAMPLE, ptszLayStrings[0]);
+ SetDlgItemTextW(hWnd, IDC_STATIC_EXAMPLE, ptrW(GetShortNameOfLayout(hklLayouts[0])));
// Заполняем комбобокс с текущими раскладками
- for(i = 0; i < bLayNum; i++) {
- ptszShortNameLay = GetShortNameOfLayout(hklLayouts[i]);
- SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_ADDSTRING, 0, (LPARAM)ptszShortNameLay);
- mir_free(ptszShortNameLay);
- }
- //Отображаем первую раскладку в списке
+ for (int i = 0; i < bLayNum; i++)
+ SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_ADDSTRING, 0, ptrW(GetShortNameOfLayout(hklLayouts[i])));
+
+ // Отображаем первую раскладку в списке
SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_SETCURSEL, 0, 0);
- ptszMemLay = ptszLayStrings[0];
- SetDlgItemText(hWnd, IDC_EDIT_SET, ptszMemLay);
-
- if (bLayNum != 2) EnableWindow(GetDlgItem(hWnd, IDC_CHECK_TWOWAY), FALSE);
+ SetDlgItemText(hWnd, IDC_EDIT_SET, ptszLayStrings[0]);
+
+ if (bLayNum != 2)
+ EnableWindow(GetDlgItem(hWnd, IDC_CHECK_TWOWAY), FALSE);
MainDialogLock = FALSE;
return TRUE;
@@ -87,7 +79,7 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP switch (LOWORD(wParam)) {
case IDC_HOTKEY_LAYOUT:
case IDC_HOTKEY_LAYOUT2:
- case IDC_HOTKEY_CASE:
+ case IDC_HOTKEY_CASE:
if ((HIWORD(wParam) == EN_CHANGE))
SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
break;
@@ -122,7 +114,7 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP case IDC_COMBO_LANG:
if ((HIWORD(wParam) == CBN_SELCHANGE)) {
MainDialogLock = TRUE;
- ptszMemLay = ptszLayStrings[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)];
+ wchar_t *ptszMemLay = ptszLayStrings[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)];
SetDlgItemText(hWnd, IDC_EDIT_SET, ptszMemLay);
MainDialogLock = FALSE;
}
@@ -134,52 +126,52 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP break;
case IDC_BUTTON_DEFAULT:
- if ((HIWORD(wParam) == BN_CLICKED )) {
- ptszGenLay = GenerateLayoutString(hklLayouts[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)]);
+ if ((HIWORD(wParam) == BN_CLICKED)) {
+ wchar_t *ptszGenLay = GenerateLayoutString(hklLayouts[SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0)]);
SetDlgItemText(hWnd, IDC_EDIT_SET, ptszGenLay);
mir_free(ptszGenLay);
SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
}
break;
}
- break;
+ break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
- case 0:
+ 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);
+ moOptions.dwHotkey_Case = SendDlgItemMessage(hWnd, IDC_HOTKEY_CASE, HKM_GETHOTKEY, 0, 0);
//Допишем к символам управляющие клавиши
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_SHIFT))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_SHIFT))
moOptions.dwHotkey_Layout |= 0x00000100;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_CTRL))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_CTRL))
moOptions.dwHotkey_Layout |= 0x00000200;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_ALT))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_ALT))
moOptions.dwHotkey_Layout |= 0x00000400;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_WIN))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT_WIN))
moOptions.dwHotkey_Layout |= 0x00000800;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_SHIFT))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_SHIFT))
moOptions.dwHotkey_Layout2 |= 0x00000100;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_CTRL))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_CTRL))
moOptions.dwHotkey_Layout2 |= 0x00000200;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_ALT))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_ALT))
moOptions.dwHotkey_Layout2 |= 0x00000400;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_WIN))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_LAYOUT2_WIN))
moOptions.dwHotkey_Layout2 |= 0x00000800;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_SHIFT))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_SHIFT))
moOptions.dwHotkey_Case |= 0x00000100;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_CTRL))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_CTRL))
moOptions.dwHotkey_Case |= 0x00000200;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_ALT))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_ALT))
moOptions.dwHotkey_Case |= 0x00000400;
- if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_WIN))
+ if (IsDlgButtonChecked(hWnd, IDC_CHECK_CASE_WIN))
moOptions.dwHotkey_Case |= 0x00000800;
@@ -197,18 +189,18 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP moOptions.bCaseOperations = 1;
else if (IsDlgButtonChecked(hWnd, IDC_RADIO_IGNORECAPS) == BST_CHECKED)
moOptions.bCaseOperations = 2;
- else moOptions.bCaseOperations = 0;
+ else moOptions.bCaseOperations = 0;
WriteMainOptions();
- ptszFormLay = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
+ wchar_t *ptszFormLay = (LPTSTR)mir_alloc(MaxTextSize * sizeof(wchar_t));
GetDlgItemText(hWnd, IDC_EDIT_SET, ptszFormLay, MaxTextSize);
- i = SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0);
- ptszMemLay = ptszLayStrings[i];
+ int i = SendDlgItemMessage(hWnd, IDC_COMBO_LANG, CB_GETCURSEL, 0, 0);
+ wchar_t *ptszMemLay = ptszLayStrings[i];
if (mir_wstrcmp(ptszMemLay, ptszFormLay) != 0) {
mir_wstrcpy(ptszMemLay, ptszFormLay);
- ptszGenLay = GenerateLayoutString(hklLayouts[i]);
- pszNameLay = GetNameOfLayout(hklLayouts[i]);
+ wchar_t *ptszGenLay = GenerateLayoutString(hklLayouts[i]);
+ char *pszNameLay = GetNameOfLayout(hklLayouts[i]);
if (mir_wstrcmp(ptszMemLay, ptszGenLay) != 0)
g_plugin.setWString(pszNameLay, ptszMemLay);
@@ -218,7 +210,7 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP mir_free(pszNameLay);
mir_free(ptszGenLay);
}
- mir_free(ptszFormLay);
+ mir_free(ptszFormLay);
ptszMemLay = ptszLayStrings[0];
SetDlgItemText(hWnd, IDC_EDIT_EXAMPLE, ptszMemLay);
@@ -232,10 +224,13 @@ INT_PTR CALLBACK DlgMainProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LP return FALSE;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static PopupOptions poOptionsTemp;
+
INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, LPARAM lParam)
{
static BOOL PopupDialogLock = FALSE;
- LPTSTR ptszPopupPreviewText;
DWORD dwTimeOut;
switch (uiMessage) {
@@ -244,7 +239,7 @@ INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, 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 ? BST_CHECKED : BST_UNCHECKED);
@@ -256,13 +251,14 @@ INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, // Таймаут
CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_POPUP, poOptionsTemp.bTimeoutType == PPT_POPUP ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_PERMANENT, poOptionsTemp.bTimeoutType == PPT_PERMANENT ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_CUSTOM, poOptionsTemp.bTimeoutType == PPT_CUSTOM ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hWnd, IDC_RADIO_TIMEOUT_CUSTOM, poOptionsTemp.bTimeoutType == PPT_CUSTOM ? BST_CHECKED : BST_UNCHECKED);
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 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_RADIO_LEFT_DISMISS, poOptionsTemp.bLeftClick == 1 ? BST_CHECKED : BST_UNCHECKED);
+
// Клик правой
CheckDlgButton(hWnd, IDC_RADIO_RIGHT_CLIPBOARD, poOptionsTemp.bRightClick == 0 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hWnd, IDC_RADIO_RIGHT_DISMISS, poOptionsTemp.bRightClick == 1 ? BST_CHECKED : BST_UNCHECKED);
@@ -271,7 +267,7 @@ INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, case WM_COMMAND:
switch (LOWORD(wParam)) {
- case IDC_RADIO_COLOURS_POPUP:
+ case IDC_RADIO_COLOURS_POPUP:
case IDC_RADIO_COLOURS_WINDOWS:
case IDC_RADIO_COLOURS_CUSTOM:
if ((HIWORD(wParam) == BN_CLICKED)) {
@@ -331,16 +327,16 @@ INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, 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);
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
}
break;
case IDC_EDIT_TIMEOUT:
if (HIWORD(wParam) == EN_CHANGE) {
dwTimeOut = GetDlgItemInt(hWnd, IDC_EDIT_TIMEOUT, nullptr, FALSE);
- if (dwTimeOut>255)
+ if (dwTimeOut > 255)
poOptionsTemp.bTimeout = 255;
- else
+ else
poOptionsTemp.bTimeout = dwTimeOut;
if (!PopupDialogLock)
@@ -349,14 +345,12 @@ INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, break;
case IDC_BUTTON_PREVIEW:
- if ((HIWORD(wParam) == BN_CLICKED )) {
- ptszPopupPreviewText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
-
+ if ((HIWORD(wParam) == BN_CLICKED)) {
POPUPDATAW ppd;
wcsncpy(ppd.lpwzContactName, TranslateT(MODULENAME), MAX_CONTACTNAME);
wcsncpy(ppd.lpwzText, L"Ghbdtn? rfr ltkf&", MAX_SECONDLINE);
- switch(poOptionsTemp.bColourType) {
+ switch (poOptionsTemp.bColourType) {
case PPC_POPUP:
ppd.colorBack = ppd.colorText = 0;
break;
@@ -368,9 +362,9 @@ INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, ppd.colorBack = poOptionsTemp.crBackColour;
ppd.colorText = poOptionsTemp.crTextColour;
break;
- }
-
- switch(poOptionsTemp.bTimeoutType) {
+ }
+
+ switch (poOptionsTemp.bTimeoutType) {
case PPT_POPUP:
ppd.iSeconds = 0;
break;
@@ -381,22 +375,21 @@ INT_PTR CALLBACK DlgPopupsProcOptions(HWND hWnd, UINT uiMessage, WPARAM wParam, ppd.iSeconds = poOptionsTemp.bTimeout;
break;
}
- mir_wstrcpy(ptszPopupPreviewText, ppd.lpwzText);
- ppd.PluginData = ptszPopupPreviewText;
+
+ ppd.PluginData = mir_wstrdup(ppd.lpwzText);
ppd.lchIcon = hPopupIcon;
poOptions.paActions[0].lchIcon = hCopyIcon;
ppd.lpActions = poOptions.paActions;
ppd.actionCount = 1;
ppd.PluginWindowProc = (WNDPROC)CKLPopupDlgProc;
- if (PUAddPopupW(&ppd) < 0)
- mir_free(ptszPopupPreviewText);
+ PUAddPopupW(&ppd);
}
break;
}
break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
diff --git a/plugins/ChangeKeyboardLayout/src/stdafx.h b/plugins/ChangeKeyboardLayout/src/stdafx.h index d4504679ca..eaeabd1e5a 100644 --- a/plugins/ChangeKeyboardLayout/src/stdafx.h +++ b/plugins/ChangeKeyboardLayout/src/stdafx.h @@ -103,14 +103,14 @@ extern HKL hklEng; extern BYTE bLayNum;
extern HKL hklLayouts[20];
-extern LPTSTR ptszLayStrings[20];
+extern wchar_t *ptszLayStrings[20];
extern LPCTSTR ptszSeparators;
extern HHOOK kbHook_All;
extern MainOptions moOptions;
-extern PopupOptions poOptions, poOptionsTemp;
+extern PopupOptions poOptions;
LRESULT CALLBACK Keyboard_Hook(int code, WPARAM wParam, LPARAM lParam);
int OnIconsChanged(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/ChangeKeyboardLayout/src/text_operations.cpp b/plugins/ChangeKeyboardLayout/src/text_operations.cpp index dca4916e94..5ccd7e39c1 100644 --- a/plugins/ChangeKeyboardLayout/src/text_operations.cpp +++ b/plugins/ChangeKeyboardLayout/src/text_operations.cpp @@ -24,12 +24,12 @@ static DWORD CALLBACK EditStreamOutRtf(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG c return 0;
}
-LPTSTR GeTStringFromStreamData(EditStreamData *esd)
+wchar_t *GeTStringFromStreamData(EditStreamData *esd)
{
DWORD i, k;
- LPTSTR ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
- LPTSTR ptszTemp = (wchar_t*)esd->pbBuff;
+ wchar_t *ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
+ wchar_t *ptszTemp = (wchar_t*)esd->pbBuff;
for (i = k = 0; i < mir_wstrlen(ptszTemp); i++) {
if ((ptszTemp[i] == 0x0A) || (ptszTemp[i] == 0x2028))
@@ -46,7 +46,7 @@ LPTSTR GeTStringFromStreamData(EditStreamData *esd) }
-BOOL CopyTextToClipboard(LPTSTR ptszText)
+BOOL CopyTextToClipboard(wchar_t *ptszText)
{
if (!OpenClipboard(nullptr))
return FALSE;
@@ -67,10 +67,10 @@ LPSTR GetNameOfLayout(HKL hklLayout) return ptszLayName;
}
-LPTSTR GetShortNameOfLayout(HKL hklLayout)
+wchar_t *GetShortNameOfLayout(HKL hklLayout)
{
wchar_t szLI[20];
- LPTSTR ptszLiShort = (LPTSTR)mir_alloc(3*sizeof(wchar_t));
+ wchar_t *ptszLiShort = (LPTSTR)mir_alloc(3*sizeof(wchar_t));
DWORD dwLcid = MAKELCID(LOWORD(hklLayout), 0);
GetLocaleInfo(dwLcid, LOCALE_SISO639LANGNAME, szLI, 10);
ptszLiShort[0] = toupper(szLI[0]);
@@ -88,12 +88,12 @@ HKL GetNextLayout(HKL hklCurLay) return nullptr;
}
-LPTSTR GenerateLayoutString(HKL hklLayout)
+wchar_t *GenerateLayoutString(HKL hklLayout)
{
BYTE bState[256] = {0};
- LPTSTR ptszLayStr = (LPTSTR)mir_alloc(100 * sizeof(wchar_t));
- LPTSTR ptszTemp = (LPTSTR)mir_alloc(3 * sizeof(wchar_t));
+ wchar_t *ptszLayStr = (LPTSTR)mir_alloc(100 * sizeof(wchar_t));
+ wchar_t *ptszTemp = (LPTSTR)mir_alloc(3 * sizeof(wchar_t));
ptszTemp[0] = 0;
DWORD i;
@@ -128,17 +128,18 @@ LPTSTR GenerateLayoutString(HKL hklLayout) return ptszLayStr;
}
-LPTSTR GetLayoutString(HKL hklLayout)
+wchar_t* GetLayoutString(HKL hklLayout)
{
for (DWORD i = 0; i < bLayNum; i++)
if (hklLayouts[i] == hklLayout)
return ptszLayStrings[i];
+
return nullptr;
}
-LPTSTR ChangeTextCase(LPCTSTR ptszInText)
+wchar_t* ChangeTextCase(LPCTSTR ptszInText)
{
- LPTSTR ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
+ wchar_t *ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
mir_wstrcpy(ptszOutText, ptszInText);
for (DWORD i = 0; i < mir_wstrlen(ptszInText); i++) {
@@ -149,16 +150,16 @@ LPTSTR ChangeTextCase(LPCTSTR ptszInText) return ptszOutText;
}
-LPTSTR ChangeTextLayout(LPCTSTR ptszInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay)
+wchar_t* ChangeTextLayout(LPCTSTR ptszInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay)
{
- LPTSTR ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
+ wchar_t *ptszOutText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
mir_wstrcpy(ptszOutText, ptszInText);
if (hklCurLay == nullptr || hklToLay == nullptr)
return ptszOutText;
- LPTSTR ptszKeybCur = GetLayoutString(hklCurLay);
- LPTSTR ptszKeybNext = GetLayoutString(hklToLay);
+ wchar_t *ptszKeybCur = GetLayoutString(hklCurLay);
+ wchar_t *ptszKeybNext = GetLayoutString(hklToLay);
if (ptszKeybCur == nullptr || ptszKeybNext == nullptr)
return ptszOutText;
@@ -185,7 +186,7 @@ LPTSTR ChangeTextLayout(LPCTSTR ptszInText, HKL hklCurLay, HKL hklToLay, BOOL Tw HKL GetLayoutOfText(LPCTSTR ptszInText)
{
HKL hklCurLay = hklLayouts[0];
- LPTSTR ptszKeybBuff = ptszLayStrings[0];
+ wchar_t *ptszKeybBuff = ptszLayStrings[0];
DWORD dwMaxSymbols = 0, dwTemp = 0;
for (DWORD j = 0; j < mir_wstrlen(ptszInText); j++)
@@ -445,7 +446,7 @@ int ChangeLayout(HWND hTextWnd, BYTE TextOperation, BOOL CurrentWord) //-------------------------------Покажем попапы------------------------------------------
if (moOptions.ShowPopup) {
- LPTSTR ptszPopupText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
+ wchar_t *ptszPopupText = (LPTSTR)mir_alloc(MaxTextSize*sizeof(wchar_t));
mir_wstrcpy(ptszPopupText, ptszMBox);
POPUPDATAW ppd;
diff --git a/plugins/ChangeKeyboardLayout/src/text_operations.h b/plugins/ChangeKeyboardLayout/src/text_operations.h index 6f5fdfed02..c06c266992 100644 --- a/plugins/ChangeKeyboardLayout/src/text_operations.h +++ b/plugins/ChangeKeyboardLayout/src/text_operations.h @@ -3,14 +3,14 @@ #include "stdafx.h"
-BOOL CopyTextToClipboard(LPTSTR ptszText);
+BOOL CopyTextToClipboard(wchar_t *ptszText);
LPSTR GetNameOfLayout(HKL hklLayout);
-LPTSTR GetShortNameOfLayout(HKL hklLayout);
-LPTSTR GenerateLayoutString(HKL hklLayout);
-LPTSTR GetLayoutString(HKL hklLayout);
+wchar_t *GetShortNameOfLayout(HKL hklLayout);
+wchar_t *GenerateLayoutString(HKL hklLayout);
+wchar_t *GetLayoutString(HKL hklLayout);
HKL GetLayoutOfText(LPCTSTR ptzsInText);
-LPTSTR ChangeTextCase(LPCTSTR ptszInText);
-LPTSTR ChangeTextLayout(LPCTSTR ptzsInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay);
+wchar_t *ChangeTextCase(LPCTSTR ptszInText);
+wchar_t *ChangeTextLayout(LPCTSTR ptzsInText, HKL hklCurLay, HKL hklToLay, BOOL TwoWay);
int ChangeLayout(HWND hTextWnd, BYTE bTextOperation, BOOL CurrentWord);
#endif
\ No newline at end of file |