diff options
author | George Hazan <ghazan@miranda.im> | 2021-01-06 13:41:49 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-01-06 13:41:49 +0300 |
commit | 27256f195c41e483a12bd1506acbbde5dd1aa3ec (patch) | |
tree | 1b3018f641c83883296cc065ca228fca04f4025f /plugins | |
parent | c8283bbae2f7a24c21c862f1769e8566b0b5144f (diff) |
minor code cleaning
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/BuddyExpectator/src/options.cpp | 10 | ||||
-rw-r--r-- | plugins/BuddyPounce/src/dialog.cpp | 34 | ||||
-rw-r--r-- | plugins/FileAsMessage/src/optionsdlg.cpp | 32 |
3 files changed, 31 insertions, 45 deletions
diff --git a/plugins/BuddyExpectator/src/options.cpp b/plugins/BuddyExpectator/src/options.cpp index a95abc0a5c..467828b600 100644 --- a/plugins/BuddyExpectator/src/options.cpp +++ b/plugins/BuddyExpectator/src/options.cpp @@ -195,9 +195,7 @@ static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, break;
case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code) {
+ switch (((NMHDR*)lParam)->code) {
case PSN_APPLY:
//iAbsencePeriod
int num = GetDlgItemInt(hwndDlg, IDC_EDIT_ABSENCE, nullptr, FALSE);
@@ -255,7 +253,6 @@ static INT_PTR CALLBACK OptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, }
break;
}
- }
return 0;
}
@@ -381,9 +378,9 @@ static INT_PTR CALLBACK PopupOptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wP }
break;
+
case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
+ NMHDR *nmhdr = (NMHDR *)lParam;
switch (nmhdr->code) {
case PSN_APPLY:
if (IsDlgButtonChecked(hwndDlg, IDC_COLORS_POPUP)) {
@@ -416,7 +413,6 @@ static INT_PTR CALLBACK PopupOptionsFrameProc(HWND hwndDlg, UINT uMsg, WPARAM wP }
break;
}
- }
return 0;
}
diff --git a/plugins/BuddyPounce/src/dialog.cpp b/plugins/BuddyPounce/src/dialog.cpp index d4fc86a852..129f8504bd 100644 --- a/plugins/BuddyPounce/src/dialog.cpp +++ b/plugins/BuddyPounce/src/dialog.cpp @@ -267,25 +267,25 @@ INT_PTR CALLBACK BuddyPounceDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM case IDC_SIMPLE:
case IDOK:
- {
- MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETITEMDATA, SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETCURSEL, 0, 0), 0);
- int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)) + 1;
- if (length > 1) {
- wchar_t *text = (wchar_t*)mir_alloc(length * sizeof(wchar_t));
- if (!text) {
- msg(TranslateT("Couldn't allocate enough memory"), L"");
- break;
+ {
+ MCONTACT hContact = (MCONTACT)SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETITEMDATA, SendDlgItemMessage(hwnd, IDC_CONTACTS, CB_GETCURSEL, 0, 0), 0);
+ int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_MESSAGE)) + 1;
+ if (length > 1) {
+ wchar_t *text = (wchar_t *)mir_alloc(length * sizeof(wchar_t));
+ if (!text) {
+ msg(TranslateT("Couldn't allocate enough memory"), L"");
+ break;
+ }
+ GetDlgItemText(hwnd, IDC_MESSAGE, text, length);
+ g_plugin.setWString(hContact, "PounceMsg", text);
+ mir_free(text);
}
- GetDlgItemText(hwnd, IDC_MESSAGE, text, length);
- g_plugin.setWString(hContact, "PounceMsg", text);
- mir_free(text);
+ else g_plugin.delSetting(hContact, "PounceMsg");
+ saveLastSetting(hContact, hwnd);
}
- else g_plugin.delSetting(hContact, "PounceMsg");
- saveLastSetting(hContact, hwnd);
- } // fall through
- if (LOWORD(wParam) == IDC_SIMPLE)
- CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POUNCE_SIMPLE), nullptr, BuddyPounceSimpleDlgProc, (LPARAM)((windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact);
- // fall through
+ if (LOWORD(wParam) == IDC_SIMPLE)
+ CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_POUNCE_SIMPLE), nullptr, BuddyPounceSimpleDlgProc, (LPARAM)((windowInfo *)GetWindowLongPtr(hwnd, GWLP_USERDATA))->hContact);
+ __fallthrough;
case IDCANCEL:
if (wi->SendIfMy) DestroyWindow(wi->SendIfMy);
diff --git a/plugins/FileAsMessage/src/optionsdlg.cpp b/plugins/FileAsMessage/src/optionsdlg.cpp index c1d6be2df8..1a0e7b8239 100644 --- a/plugins/FileAsMessage/src/optionsdlg.cpp +++ b/plugins/FileAsMessage/src/optionsdlg.cpp @@ -37,8 +37,7 @@ int settingId[] = //
INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- switch (uMsg)
- {
+ switch (uMsg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
@@ -49,23 +48,16 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l SetDlgItemInt(hwndDlg, -settingId[indx], g_plugin.getDword(settingName[indx], settingDefault[indx]), FALSE);
CheckDlgButton(hwndDlg, IDC_ALPHANUM, g_plugin.getDword("base64", 1) ? BST_CHECKED : BST_UNCHECKED);
-
return TRUE;
case WM_COMMAND:
- if (//MAKEWPARAM(IDC_AUTO, BN_CLICKED) != wParam ||
- MAKEWPARAM(IDC_ALPHANUM, BN_CLICKED) != wParam)
- {
- for (int indx = 0; indx < _countof(settingId); indx++)
- {
- if (LOWORD(wParam) == abs(settingId[indx]))
- {
- if (settingId[indx] > 0)
- {
+ if (MAKEWPARAM(IDC_ALPHANUM, BN_CLICKED) != wParam) {
+ for (int indx = 0; indx < _countof(settingId); indx++) {
+ if (LOWORD(wParam) == abs(settingId[indx])) {
+ if (settingId[indx] > 0) {
if (HIWORD(wParam) != CPN_COLOURCHANGED) return FALSE;
}
- else
- {
+ else {
if (HIWORD(wParam) != EN_CHANGE) return FALSE;
if ((HWND)lParam != GetFocus()) return FALSE;
}
@@ -79,19 +71,17 @@ INT_PTR CALLBACK OptionsDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l return FALSE;
case WM_NOTIFY:
- if ((((NMHDR*)lParam)->idFrom == 0) && (((LPNMHDR)lParam)->code == PSN_APPLY))
- {
+ if ((((NMHDR *)lParam)->idFrom == 0) && (((LPNMHDR)lParam)->code == PSN_APPLY)) {
int value;
BOOL succ;
- for (int indx = 0; indx < _countof(settingId); indx++)
- {
+ for (int indx = 0; indx < _countof(settingId); indx++) {
if (settingId[indx] > 0)
value = SendDlgItemMessage(hwndDlg, settingId[indx], CPM_GETCOLOUR, 0, 0);
- else
- {
+ else {
value = GetDlgItemInt(hwndDlg, -settingId[indx], &succ, FALSE);
- if (!succ) value = settingDefault[indx];
+ if (!succ)
+ value = settingDefault[indx];
}
g_plugin.setDword(settingName[indx], value);
}
|