summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-01-26 22:31:20 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-01-26 22:31:27 +0300
commit391980ce1e890445542441eeb5d9f9cc18ae1baf (patch)
treeee1b165175dcdaeeaabd2ddb822542e648663a90
parentbf8ad124d03b4fd059318d9ba8889b11faaf5b53 (diff)
code optimization
-rw-r--r--plugins/BasicHistory/src/BasicHistory.cpp6
-rw-r--r--plugins/BasicHistory/src/Options.cpp4
-rw-r--r--plugins/Clist_modern/src/modern_clc.cpp42
-rw-r--r--plugins/Clist_modern/src/modern_clcopts.cpp39
-rw-r--r--plugins/Clist_modern/src/modern_clistopts.cpp8
-rw-r--r--plugins/Clist_modern/src/modern_clui.cpp9
-rw-r--r--plugins/Clist_modern/src/modern_contact.cpp7
-rw-r--r--plugins/Clist_modern/src/modern_rowheight_funcs.cpp16
-rw-r--r--plugins/Clist_modern/src/modern_rowtemplateopt.cpp14
-rw-r--r--plugins/Clist_modern/src/modern_statusbar_options.cpp8
-rw-r--r--plugins/Clist_modern/src/modern_sync.cpp3
-rw-r--r--plugins/Clist_nicer/src/CLCButton.cpp18
-rw-r--r--plugins/Clist_nicer/src/clcopts.cpp29
-rw-r--r--plugins/Clist_nicer/src/extBackg.cpp9
-rw-r--r--plugins/Clist_nicer/src/groupmenu.cpp14
-rw-r--r--plugins/Clist_nicer/src/rowheight_funcs.cpp17
-rw-r--r--plugins/Clist_nicer/src/viewmodes.cpp6
-rw-r--r--plugins/CloudFile/src/icons.cpp18
-rw-r--r--plugins/DbEditorPP/src/icons.cpp16
-rw-r--r--plugins/FingerprintNG/src/options.cpp14
-rw-r--r--plugins/HistorySweeperLight/src/options.cpp18
-rw-r--r--plugins/IEView/src/Options.cpp4
-rw-r--r--plugins/IEView/src/Template.cpp14
-rw-r--r--plugins/Import/src/import.cpp2
-rw-r--r--plugins/Import/src/miranda.cpp12
-rw-r--r--plugins/Import/src/utils.cpp12
-rw-r--r--plugins/MenuItemEx/src/main.cpp24
-rw-r--r--plugins/MenuItemEx/src/options.cpp20
-rw-r--r--plugins/MirLua/src/mlua_icons.cpp12
-rwxr-xr-xplugins/Msg_Export/src/utils.cpp4
-rw-r--r--plugins/PluginUpdater/src/DlgUpdate.cpp6
-rw-r--r--plugins/PluginUpdater/src/Options.cpp11
-rw-r--r--plugins/Popup/src/actions.cpp17
-rw-r--r--plugins/Popup/src/icons.cpp12
-rw-r--r--plugins/Popup/src/opt_class.cpp76
-rw-r--r--plugins/SMS/src/SMS_svc.cpp6
-rw-r--r--plugins/Scriver/src/globals.cpp22
-rw-r--r--plugins/Scriver/src/msglog.cpp4
-rw-r--r--plugins/SpellChecker/src/dictionary.cpp28
-rw-r--r--plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp6
-rw-r--r--plugins/StatusManager/src/KeepStatus/keepstatus.cpp12
-rw-r--r--plugins/StatusManager/src/StartupStatus/startupstatus.cpp12
-rw-r--r--plugins/TabSRMM/src/chat_main.cpp6
-rw-r--r--plugins/TabSRMM/src/chat_options.cpp32
-rw-r--r--plugins/TabSRMM/src/chat_window.cpp18
-rw-r--r--plugins/TabSRMM/src/hotkeyhandler.cpp4
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp22
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp4
-rw-r--r--plugins/TabSRMM/src/msgoptions.cpp4
-rw-r--r--plugins/TabSRMM/src/msgs.cpp27
-rw-r--r--plugins/TabSRMM/src/tabctrl.cpp6
-rw-r--r--plugins/TabSRMM/src/themeio.cpp27
-rw-r--r--plugins/TabSRMM/src/themes.cpp6
-rw-r--r--plugins/TabSRMM/src/typingnotify.cpp14
-rw-r--r--plugins/TipperYM/src/options.cpp1292
-rw-r--r--plugins/TipperYM/src/translations.cpp339
-rw-r--r--plugins/UserInfoEx/src/ctrl_annivedit.cpp4
-rw-r--r--plugins/UserInfoEx/src/dlg_propsheet.cpp8
-rw-r--r--plugins/UserInfoEx/src/mir_icolib.cpp12
-rw-r--r--plugins/UserInfoEx/src/psp_options.cpp48
-rw-r--r--plugins/UserInfoEx/src/svc_reminder.cpp8
-rw-r--r--plugins/Variables/src/contact.cpp6
-rw-r--r--plugins/Weather/src/weather_icons.cpp6
-rw-r--r--protocols/FacebookRM/src/theme.cpp6
-rw-r--r--protocols/IRCG/src/options.cpp16
-rw-r--r--protocols/IcqOscarJ/src/capabilities.cpp6
-rw-r--r--protocols/IcqOscarJ/src/dlgproc.cpp3
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.cpp6
-rw-r--r--protocols/JabberG/src/jabber_chat.cpp45
-rw-r--r--protocols/JabberG/src/jabber_console.cpp35
-rw-r--r--protocols/JabberG/src/jabber_disco.cpp71
-rw-r--r--protocols/JabberG/src/jabber_groupchat.cpp6
-rw-r--r--protocols/JabberG/src/jabber_icolib.cpp30
-rw-r--r--protocols/JabberG/src/jabber_iqid_muc.cpp12
-rwxr-xr-xprotocols/JabberG/src/jabber_misc.cpp6
-rwxr-xr-xprotocols/JabberG/src/jabber_opt.cpp8
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp20
-rw-r--r--protocols/MRA/src/MraChat.cpp4
-rw-r--r--protocols/MSN/src/msn_chat.cpp4
-rw-r--r--protocols/MSN/src/msn_menu.cpp4
-rw-r--r--protocols/MSN/src/msn_mime.cpp6
-rw-r--r--protocols/MSN/src/msn_opts.cpp6
-rw-r--r--protocols/SkypeWeb/src/skype_db.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_icons.cpp12
-rw-r--r--protocols/SkypeWeb/src/skype_menus.cpp4
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp6
-rw-r--r--protocols/Tox/src/tox_icons.cpp12
-rw-r--r--protocols/Tox/src/tox_menus.cpp4
-rw-r--r--protocols/Twitter/src/theme.cpp10
-rw-r--r--protocols/Twitter/src/ui.cpp8
-rw-r--r--protocols/VKontakte/src/misc.cpp52
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp6
-rw-r--r--src/core/stdaway/src/sendmsg.cpp24
-rw-r--r--src/core/stdclist/src/clcopts.cpp14
-rw-r--r--src/core/stdclist/src/contact.cpp8
-rw-r--r--src/core/stdidle/src/options.cpp4
-rw-r--r--src/core/stdmsg/src/msglog.cpp4
-rw-r--r--src/core/stdmsg/src/msgoptions.cpp8
-rw-r--r--src/mir_app/src/DefaultExtraIcons.cpp11
-rw-r--r--src/mir_app/src/chat_tools.cpp4
-rw-r--r--src/mir_app/src/clistmod.cpp4
-rw-r--r--src/mir_app/src/findadd.cpp4
-rw-r--r--src/mir_app/src/ignore.cpp5
-rw-r--r--src/mir_app/src/netliblog.cpp8
-rw-r--r--src/mir_app/src/newplugins.cpp16
-rw-r--r--src/mir_app/src/proto_accs.cpp4
-rw-r--r--src/mir_app/src/skinicons.cpp6
-rw-r--r--src/mir_app/src/utils.cpp12
-rw-r--r--src/mir_app/src/visibility.cpp8
109 files changed, 1472 insertions, 1608 deletions
diff --git a/plugins/BasicHistory/src/BasicHistory.cpp b/plugins/BasicHistory/src/BasicHistory.cpp
index 9240b619aa..3b0723658f 100644
--- a/plugins/BasicHistory/src/BasicHistory.cpp
+++ b/plugins/BasicHistory/src/BasicHistory.cpp
@@ -173,9 +173,9 @@ void InitIcolib()
HICON LoadIconEx(int iconId, bool big)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return IcoLib_GetIconByHandle(iconList[i].hIcolib, big);
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return IcoLib_GetIconByHandle(it.hIcolib, big);
return nullptr;
}
diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp
index 900ff701a1..6df06b59b0 100644
--- a/plugins/BasicHistory/src/Options.cpp
+++ b/plugins/BasicHistory/src/Options.cpp
@@ -866,8 +866,8 @@ INT_PTR CALLBACK Options::DlgProcOptsMain(HWND hwndDlg, UINT msg, WPARAM wParam,
HWND ftpLog = GetDlgItem(hwndDlg, IDC_WINSCPLOG);
ComboBox_AddString(events, TranslateT("Incoming events"));
ComboBox_AddString(events, TranslateT("Outgoing events"));
- for (int i = 0; i < _countof(EventNames); ++i)
- ComboBox_AddString(events, TranslateW(EventNames[i].name));
+ for (auto &it : EventNames)
+ ComboBox_AddString(events, TranslateW(it.name));
ComboBox_AddString(defFilter, TranslateT("Default history events"));
ComboBox_AddString(defFilter, TranslateT("All events"));
diff --git a/plugins/Clist_modern/src/modern_clc.cpp b/plugins/Clist_modern/src/modern_clc.cpp
index 2feb1ebcfe..2b80d741cd 100644
--- a/plugins/Clist_modern/src/modern_clc.cpp
+++ b/plugins/Clist_modern/src/modern_clc.cpp
@@ -29,8 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "modern_clcpaint.h"
-int ModernSkinOptInit(WPARAM wParam, LPARAM lParam);
-
/*
* Private module variables
*/
@@ -69,23 +67,25 @@ static int clcHookIconsChanged(WPARAM, LPARAM)
if (MirandaExiting())
return 0;
- for (int i = 0; i < _countof(g_pAvatarOverlayIcons); i++) {
- g_pAvatarOverlayIcons[i].listID = -1;
- g_pStatusOverlayIcons[i].listID = -1;
- }
+ for (auto &it : g_pAvatarOverlayIcons)
+ it.listID = -1;
+ for (auto &it : g_pStatusOverlayIcons)
+ it.listID = -1;
if (hAvatarOverlays)
ImageList_Destroy(hAvatarOverlays);
hAvatarOverlays = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, _countof(g_pAvatarOverlayIcons) * 2, 1);
- for (int i = 0; i < _countof(g_pAvatarOverlayIcons); i++) {
- HICON hIcon = IcoLib_GetIcon(g_pAvatarOverlayIcons[i].name);
- g_pAvatarOverlayIcons[i].listID = ImageList_AddIcon(hAvatarOverlays, hIcon);
- IcoLib_Release(g_pAvatarOverlayIcons[i].name);
+ for (auto &it : g_pAvatarOverlayIcons) {
+ HICON hIcon = IcoLib_GetIcon(it.name);
+ it.listID = ImageList_AddIcon(hAvatarOverlays, hIcon);
+ IcoLib_Release(it.name);
+ }
- hIcon = IcoLib_GetIcon(g_pStatusOverlayIcons[i].name);
- g_pStatusOverlayIcons[i].listID = ImageList_AddIcon(hAvatarOverlays, hIcon);
- IcoLib_Release(g_pStatusOverlayIcons[i].name);
+ for (auto &it : g_pStatusOverlayIcons) {
+ HICON hIcon = IcoLib_GetIcon(it.name);
+ it.listID = ImageList_AddIcon(hAvatarOverlays, hIcon);
+ IcoLib_Release(it.name);
}
g_hListeningToIcon = IcoLib_GetIcon("LISTENING_TO_ICON");
@@ -1564,18 +1564,18 @@ static int clcHookModulesLoaded(WPARAM, LPARAM)
IcoLib_AddIcon(&sid);
sid.section.a = LPGEN("Contact list") "/" LPGEN("Avatar overlay");
- for (int i = 0; i < _countof(g_pAvatarOverlayIcons); i++) {
- sid.description.a = g_pAvatarOverlayIcons[i].description;
- sid.pszName = g_pAvatarOverlayIcons[i].name;
- sid.iDefaultIndex = -g_pAvatarOverlayIcons[i].id;
+ for (auto &it : g_pAvatarOverlayIcons) {
+ sid.description.a = it.description;
+ sid.pszName = it.name;
+ sid.iDefaultIndex = -it.id;
IcoLib_AddIcon(&sid);
}
sid.section.a = LPGEN("Contact list") "/" LPGEN("Status overlay");
- for (int i = 0; i < _countof(g_pStatusOverlayIcons); i++) {
- sid.description.a = g_pStatusOverlayIcons[i].description;
- sid.pszName = g_pStatusOverlayIcons[i].name;
- sid.iDefaultIndex = -g_pStatusOverlayIcons[i].id;
+ for (auto &it : g_pStatusOverlayIcons) {
+ sid.description.a = it.description;
+ sid.pszName = it.name;
+ sid.iDefaultIndex = -it.id;
IcoLib_AddIcon(&sid);
}
diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp
index 8a9a54e6d1..3ec5ff83e4 100644
--- a/plugins/Clist_modern/src/modern_clcopts.cpp
+++ b/plugins/Clist_modern/src/modern_clcopts.cpp
@@ -378,8 +378,8 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
{
DWORD exStyle = db_get_dw(0, "CLC", "ExStyle", GetDefaultExStyle());
- for (int i = 0; i < _countof(checkBoxToStyleEx); i++)
- CheckDlgButton(hwndDlg, checkBoxToStyleEx[i].id, (exStyle&checkBoxToStyleEx[i].flag) ^ (checkBoxToStyleEx[i].flag*checkBoxToStyleEx[i].neg) ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : checkBoxToStyleEx)
+ CheckDlgButton(hwndDlg, it.id, (exStyle & it.flag) ^ (it.flag * it.neg) ? BST_CHECKED : BST_UNCHECKED);
UDACCEL accel[2] = { { 0, 10 }, { 2, 50 } };
SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETRANGE, 0, MAKELONG(999, 0));
@@ -439,9 +439,9 @@ static INT_PTR CALLBACK DlgProcClistListOpts(HWND hwndDlg, UINT msg, WPARAM wPar
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
DWORD exStyle = 0;
- for (int i = 0; i < _countof(checkBoxToStyleEx); i++)
- if ((IsDlgButtonChecked(hwndDlg, checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].neg)
- exStyle |= checkBoxToStyleEx[i].flag;
+ for (auto &it : checkBoxToStyleEx)
+ if ((IsDlgButtonChecked(hwndDlg, it.id) == 0) == it.neg)
+ exStyle |= it.flag;
db_set_dw(0, "CLC", "ExStyle", exStyle);
DWORD fullGreyoutFlags = MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS));
@@ -500,14 +500,13 @@ static INT_PTR CALLBACK DlgProcClistOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
CheckDlgButton(hwndDlg, IDC_HILIGHTMODE2, db_get_b(0, "CLC", "HiLightMode", SETTING_HILIGHTMODE_DEFAULT) == 2 ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_HILIGHTMODE3, db_get_b(0, "CLC", "HiLightMode", SETTING_HILIGHTMODE_DEFAULT) == 3 ? BST_CHECKED : BST_UNCHECKED);
{
- int i, item;
int s1, s2, s3;
- for (i = 0; i < _countof(sortby); i++) {
- item = SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_ADDSTRING, 0, (LPARAM)TranslateW(sortby[i]));
+ for (auto &it : sortby) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_SETITEMDATA, item, 0);
- item = SendDlgItemMessage(hwndDlg, IDC_CLSORT2, CB_ADDSTRING, 0, (LPARAM)TranslateW(sortby[i]));
+ item = SendDlgItemMessage(hwndDlg, IDC_CLSORT2, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_CLSORT2, CB_SETITEMDATA, item, 0);
- item = SendDlgItemMessage(hwndDlg, IDC_CLSORT3, CB_ADDSTRING, 0, (LPARAM)TranslateW(sortby[i]));
+ item = SendDlgItemMessage(hwndDlg, IDC_CLSORT3, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_CLSORT3, CB_SETITEMDATA, item, 0);
}
@@ -515,7 +514,7 @@ static INT_PTR CALLBACK DlgProcClistOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
s2 = db_get_b(0, "CList", "SortBy2", SETTING_SORTBY2_DEFAULT);
s3 = db_get_b(0, "CList", "SortBy3", SETTING_SORTBY3_DEFAULT);
- for (i = 0; i < _countof(sortby); i++) {
+ for (int i = 0; i < _countof(sortby); i++) {
if (s1 == sortbyValue[i])
SendDlgItemMessage(hwndDlg, IDC_CLSORT1, CB_SETCURSEL, i, 0);
if (s2 == sortbyValue[i])
@@ -799,8 +798,8 @@ static INT_PTR CALLBACK DlgProcClistBehaviourOpts(HWND hwndDlg, UINT msg, WPARAM
EnableWindow(GetDlgItem(hwndDlg, IDC_STATIC01), IsDlgButtonChecked(hwndDlg, IDC_AUTOHIDE));
{
wchar_t *hidemode[] = { TranslateT("Hide to tray"), TranslateT("Behind left edge"), TranslateT("Behind right edge") };
- for (int i = 0; i < _countof(hidemode); i++) {
- int item = SendDlgItemMessage(hwndDlg, IDC_HIDEMETHOD, CB_ADDSTRING, 0, (LPARAM)hidemode[i]);
+ for (auto &it : hidemode) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_HIDEMETHOD, CB_ADDSTRING, 0, (LPARAM)it);
SendDlgItemMessage(hwndDlg, IDC_HIDEMETHOD, CB_SETITEMDATA, item, 0);
SendDlgItemMessage(hwndDlg, IDC_HIDEMETHOD, CB_SETCURSEL, db_get_b(0, "ModernData", "HideBehind", SETTING_HIDEBEHIND_DEFAULT), 0);
}
@@ -1356,8 +1355,8 @@ static INT_PTR CALLBACK DlgProcClcBkgOpts(HWND hwndDlg, UINT msg, WPARAM wParam,
case M_BKGR_UPDATE:
{
int isChecked = IsDlgButtonChecked(hwndDlg, IDC_BITMAP);
- for (int indx = 0; indx < _countof(bitmapRelatedControls); indx++)
- EnableWindow(GetDlgItem(hwndDlg, bitmapRelatedControls[indx]), isChecked);
+ for (auto &it : bitmapRelatedControls)
+ EnableWindow(GetDlgItem(hwndDlg, it), isChecked);
}
break;
@@ -1526,11 +1525,11 @@ int ClcOptInit(WPARAM wParam, LPARAM)
odp.pfnDlgProc = DlgProcClistListOpts;
odp.flags = ODPF_BOLDGROUPS;
- for (int i = 0; i < _countof(clist_opt_items); i++) {
- odp.pszTemplate = MAKEINTRESOURCEA(clist_opt_items[i].id);
- odp.szTab.a = clist_opt_items[i].name;
- odp.pfnDlgProc = clist_opt_items[i].wnd_proc;
- odp.flags = ODPF_BOLDGROUPS | clist_opt_items[i].flag;
+ for (auto &it : clist_opt_items) {
+ odp.pszTemplate = MAKEINTRESOURCEA(it.id);
+ odp.szTab.a = it.name;
+ odp.pfnDlgProc = it.wnd_proc;
+ odp.flags = ODPF_BOLDGROUPS | it.flag;
Options_AddPage(wParam, &odp);
}
diff --git a/plugins/Clist_modern/src/modern_clistopts.cpp b/plugins/Clist_modern/src/modern_clistopts.cpp
index 210d57dedb..da51bc085a 100644
--- a/plugins/Clist_modern/src/modern_clistopts.cpp
+++ b/plugins/Clist_modern/src/modern_clistopts.cpp
@@ -937,10 +937,10 @@ int CListOptInit(WPARAM wParam, LPARAM)
odp.szTitle.a = LPGEN("Row items");
odp.flags = ODPF_BOLDGROUPS;
- for (int i = 0; i < _countof(row_opt_items); i++) {
- odp.pszTemplate = MAKEINTRESOURCEA(row_opt_items[i].id);
- odp.szTab.a = row_opt_items[i].name;
- odp.pfnDlgProc = row_opt_items[i].wnd_proc;
+ for (auto &it : row_opt_items) {
+ odp.pszTemplate = MAKEINTRESOURCEA(it.id);
+ odp.szTab.a = it.name;
+ odp.pfnDlgProc = it.wnd_proc;
Options_AddPage(wParam, &odp);
}
return 0;
diff --git a/plugins/Clist_modern/src/modern_clui.cpp b/plugins/Clist_modern/src/modern_clui.cpp
index 074ba54b7c..6f0eb8630a 100644
--- a/plugins/Clist_modern/src/modern_clui.cpp
+++ b/plugins/Clist_modern/src/modern_clui.cpp
@@ -470,10 +470,11 @@ HICON GetMainStatusOverlay(int STATUS)
void UnloadAvatarOverlayIcon()
{
- for (int i = 0; i < _countof(g_pAvatarOverlayIcons); i++) {
- g_pAvatarOverlayIcons[i].listID = -1;
- g_pStatusOverlayIcons[i].listID = -1;
- }
+ for (auto &it : g_pAvatarOverlayIcons)
+ it.listID = -1;
+ for (auto &it : g_pStatusOverlayIcons)
+ it.listID = -1;
+
ImageList_Destroy(hAvatarOverlays);
hAvatarOverlays = nullptr;
DestroyIcon_protect(g_hListeningToIcon);
diff --git a/plugins/Clist_modern/src/modern_contact.cpp b/plugins/Clist_modern/src/modern_contact.cpp
index 45f4c29615..3e15378cf1 100644
--- a/plugins/Clist_modern/src/modern_contact.cpp
+++ b/plugins/Clist_modern/src/modern_contact.cpp
@@ -51,9 +51,10 @@ static int GetContactStatus(MCONTACT hContact)
static int GetStatusModeOrdering(int statusMode)
{
- for (int i = 0; i < _countof(statusModeOrder); i++)
- if (statusModeOrder[i].status == statusMode)
- return statusModeOrder[i].order;
+ for (auto &it : statusModeOrder)
+ if (it.status == statusMode)
+ return it.order;
+
return 1000;
}
diff --git a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
index 8c09d9f65c..3bf61c98a3 100644
--- a/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
+++ b/plugins/Clist_modern/src/modern_rowheight_funcs.cpp
@@ -343,15 +343,15 @@ static int other_fonts[] = { FONTID_OPENGROUPS, FONTID_OPENGROUPCOUNTS, FONTID_C
int RowHeights_GetMaxRowHeight(ClcData *dat, HWND hwnd)
{
- int max_height = 0, i, tmp;
+ int max_height = 0;
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
if (!dat->text_ignore_size_for_row_height) {
// Get contact font size
- tmp = 0;
- for (i = 0; i < _countof(contact_fonts); i++)
- if (tmp < dat->fontModernInfo[contact_fonts[i]].fontHeight)
- tmp = dat->fontModernInfo[contact_fonts[i]].fontHeight;
+ int tmp = 0;
+ for (auto &it : contact_fonts)
+ if (tmp < dat->fontModernInfo[it].fontHeight)
+ tmp = dat->fontModernInfo[it].fontHeight;
if (dat->text_replace_smileys && dat->first_line_draw_smileys && !dat->text_resize_smileys)
tmp = max(tmp, dat->text_smiley_height);
@@ -373,9 +373,9 @@ int RowHeights_GetMaxRowHeight(ClcData *dat, HWND hwnd)
}
// Get other font sizes
- for (i = 0; i < _countof(other_fonts); i++)
- if (max_height < dat->fontModernInfo[other_fonts[i]].fontHeight)
- max_height = dat->fontModernInfo[other_fonts[i]].fontHeight;
+ for (auto &it : other_fonts)
+ if (max_height < dat->fontModernInfo[it].fontHeight)
+ max_height = dat->fontModernInfo[it].fontHeight;
}
// Avatar size
diff --git a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
index 5d3cbcfb1f..1ac420b9bf 100644
--- a/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
+++ b/plugins/Clist_modern/src/modern_rowtemplateopt.cpp
@@ -354,24 +354,22 @@ INT_PTR CALLBACK DlgTmplEditorOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SendDlgItemMessage(hwndDlg, IDC_SPINCONTWIDTH, UDM_SETRANGE, 0, MAKELONG(999, 0));
SendDlgItemMessage(hwndDlg, IDC_SPINCONTHEIGHT, UDM_SETRANGE, 0, MAKELONG(999, 0));
- int i, item;
-
- for (i = 0; i < _countof(types); i++) {
- item = SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_ADDSTRING, 0, (LPARAM)TranslateW(types[i]));
+ for (auto &it : types) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETITEMDATA, item, 0);
}
SendDlgItemMessage(hwndDlg, IDC_CONTTYPE, CB_SETCURSEL, 0, 0);
wchar_t *h_alignment[] = { L"left", L"hCenter", L"right" };
- for (i = 0; i < _countof(h_alignment); i++) {
- item = SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(h_alignment[i]));
+ for (auto &it : h_alignment) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETITEMDATA, item, 0);
}
SendDlgItemMessage(hwndDlg, IDC_HALIGN, CB_SETCURSEL, 0, 0);
wchar_t *v_alignment[] = { L"top", L"vCenter", L"bottom" };
- for (i = 0; i < _countof(v_alignment); i++) {
- item = SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(v_alignment[i]));
+ for (auto &it : v_alignment) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETITEMDATA, item, 0);
}
SendDlgItemMessage(hwndDlg, IDC_VALIGN, CB_SETCURSEL, 0, 0);
diff --git a/plugins/Clist_modern/src/modern_statusbar_options.cpp b/plugins/Clist_modern/src/modern_statusbar_options.cpp
index 99fd49ffe1..b2baf89122 100644
--- a/plugins/Clist_modern/src/modern_statusbar_options.cpp
+++ b/plugins/Clist_modern/src/modern_statusbar_options.cpp
@@ -238,15 +238,15 @@ INT_PTR CALLBACK DlgProcSBarOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{
wchar_t *align[] = { LPGENW("Left"), LPGENW("Center"), LPGENW("Right") };
- for (int i = 0; i < _countof(align); i++)
- SendDlgItemMessage(hwndDlg, IDC_SBAR_HORIZ_ALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(align[i]));
+ for (auto &it : align)
+ SendDlgItemMessage(hwndDlg, IDC_SBAR_HORIZ_ALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_SBAR_HORIZ_ALIGN, CB_SETCURSEL, db_get_b(0, "CLUI", "Align", SETTING_ALIGN_DEFAULT), 0);
}
{
wchar_t *align[] = { LPGENW("Top"), LPGENW("Center"), LPGENW("Bottom") };
- for (int i = 0; i < _countof(align); i++)
- SendDlgItemMessage(hwndDlg, IDC_SBAR_VERT_ALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(align[i]));
+ for (auto &it : align)
+ SendDlgItemMessage(hwndDlg, IDC_SBAR_VERT_ALIGN, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_SBAR_VERT_ALIGN, CB_SETCURSEL, db_get_b(0, "CLUI", "VAlign", SETTING_VALIGN_DEFAULT), 0);
}
diff --git a/plugins/Clist_modern/src/modern_sync.cpp b/plugins/Clist_modern/src/modern_sync.cpp
index 2715e8da36..50bec6b3dc 100644
--- a/plugins/Clist_modern/src/modern_sync.cpp
+++ b/plugins/Clist_modern/src/modern_sync.cpp
@@ -81,10 +81,9 @@ int SyncCall(void * vproc, int count, ...)
{
LPARAM params[5];
va_list va;
- int i;
params[0] = (LPARAM)count;
va_start(va, count);
- for (i = 0; i < count && i < _countof(params) - 1; i++)
+ for (int i = 0; i < count && i < _countof(params) - 1; i++)
params[i + 1] = va_arg(va, LPARAM);
va_end(va);
diff --git a/plugins/Clist_nicer/src/CLCButton.cpp b/plugins/Clist_nicer/src/CLCButton.cpp
index 49bbfd86f9..e22b9c53b0 100644
--- a/plugins/Clist_nicer/src/CLCButton.cpp
+++ b/plugins/Clist_nicer/src/CLCButton.cpp
@@ -72,27 +72,27 @@ static void InitDefaultButtons()
void ClcSetButtonState(int ctrlid, int status)
{
- for (int i = 0; i < _countof(BTNS); i++)
- if (BTNS[i].ctrlid == ctrlid) {
- CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)BTNS[i].hButton, status ? TTBST_PUSHED : 0);
+ for (auto &it : BTNS)
+ if (it.ctrlid == ctrlid) {
+ CallService(MS_TTB_SETBUTTONSTATE, (WPARAM)it.hButton, status ? TTBST_PUSHED : 0);
break;
}
}
HWND ClcGetButtonWindow(int ctrlid)
{
- for (int i = 0; i < _countof(BTNS); i++)
- if (BTNS[i].ctrlid == ctrlid)
- return BTNS[i].hwndButton;
+ for (auto &it : BTNS)
+ if (it.ctrlid == ctrlid)
+ return it.hwndButton;
return nullptr;
}
int ClcGetButtonId(HWND hwnd)
{
- for (int i = 0; i < _countof(BTNS); i++)
- if (BTNS[i].hwndButton == hwnd)
- return BTNS[i].ctrlid;
+ for (auto &it : BTNS)
+ if (it.hwndButton == hwnd)
+ return it.ctrlid;
return 0;
}
diff --git a/plugins/Clist_nicer/src/clcopts.cpp b/plugins/Clist_nicer/src/clcopts.cpp
index d7342d00da..b2464eeb00 100644
--- a/plugins/Clist_nicer/src/clcopts.cpp
+++ b/plugins/Clist_nicer/src/clcopts.cpp
@@ -156,8 +156,8 @@ static INT_PTR CALLBACK DlgProcDspGroups(HWND hwndDlg, UINT msg, WPARAM wParam,
SendDlgItemMessage(hwndDlg, IDC_GROUPALIGN, CB_INSERTSTRING, -1, (LPARAM)TranslateT("Automatic (RTL)"));
DWORD exStyle = db_get_dw(NULL, "CLC", "ExStyle", pcli->pfnGetDefaultExStyle());
- for (int i = 0; i < _countof(checkBoxToGroupStyleEx); i++)
- CheckDlgButton(hwndDlg, checkBoxToGroupStyleEx[i].id, (exStyle & checkBoxToGroupStyleEx[i].flag) ^ (checkBoxToGroupStyleEx[i].flag * checkBoxToGroupStyleEx[i].not_t) ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : checkBoxToGroupStyleEx)
+ CheckDlgButton(hwndDlg, it.id, (exStyle & it.flag) ^ (it.flag * it.not_t) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_NOGROUPICON, (cfg::dat.dwFlags & CLUI_FRAME_NOGROUPICON) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CENTERGROUPNAMES, db_get_b(NULL, "CLCExt", "EXBK_CenterGroupnames", 0) ? BST_CHECKED : BST_UNCHECKED);
@@ -195,11 +195,11 @@ static INT_PTR CALLBACK DlgProcDspGroups(HWND hwndDlg, UINT msg, WPARAM wParam,
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
DWORD exStyle = db_get_dw(NULL, "CLC", "ExStyle", pcli->pfnGetDefaultExStyle());
- for (int i = 0; i < _countof(checkBoxToGroupStyleEx); i++) {
- if ((IsDlgButtonChecked(hwndDlg, checkBoxToGroupStyleEx[i].id) == 0) == checkBoxToGroupStyleEx[i].not_t)
- exStyle |= checkBoxToGroupStyleEx[i].flag;
+ for (auto &it : checkBoxToGroupStyleEx) {
+ if ((IsDlgButtonChecked(hwndDlg, it.id) == 0) == it.not_t)
+ exStyle |= it.flag;
else
- exStyle &= ~(checkBoxToGroupStyleEx[i].flag);
+ exStyle &= ~(it.flag);
}
db_set_dw(NULL, "CLC", "ExStyle", exStyle);
@@ -602,8 +602,8 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETACCEL, _countof(accel), (LPARAM)&accel);
SendDlgItemMessage(hwndDlg, IDC_SMOOTHTIMESPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CLC", "ScrollTime", CLCDEFAULT_SCROLLTIME), 0));
- for (int i = 0; i < _countof(checkBoxToStyleEx); i++)
- CheckDlgButton(hwndDlg, checkBoxToStyleEx[i].id, (exStyle & checkBoxToStyleEx[i].flag) ^ (checkBoxToStyleEx[i].flag * checkBoxToStyleEx[i].not_t) ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : checkBoxToStyleEx)
+ CheckDlgButton(hwndDlg, it.id, (exStyle & it.flag) ^ (it.flag * it.not_t) ? BST_CHECKED : BST_UNCHECKED);
}
CheckDlgButton(hwndDlg, IDC_FULLROWSELECT, (cfg::dat.dwFlags & CLUI_FULLROWSELECT) ? BST_CHECKED : BST_UNCHECKED);
@@ -658,16 +658,15 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
if (!opt_clc_main_changed)
return TRUE;
- int i;
DWORD exStyle = db_get_dw(NULL, "CLC", "ExStyle", CLCDEFAULT_EXSTYLE);
- for (i = 0; i < sizeof(checkBoxToStyleEx) / sizeof(checkBoxToStyleEx[0]); i++)
- exStyle &= ~(checkBoxToStyleEx[i].flag);
+ for (auto &it : checkBoxToStyleEx)
+ exStyle &= ~(it.flag);
+
+ for (auto &it : checkBoxToStyleEx)
+ if ((IsDlgButtonChecked(hwndDlg, it.id) == 0) == it.not_t)
+ exStyle |= it.flag;
- for (i = 0; i < sizeof(checkBoxToStyleEx) / sizeof(checkBoxToStyleEx[0]); i++) {
- if ((IsDlgButtonChecked(hwndDlg, checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].not_t)
- exStyle |= checkBoxToStyleEx[i].flag;
- }
db_set_dw(NULL, "CLC", "ExStyle", exStyle);
DWORD fullGreyoutFlags = MakeCheckBoxTreeFlags(GetDlgItem(hwndDlg, IDC_GREYOUTOPTS));
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp
index a5ee0a0fe6..182f17b269 100644
--- a/plugins/Clist_nicer/src/extBackg.cpp
+++ b/plugins/Clist_nicer/src/extBackg.cpp
@@ -271,10 +271,9 @@ StatusItems_t *GetProtocolStatusItem(const char *szProto)
// fills the struct with the settings in the database
void LoadExtBkSettingsFromDB()
{
- int i, n;
- for (i = 0; i < _countof(_StatusItems); i++) {
+ for (auto &it : _StatusItems) {
StatusItems_t *p = (StatusItems_t*)mir_alloc(sizeof(StatusItems_t));
- *p = _StatusItems[i];
+ *p = it;
arStatusItems.insert(p);
}
@@ -282,7 +281,7 @@ void LoadExtBkSettingsFromDB()
PROTOACCOUNT **accs;
Proto_EnumAccounts(&protoCount, &accs);
- for (i = 0; i < protoCount; i++) {
+ for (int i = 0; i < protoCount; i++) {
StatusItems_t *p = (StatusItems_t*)mir_alloc(sizeof(StatusItems_t));
*p = _StatusItems[0];
ID_EXTBK_LAST++;
@@ -296,7 +295,7 @@ void LoadExtBkSettingsFromDB()
arStatusItems.insert(p);
}
- for (n = 0; n < arStatusItems.getCount(); n++) {
+ for (int n = 0; n < arStatusItems.getCount(); n++) {
StatusItems_t *p = arStatusItems[n];
if (p->statusID == ID_EXTBKSEPARATOR)
continue;
diff --git a/plugins/Clist_nicer/src/groupmenu.cpp b/plugins/Clist_nicer/src/groupmenu.cpp
index 58550d1706..b4fe9c1384 100644
--- a/plugins/Clist_nicer/src/groupmenu.cpp
+++ b/plugins/Clist_nicer/src/groupmenu.cpp
@@ -74,8 +74,8 @@ static INT_PTR CommandHelper(WPARAM wParam, LPARAM)
static int OnBuildGroupMenu(WPARAM, LPARAM)
{
- for (int i = 0; i < _countof(hAppearanceItems); i++)
- Menu_SetChecked(hAppearanceItems[i].hMenu, (cfg::dat.dwFlags & hAppearanceItems[i].mask) != 0);
+ for (auto &it : hAppearanceItems)
+ Menu_SetChecked(it.hMenu, (cfg::dat.dwFlags & it.mask) != 0);
return 0;
}
@@ -136,12 +136,12 @@ void InitGroupMenus(void)
mi.hIcolibItem = nullptr;
mi.pszService = "CLISTMENUSGroup/CommandHelper";
CreateServiceFunction(mi.pszService, CommandHelper);
- for (int i = 0; i < _countof(hAppearanceItems); i++) {
+ for (auto &it : hAppearanceItems) {
GroupMenuParam gmp;
- gmp.wParam = hAppearanceItems[i].command;
- mi.name.a = hAppearanceItems[i].name;
- mi.position = hAppearanceItems[i].position;
- hAppearanceItems[i].hMenu = Menu_AddGroupMenuItem(&mi, &gmp);
+ gmp.wParam = it.command;
+ mi.name.a = it.name;
+ mi.position = it.position;
+ it.hMenu = Menu_AddGroupMenuItem(&mi, &gmp);
}
SET_UID(mi, 0xc2895531, 0x98e9, 0x40bc, 0x9b, 0x8e, 0xfb, 0x33, 0xe8, 0xab, 0xcc, 0xef);
diff --git a/plugins/Clist_nicer/src/rowheight_funcs.cpp b/plugins/Clist_nicer/src/rowheight_funcs.cpp
index d50412ee60..625bf12d34 100644
--- a/plugins/Clist_nicer/src/rowheight_funcs.cpp
+++ b/plugins/Clist_nicer/src/rowheight_funcs.cpp
@@ -88,32 +88,31 @@ BOOL RowHeight::Alloc(ClcData *dat, int size)
// Calc and store max row height
int RowHeight::getMaxRowHeight(ClcData *dat, const HWND hwnd)
{
- int max_height = 0, i;
+ int max_height = 0;
DWORD style = GetWindowLongPtr(hwnd, GWL_STYLE);
int contact_fonts[] = { FONTID_CONTACTS, FONTID_INVIS, FONTID_OFFLINE, FONTID_NOTONLIST, FONTID_OFFINVIS };
int other_fonts[] = { FONTID_GROUPS, FONTID_GROUPCOUNTS, FONTID_DIVIDERS };
// Get contact font size
- for (i = 0; i < _countof(contact_fonts); i++)
- if (max_height < dat->fontInfo[contact_fonts[i]].fontHeight)
- max_height = dat->fontInfo[contact_fonts[i]].fontHeight;
+ for (auto &it : contact_fonts)
+ if (max_height < dat->fontInfo[it].fontHeight)
+ max_height = dat->fontInfo[it].fontHeight;
if (cfg::dat.dualRowMode == 1 && !dat->bisEmbedded)
max_height += ROW_SPACE_BEETWEEN_LINES + dat->fontInfo[FONTID_STATUS].fontHeight;
// Get other font sizes
- for (i = 0; i < _countof(other_fonts); i++) {
- if (max_height < dat->fontInfo[other_fonts[i]].fontHeight)
- max_height = dat->fontInfo[other_fonts[i]].fontHeight;
- }
+ for (auto &it : other_fonts)
+ if (max_height < dat->fontInfo[it].fontHeight)
+ max_height = dat->fontInfo[it].fontHeight;
// Avatar size
if (cfg::dat.dwFlags & CLUI_FRAME_AVATARS && !dat->bisEmbedded)
max_height = max(max_height, cfg::dat.avatarSize + cfg::dat.avatarPadding);
// Checkbox size
- if (style&CLS_CHECKBOXES || style&CLS_GROUPCHECKBOXES)
+ if (style & CLS_CHECKBOXES || style & CLS_GROUPCHECKBOXES)
max_height = max(max_height, dat->checkboxSize);
//max_height += 2 * dat->row_border;
diff --git a/plugins/Clist_nicer/src/viewmodes.cpp b/plugins/Clist_nicer/src/viewmodes.cpp
index 42c73abd72..eb38ffa2d8 100644
--- a/plugins/Clist_nicer/src/viewmodes.cpp
+++ b/plugins/Clist_nicer/src/viewmodes.cpp
@@ -869,9 +869,9 @@ LRESULT CALLBACK ViewModeFrameWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case WM_USER + 100:
{
bool bSkinned = db_get_b(NULL, "CLCExt", "bskinned", 0) != 0;
- for (int i = 0; i < _countof(_buttons); i++) {
- HWND hwndButton = GetDlgItem(hwnd, _buttons[i].btn_id);
- SendMessage(hwndButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(_buttons[i].icon));
+ for (auto &it : _buttons) {
+ HWND hwndButton = GetDlgItem(hwnd, it.btn_id);
+ SendMessage(hwndButton, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIcon(it.icon));
CustomizeButton(hwndButton, bSkinned, !bSkinned, bSkinned);
}
}
diff --git a/plugins/CloudFile/src/icons.cpp b/plugins/CloudFile/src/icons.cpp
index ae89626884..72d7c22314 100644
--- a/plugins/CloudFile/src/icons.cpp
+++ b/plugins/CloudFile/src/icons.cpp
@@ -16,27 +16,27 @@ void InitializeIcons()
HANDLE GetIconHandle(int iconId)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
}
HANDLE GetIconHandle(const char *name)
{
- for (size_t i = 0; i < _countof(iconList); i++)
- if (mir_strcmpi(iconList[i].szName, name) == 0)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (mir_strcmpi(it.szName, name) == 0)
+ return it.hIcolib;
return nullptr;
}
HICON LoadIconEx(int iconId, bool big)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return IcoLib_GetIconByHandle(iconList[i].hIcolib, big);
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return IcoLib_GetIconByHandle(it.hIcolib, big);
return nullptr;
} \ No newline at end of file
diff --git a/plugins/DbEditorPP/src/icons.cpp b/plugins/DbEditorPP/src/icons.cpp
index 683b90fbe7..6a98c9a86d 100644
--- a/plugins/DbEditorPP/src/icons.cpp
+++ b/plugins/DbEditorPP/src/icons.cpp
@@ -42,9 +42,9 @@ IconItem iconList[] = {
HANDLE GetIcoLibHandle(int icon)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == icon)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (it.defIconID == icon)
+ return it.hIcolib;
return INVALID_HANDLE_VALUE;
}
@@ -55,9 +55,9 @@ void IcoLibRegister(void)
HICON LoadSkinnedDBEIcon(int icon)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == icon)
- return IcoLib_GetIconByHandle(iconList[i].hIcolib);
+ for (auto &it : iconList)
+ if (it.defIconID == icon)
+ return IcoLib_GetIconByHandle(it.hIcolib);
return LoadIcon(hInst, MAKEINTRESOURCE(icon));
}
@@ -69,8 +69,8 @@ HIMAGELIST LoadIcons()
if (!hil)
return nullptr;
- for(int i = 0; i < _countof(dbeIcons); i++)
- ImageList_AddIcon(hil, LoadSkinnedDBEIcon(dbeIcons[i]));
+ for (auto &it : dbeIcons)
+ ImageList_AddIcon(hil, LoadSkinnedDBEIcon(it));
int protoCount = 0;
PROTOACCOUNT **protocols = nullptr;
diff --git a/plugins/FingerprintNG/src/options.cpp b/plugins/FingerprintNG/src/options.cpp
index 9e8af894f4..a18db89934 100644
--- a/plugins/FingerprintNG/src/options.cpp
+++ b/plugins/FingerprintNG/src/options.cpp
@@ -76,19 +76,17 @@ static void StoreDBCheckState(HWND hwndDlg, int idCtrl, LPCSTR szSetting)
static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- int i;
-
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
- for (i = 0; i < _countof(settings); i++)
- LoadDBCheckState(hwndDlg, settings[i].idCtrl, settings[i].szSetName, settings[i].defValue);
+ for (auto &it : settings)
+ LoadDBCheckState(hwndDlg, it.idCtrl, it.szSetName, it.defValue);
break;
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED)
- for (i = 0; i < _countof(settings); i++)
- if (settings[i].idCtrl == LOWORD(wParam)) {
+ for (auto &it : settings)
+ if (it.idCtrl == LOWORD(wParam)) {
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
@@ -97,8 +95,8 @@ static INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case WM_NOTIFY:
NMHDR *hdr = (NMHDR *)lParam;
if (hdr && hdr->code == PSN_APPLY) {
- for (i = 0; i < _countof(settings); i++)
- StoreDBCheckState(hwndDlg, settings[i].idCtrl, settings[i].szSetName);
+ for (auto &it : settings)
+ StoreDBCheckState(hwndDlg, it.idCtrl, it.szSetName);
ClearFI();
RegisterIcons();
diff --git a/plugins/HistorySweeperLight/src/options.cpp b/plugins/HistorySweeperLight/src/options.cpp
index b503a09580..7d8071eb63 100644
--- a/plugins/HistorySweeperLight/src/options.cpp
+++ b/plugins/HistorySweeperLight/src/options.cpp
@@ -68,9 +68,9 @@ HICON LoadIconEx(const char* name)
HANDLE GetIconHandle(const char* name)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (mir_strcmp(iconList[i].szName, name) == 0)
- return hIconLibItem[i];
+ for (auto &it : iconList)
+ if (mir_strcmp(it.szName, name) == 0)
+ return &it;
return nullptr;
}
@@ -100,7 +100,6 @@ static void ShowAllContactIcons(HWND hwndList)
void LoadSettings(HWND hwndDlg)
{
- int i;
HWND hwndList = GetDlgItem(hwndDlg, IDC_LIST);
CLCINFOITEM cii = { 0 };
@@ -118,13 +117,13 @@ void LoadSettings(HWND hwndDlg)
SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_RESETCONTENT, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_RESETCONTENT, 0, 0);
- for (i = 0; i < _countof(time_stamp_strings); i++) {
- ptrW ptszTimeStr(Langpack_PcharToTchar(time_stamp_strings[i]));
+ for (auto &it : time_stamp_strings) {
+ ptrW ptszTimeStr(Langpack_PcharToTchar(it));
SendDlgItemMessage(hwndDlg, IDC_SSOLDER, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr);
}
- for (i = 0; i < _countof(keep_strings); i++) {
- ptrW ptszTimeStr(Langpack_PcharToTchar(keep_strings[i]));
+ for (auto &it : keep_strings) {
+ ptrW ptszTimeStr(Langpack_PcharToTchar(it));
SendDlgItemMessage(hwndDlg, IDC_SSKEEP, CB_ADDSTRING, 0, (LPARAM)ptszTimeStr);
}
@@ -134,8 +133,7 @@ void LoadSettings(HWND hwndDlg)
CheckDlgButton(hwndDlg, IDC_UNSAFEMODE, db_get_b(NULL, ModuleName, "UnsafeMode", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SWEEPONCLOSE, db_get_b(NULL, ModuleName, "SweepOnClose", 0) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_HISTMW, db_get_b(NULL, ModuleName, "ChangeInMW", 0) ? BST_CHECKED : BST_UNCHECKED);
-}//LoadSettings
-
+}
void SaveSettings(HWND hwndDlg)
{
diff --git a/plugins/IEView/src/Options.cpp b/plugins/IEView/src/Options.cpp
index bad5e10bba..5ca9fa0496 100644
--- a/plugins/IEView/src/Options.cpp
+++ b/plugins/IEView/src/Options.cpp
@@ -510,8 +510,8 @@ static INT_PTR CALLBACK IEViewGeneralOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w
EnableWindow(GetDlgItem(hwndDlg, IDC_EMBED_SIZE), IsDlgButtonChecked(hwndDlg, IDC_ENABLE_EMBED));
{
wchar_t* size[] = { L"320 x 205", L"480 x 385", L"560 x 349", L"640 x 390" };
- for (int i = 0; i < _countof(size); ++i) {
- int item = SendDlgItemMessage(hwndDlg, IDC_EMBED_SIZE, CB_ADDSTRING, 0, (LPARAM)TranslateW(size[i]));
+ for (auto &it : size) {
+ int item = SendDlgItemMessage(hwndDlg, IDC_EMBED_SIZE, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
SendDlgItemMessage(hwndDlg, IDC_EMBED_SIZE, CB_SETITEMDATA, item, 0);
}
SendDlgItemMessage(hwndDlg, IDC_EMBED_SIZE, CB_SETCURSEL, Options::getEmbedsize(), 0);
diff --git a/plugins/IEView/src/Template.cpp b/plugins/IEView/src/Template.cpp
index 708abda305..c171a141c1 100644
--- a/plugins/IEView/src/Template.cpp
+++ b/plugins/IEView/src/Template.cpp
@@ -338,12 +338,12 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename,
if (sscanf(store, "%s", tmp2) == EOF) continue;
//template start
bool bFound = false;
- for (unsigned i = 0; i < _countof(templateNames); i++) {
- if (!strncmp(store, templateNames[i].tokenString, templateNames[i].tokenLen)) {
+ for (auto &it : templateNames)
+ if (!strncmp(store, it.tokenString, it.tokenLen)) {
bFound = true;
break;
}
- }
+
if (bFound) {
if (wasTemplate)
tmap->addTemplate(lastTemplate, templateText);
@@ -365,16 +365,16 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename,
"MessageOutGroupStart", "MessageOutGroupInner",
"hMessageOutGroupStart", "hMessageOutGroupInner" };
tmap->m_grouping = true;
- for (int i = 0; i < _countof(groupTemplates); i++) {
- if (tmap->getTemplate(groupTemplates[i]) == nullptr) {
+ for (auto &it : groupTemplates) {
+ if (tmap->getTemplate(it) == nullptr) {
tmap->m_grouping = false;
break;
}
}
static const char *rtlTemplates[] = { "MessageInRTL", "MessageOutRTL" }; //"HTMLStartRTL",
tmap->m_rtl = true;
- for (int i = 0; i < _countof(rtlTemplates); i++) {
- if (tmap->getTemplate(rtlTemplates[i]) == nullptr) {
+ for (auto &it : rtlTemplates) {
+ if (tmap->getTemplate(it) == nullptr) {
tmap->m_rtl = false;
break;
}
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index 2d4e756943..249c998afe 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -77,7 +77,7 @@ void AddMessage(const wchar_t* fmt, ...)
va_list args;
wchar_t msgBuf[4096];
va_start(args, fmt);
- mir_vsnwprintf(msgBuf, _countof(msgBuf), TranslateW(fmt), args);
+ mir_vsnwprintf(msgBuf, TranslateW(fmt), args);
SendMessage(hdlgProgress, PROGM_ADDMESSAGE, 0, (LPARAM)msgBuf);
}
diff --git a/plugins/Import/src/miranda.cpp b/plugins/Import/src/miranda.cpp
index 1fa7471f63..d2fef1228c 100644
--- a/plugins/Import/src/miranda.cpp
+++ b/plugins/Import/src/miranda.cpp
@@ -303,16 +303,16 @@ INT_PTR CALLBACK MirandaAdvOptionsPageProc(HWND hwndDlg, UINT message, WPARAM wP
case IDC_INCOMING:
case IDC_OUTGOING:
if (LOWORD(wParam) == IDC_ALL)
- for (int i = 0; i < _countof(SysControls); i++)
- CheckDlgButton(hwndDlg, SysControls[i], IsDlgButtonChecked(hwndDlg, SysControls[i]) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : SysControls)
+ CheckDlgButton(hwndDlg, it, IsDlgButtonChecked(hwndDlg, it) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
if (LOWORD(wParam) != IDC_OUTGOING)
- for (int i = 0; i < _countof(InControls); i++)
- CheckDlgButton(hwndDlg, InControls[i], IsDlgButtonChecked(hwndDlg, InControls[i]) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : InControls)
+ CheckDlgButton(hwndDlg, it, IsDlgButtonChecked(hwndDlg, it) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
if (LOWORD(wParam) != IDC_INCOMING)
- for (int i = 0; i < _countof(OutControls); i++)
- CheckDlgButton(hwndDlg, OutControls[i], IsDlgButtonChecked(hwndDlg, OutControls[i]) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : OutControls)
+ CheckDlgButton(hwndDlg, it, IsDlgButtonChecked(hwndDlg, it) == BST_UNCHECKED ? BST_CHECKED : BST_UNCHECKED);
break;
case IDC_MSG:
diff --git a/plugins/Import/src/utils.cpp b/plugins/Import/src/utils.cpp
index 77e60895cd..8f83ed3f8b 100644
--- a/plugins/Import/src/utils.cpp
+++ b/plugins/Import/src/utils.cpp
@@ -197,18 +197,18 @@ static IconItem iconList[] =
HICON GetIcon(int iIconId, bool size)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iIconId)
- return IcoLib_GetIconByHandle(iconList[i].hIcolib, size);
+ for (auto &it : iconList)
+ if (it.defIconID == iIconId)
+ return IcoLib_GetIconByHandle(it.hIcolib, size);
return nullptr;
}
HANDLE GetIconHandle(int iIconId)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iIconId)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (it.defIconID == iIconId)
+ return it.hIcolib;
return nullptr;
}
diff --git a/plugins/MenuItemEx/src/main.cpp b/plugins/MenuItemEx/src/main.cpp
index e77177358f..f6238d5cfb 100644
--- a/plugins/MenuItemEx/src/main.cpp
+++ b/plugins/MenuItemEx/src/main.cpp
@@ -289,16 +289,16 @@ int StatusMsgExists(MCONTACT hContact)
LPSTR module = GetContactProto(hContact);
if (!module) return 0;
- for (int i = 0; i < _countof(statusMsg); i++) {
- if (statusMsg[i].flag & 8)
- mir_snprintf(par, "%s/%s", module, statusMsg[i].name);
+ for (auto &it : statusMsg) {
+ if (it.flag & 8)
+ mir_snprintf(par, "%s/%s", module, it.name);
else
- strncpy(par, statusMsg[i].name, _countof(par)-1);
+ strncpy(par, it.name, _countof(par)-1);
- LPSTR msg = db_get_sa(hContact, (statusMsg[i].module) ? statusMsg[i].module : module, par);
+ LPSTR msg = db_get_sa(hContact, (it.module) ? it.module : module, par);
if (msg) {
if (mir_strlen(msg))
- ret |= statusMsg[i].flag;
+ ret |= it.flag;
mir_free(msg);
}
}
@@ -609,17 +609,17 @@ static INT_PTR onCopyStatusMsg(WPARAM wparam, LPARAM lparam)
return 0;
buffer[0] = 0;
- for (int i = 0; i < _countof(statusMsg); i++) {
- if (statusMsg[i].flag & 8)
- mir_snprintf(par, "%s/%s", module, statusMsg[i].name);
+ for (auto &it : statusMsg) {
+ if (it.flag & 8)
+ mir_snprintf(par, "%s/%s", module, it.name);
else
- strncpy(par, statusMsg[i].name, _countof(par) - 1);
+ strncpy(par, it.name, _countof(par) - 1);
- LPTSTR msg = db_get_wsa(hContact, (statusMsg[i].module) ? statusMsg[i].module : module, par);
+ LPTSTR msg = db_get_wsa(hContact, (it.module) ? it.module : module, par);
if (msg) {
if (wcslen(msg)) {
if (flags & VF_SMNAME) {
- mir_wstrncat(buffer, TranslateW(statusMsg[i].fullName), (_countof(buffer) - wcslen(buffer) - 1));
+ mir_wstrncat(buffer, TranslateW(it.fullName), (_countof(buffer) - wcslen(buffer) - 1));
mir_wstrncat(buffer, L": ", (_countof(buffer) - wcslen(buffer) - 1));
}
mir_wstrncat(buffer, msg, (_countof(buffer) - wcslen(buffer) - 1));
diff --git a/plugins/MenuItemEx/src/options.cpp b/plugins/MenuItemEx/src/options.cpp
index 997bc2d417..853fdb40d8 100644
--- a/plugins/MenuItemEx/src/options.cpp
+++ b/plugins/MenuItemEx/src/options.cpp
@@ -35,25 +35,19 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
switch (msg) {
case WM_INITDIALOG:
-
TranslateDialogDefault(hdlg);
- for (i = 0; i < _countof(checkboxes); i++)
- {
- CheckDlgButton(hdlg, checkboxes[i].idc, (flags & checkboxes[i].flag) ? BST_CHECKED : BST_UNCHECKED);
- }
+ for (auto &it : checkboxes)
+ CheckDlgButton(hdlg, it.idc, (flags & it.flag) ? BST_CHECKED : BST_UNCHECKED);
- if (bPopupService)
- {
- for (i = 0; i < 4; i++)
- {
+ if (bPopupService) {
+ for (i = 0; i < 4; i++) {
GetDlgItemText(hdlg, checkboxes[i].idc, buffer, (_countof(buffer) - 3));
mir_wstrcat(buffer, L" *");
SetDlgItemText(hdlg, checkboxes[i].idc, buffer);
}
}
- else
- ShowWindow(GetDlgItem(hdlg, IDC_HINT1), SW_HIDE);
+ else ShowWindow(GetDlgItem(hdlg, IDC_HINT1), SW_HIDE);
SendMessage(hdlg, WM_USER + 50, 0, 0);
return 0;
@@ -72,8 +66,8 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg, UINT msg, WPARAM wparam, LPARAM lparam)
case PSN_APPLY:
DWORD mod_flags = 0;
- for (i = 0; i < _countof(checkboxes); i++)
- mod_flags |= IsDlgButtonChecked(hdlg, checkboxes[i].idc) ? checkboxes[i].flag : 0;
+ for (auto &it : checkboxes)
+ mod_flags |= IsDlgButtonChecked(hdlg, it.idc) ? it.flag : 0;
db_set_dw(NULL, MODULENAME, "flags", mod_flags);
return 1;
diff --git a/plugins/MirLua/src/mlua_icons.cpp b/plugins/MirLua/src/mlua_icons.cpp
index 4b13f8c52e..64648484ed 100644
--- a/plugins/MirLua/src/mlua_icons.cpp
+++ b/plugins/MirLua/src/mlua_icons.cpp
@@ -16,18 +16,18 @@ void InitIcons()
HICON GetIcon(int iconId)
{
- for (size_t i = 0; i < _countof(Icons); i++)
- if (Icons[i].defIconID == iconId)
- return IcoLib_GetIconByHandle(Icons[i].hIcolib);
+ for (auto &it : Icons)
+ if (it.defIconID == iconId)
+ return IcoLib_GetIconByHandle(it.hIcolib);
return nullptr;
}
HANDLE GetIconHandle(int iconId)
{
- for (size_t i = 0; i < _countof(Icons); i++)
- if (Icons[i].defIconID == iconId)
- return Icons[i].hIcolib;
+ for (auto &it : Icons)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
} \ No newline at end of file
diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp
index 7062447709..7024e28f42 100755
--- a/plugins/Msg_Export/src/utils.cpp
+++ b/plugins/Msg_Export/src/utils.cpp
@@ -1318,9 +1318,9 @@ bool bWriteIndentedToFile(HANDLE hFile, int nIndent, const wchar_t *pszSrc, bool
// then we will look for a ? and so on.
const wchar_t ac[] = { ' ', '?', '-', '.', ',' };
- for (int y = 0; y < _countof(ac); y++) {
+ for (auto &it : ac) {
for (int n = nLineLen; n > 0; n--) {
- if (pszSrc[n] == ac[y]) {
+ if (pszSrc[n] == it) {
nLineLen = n;
goto SuperBreak;
}
diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index 42de3b5625..1c32790add 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -609,9 +609,9 @@ static renameTable[] =
// Returns true if smth. was copied
static bool CheckFileRename(const wchar_t *ptszOldName, wchar_t *pNewName)
{
- for (int i = 0; i < _countof(renameTable); i++) {
- if (wildcmpiw(ptszOldName, renameTable[i].oldName)) {
- wchar_t *ptszDest = renameTable[i].newName;
+ for (auto &it : renameTable) {
+ if (wildcmpiw(ptszOldName, it.oldName)) {
+ wchar_t *ptszDest = it.newName;
if (ptszDest == nullptr)
*pNewName = 0;
else {
diff --git a/plugins/PluginUpdater/src/Options.cpp b/plugins/PluginUpdater/src/Options.cpp
index 8d5d4d2830..660b676d07 100644
--- a/plugins/PluginUpdater/src/Options.cpp
+++ b/plugins/PluginUpdater/src/Options.cpp
@@ -328,14 +328,15 @@ static INT_PTR CALLBACK DlgPopupOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM
EnableWindow(GetDlgItem(hdlg, (i+42071)), (PopupOptions.DefColors == byCOLOR_OWN));
EnableWindow(GetDlgItem(hdlg, (i+41071)), (PopupOptions.DefColors == byCOLOR_OWN));
}
- //Timeout
+ // Timeout
SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE, EM_LIMITTEXT, 4, 0);
SendDlgItemMessage(hdlg, IDC_TIMEOUT_VALUE_SPIN, UDM_SETRANGE32, -1, 9999);
SetDlgItemInt(hdlg, IDC_TIMEOUT_VALUE, PopupOptions.Timeout, TRUE);
- //Mouse actions
- for (int i = 0; i < _countof(PopupActions); i++) {
- SendDlgItemMessage(hdlg, IDC_LC, CB_SETITEMDATA, SendDlgItemMessage(hdlg, IDC_LC, CB_ADDSTRING, 0, (LPARAM)TranslateW(PopupActions[i].Text)), PopupActions[i].Action);
- SendDlgItemMessage(hdlg, IDC_RC, CB_SETITEMDATA, SendDlgItemMessage(hdlg, IDC_RC, CB_ADDSTRING, 0, (LPARAM)TranslateW(PopupActions[i].Text)), PopupActions[i].Action);
+
+ // Mouse actions
+ for (auto &it : PopupActions) {
+ SendDlgItemMessage(hdlg, IDC_LC, CB_SETITEMDATA, SendDlgItemMessage(hdlg, IDC_LC, CB_ADDSTRING, 0, (LPARAM)TranslateW(it.Text)), it.Action);
+ SendDlgItemMessage(hdlg, IDC_RC, CB_SETITEMDATA, SendDlgItemMessage(hdlg, IDC_RC, CB_ADDSTRING, 0, (LPARAM)TranslateW(it.Text)), it.Action);
}
SendDlgItemMessage(hdlg, IDC_LC, CB_SETCURSEL, PopupOptions.LeftClickAction, 0);
SendDlgItemMessage(hdlg, IDC_RC, CB_SETCURSEL, PopupOptions.RightClickAction, 0);
diff --git a/plugins/Popup/src/actions.cpp b/plugins/Popup/src/actions.cpp
index 9235521bec..181297e265 100644
--- a/plugins/Popup/src/actions.cpp
+++ b/plugins/Popup/src/actions.cpp
@@ -45,8 +45,8 @@ void LoadActions()
{ sizeof(POPUPACTION), LoadIconEx(IDI_ACT_COPY), LPGEN("General") "/" LPGEN("Copy to clipboard"), 0 },
};
- for (int i = 0; i < _countof(actions); ++i)
- RegisterAction(&actions[i]);
+ for (auto &it : actions)
+ RegisterAction(&it);
}
void UnloadActions()
@@ -174,7 +174,6 @@ static UINT controls[] =
INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static bool windowInitialized = false;
- int i;
switch (msg) {
case WM_INITDIALOG:
@@ -224,7 +223,7 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
LIST<char> groups(1, strcmp);
- for (i = 0; i < gActions.getCount(); ++i) {
+ for (int i = 0; i < gActions.getCount(); ++i) {
char szGroup[64];
char *szName = strchr(gActions[i]->lpzTitle, '/');
if (!szName) szName = gActions[i]->lpzTitle;
@@ -261,8 +260,8 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
}
BOOL enabled = (PopupOptions.actions & ACT_ENABLE) ? TRUE : FALSE;
- for (i = 0; i < _countof(controls); ++i)
- EnableWindow(GetDlgItem(hwnd, controls[i]), enabled);
+ for (auto &it : controls)
+ EnableWindow(GetDlgItem(hwnd, it), enabled);
}
windowInitialized = true;
break;
@@ -275,8 +274,8 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
{
BOOL enabled = (PopupOptions.actions & ACT_ENABLE) ? TRUE : FALSE;
- for (i = 0; i < _countof(controls); ++i)
- EnableWindow(GetDlgItem(hwnd, controls[i]), enabled);
+ for (auto &it : controls)
+ EnableWindow(GetDlgItem(hwnd, it), enabled);
}
break;
@@ -344,7 +343,7 @@ INT_PTR CALLBACK DlgProcPopupActions(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
db_set_dw(NULL, MODULNAME, "Actions", PopupOptions.actions);
HWND hwndList = GetDlgItem(hwnd, IDC_ACTIONS);
- for (i = 0; i < gActions.getCount(); ++i) {
+ for (int i = 0; i < gActions.getCount(); ++i) {
gActions[i]->flags = (ListView_GetItemState(hwndList, i, LVIS_STATEIMAGEMASK) == 0x2000) ? PAF_ENABLED : 0;
db_set_b(NULL, "PopupActions", gActions[i]->lpzTitle, (gActions[i]->flags & PAF_ENABLED) ? 1 : 0);
}
diff --git a/plugins/Popup/src/icons.cpp b/plugins/Popup/src/icons.cpp
index 297a9d982f..b1b5a985fc 100644
--- a/plugins/Popup/src/icons.cpp
+++ b/plugins/Popup/src/icons.cpp
@@ -69,18 +69,18 @@ void InitIcons()
HICON LoadIconEx(int iconId, bool big)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return IcoLib_GetIconByHandle(iconList[i].hIcolib, big);
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return IcoLib_GetIconByHandle(it.hIcolib, big);
return nullptr;
}
HANDLE GetIconHandle(int iconId)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
}
diff --git a/plugins/Popup/src/opt_class.cpp b/plugins/Popup/src/opt_class.cpp
index 742bc2dbee..1b7cf2b05c 100644
--- a/plugins/Popup/src/opt_class.cpp
+++ b/plugins/Popup/src/opt_class.cpp
@@ -168,8 +168,6 @@ static statusButtons[] = {
INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- int i;
-
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwnd);
@@ -183,7 +181,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
ImageList_ReplaceIcon(hImgLst, -1, LoadIconEx(IDI_OPT_GROUP));
TreeView_SetImageList(hwndTree, hImgLst, TVSIL_NORMAL);
- for (i = 0; i < gTreeData.getCount(); ++i) {
+ for (int i = 0; i < gTreeData.getCount(); ++i) {
POPUPTREEDATA *p = gTreeData[i];
wchar_t itemName[MAXMODULELABELLENGTH];
@@ -202,24 +200,24 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
OptTree_Translate(hwndTree);
// Bold Title
- for (i = 0; i < _countof(titleIds); ++i) {
+ for (auto &it : titleIds) {
LOGFONT lf;
- GetObject((HFONT)SendDlgItemMessage(hwnd, titleIds[i], WM_GETFONT, 0, 0), sizeof(lf), &lf);
+ GetObject((HFONT)SendDlgItemMessage(hwnd, it, WM_GETFONT, 0, 0), sizeof(lf), &lf);
lf.lfWeight = FW_BOLD;
- SendDlgItemMessage(hwnd, titleIds[i], WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
+ SendDlgItemMessage(hwnd, it, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), TRUE);
}
// spindown for Timeout
SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(SETTING_LIFETIME_MAX, SETTING_LIFETIME_INFINITE));
SetDlgItemInt(hwnd, IDC_TIMEOUT, (UINT)0, TRUE);
// status buttons
- for (i = 0; i < _countof(statusButtons); ++i) {
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONSETASPUSHBTN, TRUE, 0);
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BM_SETIMAGE,
- IMAGE_ICON, (LPARAM)Skin_LoadIcon(statusButtons[i].iconId));
- SendDlgItemMessage(hwnd, statusButtons[i].idCtrl, BUTTONADDTOOLTIP,
- (WPARAM)Translate(statusButtons[i].title), 0);
+ for (auto &it : statusButtons) {
+ SendDlgItemMessage(hwnd, it.idCtrl, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwnd, it.idCtrl, BUTTONSETASPUSHBTN, TRUE, 0);
+ SendDlgItemMessage(hwnd, it.idCtrl, BM_SETIMAGE,
+ IMAGE_ICON, (LPARAM)Skin_LoadIcon(it.iconId));
+ SendDlgItemMessage(hwnd, it.idCtrl, BUTTONADDTOOLTIP,
+ (WPARAM)Translate(it.title), 0);
}
// info icon
SendDlgItemMessage(hwnd, IDC_ICO_INFO, STM_SETICON, (WPARAM)LoadIconEx(IDI_MB_INFO), 0);
@@ -265,7 +263,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1));
// combo left action (EXTRA)
hCtrl = GetDlgItem(hwnd, IDC_LACTION);
- for (i = 0; i < ptd->notification.actionCount; ++i) {
+ for (int i = 0; i < ptd->notification.actionCount; ++i) {
psztAction = mir_a2u(ptd->notification.lpActions[i].lpzTitle);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateW(psztAction)), ptd->notification.lpActions[i].lpzTitle);
mir_free(psztAction); psztAction = nullptr;
@@ -273,25 +271,27 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
// combo right action (EXTRA)
hCtrl = GetDlgItem(hwnd, IDC_RACTION);
psztAction = nullptr;
- for (i = 0; i < ptd->notification.actionCount; ++i) {
+ for (int i = 0; i < ptd->notification.actionCount; ++i) {
psztAction = mir_a2u(ptd->notification.lpActions[i].lpzTitle);
ComboBox_SetItemData(hCtrl, ComboBox_AddString(hCtrl, TranslateW(psztAction)), ptd->notification.lpActions[i].lpzTitle);
mir_free(psztAction); psztAction = nullptr;
}
// enable all controls
- for (i = 0; i < _countof(ctrlsAll); ++i){
- ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1 ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp1);
+ for (auto &it : ctrlsAll) {
+ ShowWindow(GetDlgItem(hwnd, it.idCtrl), it.onTyp1 ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(hwnd, it.idCtrl), it.onTyp1);
}
// enable or disable controls ctrlsEnable
- for (i = 0; i < _countof(ctrlsEnable); ++i)
- EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled ? TRUE : FALSE);
+ for (auto &it : ctrlsEnable)
+ EnableWindow(GetDlgItem(hwnd, it), ptd->enabled ? TRUE : FALSE);
+
// show or hide controls ctrlsContact
- for (i = 0; i < _countof(ctrlsContact); ++i)
- ShowWindow(GetDlgItem(hwnd, ctrlsContact[i]), ptd->notification.dwFlags&PNF_CONTACT ? SW_SHOW : SW_HIDE);
+ for (auto &it : ctrlsContact)
+ ShowWindow(GetDlgItem(hwnd, it), ptd->notification.dwFlags&PNF_CONTACT ? SW_SHOW : SW_HIDE);
+
// statusButtons state
- for (i = 0; i < _countof(statusButtons); ++i)
- CheckDlgButton(hwnd, statusButtons[i].idCtrl, ptd->disableWhen & statusButtons[i].disableWhenFlag ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : statusButtons)
+ CheckDlgButton(hwnd, it.idCtrl, ptd->disableWhen & it.disableWhenFlag ? BST_CHECKED : BST_UNCHECKED);
}
// element typ2 (CLASS Plugins)
else if (ptd->typ == 2) {
@@ -299,9 +299,9 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
SetDlgItemInt(hwnd, IDC_TIMEOUT, (UINT)ptd->timeoutValue, TRUE);
SendDlgItemMessage(hwnd, IDC_TIMEOUT_SPIN, UDM_SETRANGE, 0, (LPARAM)MAKELONG(250, -1));
// enable ctrls
- for (i = 0; i < _countof(ctrlsAll); ++i){
- ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2 ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp2);
+ for (auto &it : ctrlsAll) {
+ ShowWindow(GetDlgItem(hwnd, it.idCtrl), it.onTyp2 ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(hwnd, it.idCtrl), it.onTyp2);
}
}
// checkbox enable notify
@@ -315,9 +315,9 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
} // end if (tvi.lParam)
else {
// enable / disable controls
- for (i = 0; i < _countof(ctrlsAll); ++i) {
- ShowWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0 ? SW_SHOW : SW_HIDE);
- EnableWindow(GetDlgItem(hwnd, ctrlsAll[i].idCtrl), ctrlsAll[i].onTyp0);
+ for (auto &it : ctrlsAll) {
+ ShowWindow(GetDlgItem(hwnd, it.idCtrl), it.onTyp0 ? SW_SHOW : SW_HIDE);
+ EnableWindow(GetDlgItem(hwnd, it.idCtrl), it.onTyp0);
}
}
}
@@ -333,8 +333,8 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
switch (idCtrl) {
case IDC_ENABLE:
ptd->enabled = (BYTE)Button_GetCheck((HWND)lParam);
- for (i = 0; i < _countof(ctrlsEnable); ++i)
- EnableWindow(GetDlgItem(hwnd, ctrlsEnable[i]), ptd->enabled);
+ for (auto &it : ctrlsEnable)
+ EnableWindow(GetDlgItem(hwnd, it), ptd->enabled);
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
@@ -378,10 +378,10 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
case IDC_SOFFLINE2: case IDC_SONLINE2: case IDC_SAWAY2: case IDC_SNA2: case IDC_SOCCUPIED2:
case IDC_SDND2: case IDC_SFREE4CHAT2: case IDC_SINVISIBLE2: case IDC_SPHONE2: case IDC_SLUNCH2:
ptd->disableWhen = 0;
- for (i = 0; i < _countof(statusButtons); ++i) {
- if (IsDlgButtonChecked(hwnd, statusButtons[i].idCtrl))
- ptd->disableWhen |= statusButtons[i].disableWhenFlag;
- if (idCtrl == (UINT)statusButtons[i].idCtrl)
+ for (auto &it : statusButtons) {
+ if (IsDlgButtonChecked(hwnd, it.idCtrl))
+ ptd->disableWhen |= it.disableWhenFlag;
+ if (idCtrl == (UINT)it.idCtrl)
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
}
@@ -438,7 +438,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_RESET:
- for (i = 0; i < gTreeData.getCount(); ++i) {
+ for (int i = 0; i < gTreeData.getCount(); ++i) {
POPUPTREEDATA *p = gTreeData[i];
switch (p->typ) {
case 1:
@@ -453,7 +453,7 @@ INT_PTR CALLBACK DlgProcOptsClasses(HWND hwnd, UINT msg, WPARAM wParam, LPARAM l
return TRUE;
case PSN_APPLY:
- for (i = 0; i < gTreeData.getCount(); ++i) {
+ for (int i = 0; i < gTreeData.getCount(); ++i) {
POPUPTREEDATA *p = gTreeData[i];
switch (p->typ) {
case 1:
diff --git a/plugins/SMS/src/SMS_svc.cpp b/plugins/SMS/src/SMS_svc.cpp
index 330c089f08..ee3b8dc53c 100644
--- a/plugins/SMS/src/SMS_svc.cpp
+++ b/plugins/SMS/src/SMS_svc.cpp
@@ -8,9 +8,9 @@ int LoadServices(void)
pszServiceFunctionName = szServiceFunction + PROTOCOL_NAME_LEN;
// Service creation
- for (size_t i = 0; i < _countof(siPluginServices); i++) {
- memcpy(pszServiceFunctionName, siPluginServices[i].lpszName, (mir_strlen(siPluginServices[i].lpszName) + 1));
- CreateServiceFunction(szServiceFunction, (MIRANDASERVICE)siPluginServices[i].lpFunc);
+ for (auto &it : siPluginServices) {
+ memcpy(pszServiceFunctionName, it.lpszName, (mir_strlen(it.lpszName) + 1));
+ CreateServiceFunction(szServiceFunction, (MIRANDASERVICE)it.lpFunc);
}
return 0;
}
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp
index 97ac6a7adf..9d5f880dc3 100644
--- a/plugins/Scriver/src/globals.cpp
+++ b/plugins/Scriver/src/globals.cpp
@@ -209,17 +209,15 @@ void ReleaseIcons()
HICON GetCachedIcon(const char *name)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (!mir_strcmp(iconList[i].szName, name))
- return IcoLib_GetIconByHandle(iconList[i].hIcolib);
+ for (auto &it : iconList)
+ if (!mir_strcmp(it.szName, name))
+ return IcoLib_GetIconByHandle(it.hIcolib);
return nullptr;
}
void LoadGlobalIcons()
{
- int i;
-
g_dat.hMsgIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE);
g_dat.hMsgIconBig = Skin_LoadIcon(SKINICON_EVENT_MESSAGE, true);
g_dat.hIconChatBig = IcoLib_GetIcon("chat_window", true);
@@ -228,19 +226,21 @@ void LoadGlobalIcons()
ImageList_RemoveAll(g_dat.hChatButtonIconList);
ImageList_RemoveAll(g_dat.hHelperIconList);
ImageList_RemoveAll(g_dat.hSearchEngineIconList);
- for (i = 0; i < _countof(buttonIcons); i++) {
- if (buttonIcons[i] == nullptr)
+
+ for (auto &it : buttonIcons) {
+ if (it == nullptr)
ImageList_AddIcon_ProtoEx(g_dat.hButtonIconList, nullptr, ID_STATUS_OFFLINE);
else
- ImageList_AddIcon(g_dat.hButtonIconList, GetCachedIcon(buttonIcons[i]));
+ ImageList_AddIcon(g_dat.hButtonIconList, GetCachedIcon(it));
}
- for (i = 0; i < _countof(chatButtonIcons); i++)
- ImageList_AddIcon(g_dat.hChatButtonIconList, GetCachedIcon(chatButtonIcons[i]));
+
+ for (auto &it : chatButtonIcons)
+ ImageList_AddIcon(g_dat.hChatButtonIconList, GetCachedIcon(it));
ImageList_AddIcon(g_dat.hHelperIconList, GetCachedIcon("scriver_OVERLAY"));
int overlayIcon = ImageList_AddIcon(g_dat.hHelperIconList, GetCachedIcon("scriver_OVERLAY"));
ImageList_SetOverlayImage(g_dat.hHelperIconList, overlayIcon, 1);
- for (i = IDI_GOOGLE; i < IDI_LASTICON; i++) {
+ for (int i = IDI_GOOGLE; i < IDI_LASTICON; i++) {
HICON hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(i), IMAGE_ICON, 0, 0, 0);
ImageList_AddIcon(g_dat.hSearchEngineIconList, hIcon);
DestroyIcon(hIcon);
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp
index f2beec5ee5..912b5a4741 100644
--- a/plugins/Scriver/src/msglog.cpp
+++ b/plugins/Scriver/src/msglog.cpp
@@ -910,8 +910,8 @@ void LoadMsgLogIcons(void)
void FreeMsgLogIcons(void)
{
- for (int i = 0; i < _countof(pLogIconBmpBits); i++)
- mir_free(pLogIconBmpBits[i]);
+ for (auto &it : pLogIconBmpBits)
+ mir_free(it);
ImageList_RemoveAll(g_hImageList);
ImageList_Destroy(g_hImageList);
diff --git a/plugins/SpellChecker/src/dictionary.cpp b/plugins/SpellChecker/src/dictionary.cpp
index 4fd5123aa5..03fa58e5fb 100644
--- a/plugins/SpellChecker/src/dictionary.cpp
+++ b/plugins/SpellChecker/src/dictionary.cpp
@@ -537,10 +537,10 @@ public:
}
else {
- for (int i = 0; i < _countof(codepages); i++) {
- if (_strcmpi(codepages[i].name, dic_enc) == 0) {
- if (IsValidCodePage(codepages[i].codepage))
- codePage = codepages[i].codepage;
+ for (auto &it : codepages) {
+ if (_strcmpi(it.name, dic_enc) == 0) {
+ if (IsValidCodePage(it.codepage))
+ codePage = it.codepage;
break;
}
}
@@ -786,20 +786,18 @@ void GetDictsInfo(LIST<Dictionary> &dicts)
}
if (dict->localized_name[0] == '\0') {
- for (size_t j = 0; j < _countof(aditionalLanguages); j++) {
- if (!mir_wstrcmp(aditionalLanguages[j].language, dict->language)) {
- mir_wstrncpy(dict->localized_name, TranslateW(aditionalLanguages[j].localized_name), _countof(dict->localized_name));
+ for (auto &it : aditionalLanguages) {
+ if (!mir_wstrcmp(it.language, dict->language)) {
+ mir_wstrncpy(dict->localized_name, TranslateW(it.localized_name), _countof(dict->localized_name));
break;
}
}
}
- if (dict->localized_name[0] != '\0') {
+ if (dict->localized_name[0] != '\0')
mir_snwprintf(dict->full_name, L"%s [%s]", dict->localized_name, dict->language);
- }
- else {
+ else
mir_wstrncpy(dict->full_name, dict->language, _countof(dict->full_name));
- }
}
}
}
@@ -865,9 +863,9 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use
if (opts.use_other_apps_dicts) {
// Get other apps dicts
- for (int i = 0; i < _countof(otherHunspellApps); i++) {
+ for (auto &it : otherHunspellApps) {
wchar_t key[1024];
- mir_snwprintf(key, APPPATH, otherHunspellApps[i].key);
+ mir_snwprintf(key, APPPATH, it.key);
HKEY hKey = nullptr;
LONG lResult = 0;
@@ -892,7 +890,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use
key[cchValue] = 0;
wchar_t *pos;
if (pos = wcsrchr(key, '\\')) {
- if (!mir_wstrcmpi(&pos[1], otherHunspellApps[i].key)) {
+ if (!mir_wstrcmpi(&pos[1], it.key)) {
pos[0] = 0;
lResult = ERROR_SUCCESS;
break;
@@ -907,7 +905,7 @@ void GetAvaibleDictionaries(LIST<Dictionary> &dicts, wchar_t *path, wchar_t *use
wchar_t folder[1024];
mir_snwprintf(folder, L"%s\\Dictionaries", key);
- GetHunspellDictionariesFromFolder(languages, folder, user_path, otherHunspellApps[i].name);
+ GetHunspellDictionariesFromFolder(languages, folder, user_path, it.name);
}
}
}
diff --git a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
index 41e09bc0bf..50cf03813d 100644
--- a/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
+++ b/plugins/StatusManager/src/AdvancedAutoAway/advancedautoaway.cpp
@@ -599,9 +599,9 @@ void AdvancedAutoAwayUnload()
KillModuleOptions(AAALangPack);
- for (int i = 0; i < _countof(hEvents); i++) {
- UnhookEvent(hEvents[i]);
- hEvents[i] = nullptr;
+ for (auto &it : hEvents) {
+ UnhookEvent(it);
+ it = nullptr;
}
DestroyHookableEvent(hStateChangedEvent); hStateChangedEvent = nullptr;
diff --git a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
index 7ac0eb0dd2..5c925893f9 100644
--- a/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
+++ b/plugins/StatusManager/src/KeepStatus/keepstatus.cpp
@@ -1205,14 +1205,14 @@ void KeepStatusUnload()
KillModuleOptions(KSLangPack);
- for (int i = 0; i < _countof(hServices); i++) {
- DestroyServiceFunction(hServices[i]);
- hServices[i] = nullptr;
+ for (auto &it : hServices) {
+ DestroyServiceFunction(it);
+ it = nullptr;
}
- for (int i = 0; i < _countof(hEvents); i++) {
- UnhookEvent(hEvents[i]);
- hEvents[i] = nullptr;
+ for (auto &it : hEvents) {
+ UnhookEvent(it);
+ it = nullptr;
}
DestroyHookableEvent(hConnectionEvent); hConnectionEvent = nullptr;
diff --git a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
index 1f051800e6..6559fa6811 100644
--- a/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
+++ b/plugins/StatusManager/src/StartupStatus/startupstatus.cpp
@@ -519,14 +519,14 @@ void StartupStatusUnload()
KillModuleOptions(SSLangPack);
- for (int i = 0; i < _countof(hServices); i++) {
- DestroyServiceFunction(hServices[i]);
- hServices[i] = nullptr;
+ for (auto &it : hServices) {
+ DestroyServiceFunction(it);
+ it = nullptr;
}
- for (int i = 0; i < _countof(hEvents); i++) {
- UnhookEvent(hEvents[i]);
- hEvents[i] = nullptr;
+ for (auto &it : hEvents) {
+ UnhookEvent(it);
+ it = nullptr;
}
DeinitProfilesModule();
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp
index 532984439f..c3fe689df4 100644
--- a/plugins/TabSRMM/src/chat_main.cpp
+++ b/plugins/TabSRMM/src/chat_main.cpp
@@ -253,9 +253,9 @@ int Chat_Unload(void)
if (g_Settings.SelectionBGBrush)
DeleteObject(g_Settings.SelectionBGBrush);
- for (int i = 0; i < _countof(g_Settings.UserListFonts); i++)
- if (g_Settings.UserListFonts[i])
- DeleteObject(g_Settings.UserListFonts[i]);
+ for (auto &it : g_Settings.UserListFonts)
+ if (it)
+ DeleteObject(it);
delete g_Settings.Highlight;
return 0;
diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp
index 9d522e9382..ad7c49b08a 100644
--- a/plugins/TabSRMM/src/chat_options.cpp
+++ b/plugins/TabSRMM/src/chat_options.cpp
@@ -601,30 +601,30 @@ void RegisterFontServiceFonts()
strncpy(fid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup));
strncpy(cid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup));
- for (int i = 0; i < _countof(_clrs); i++) {
- cid.order = _clrs[i].order;
- wcsncpy(cid.group, _clrs[i].tszGroup, _countof(fid.group));
- wcsncpy(cid.name, _clrs[i].tszName, _countof(cid.name));
- strncpy(cid.setting, _clrs[i].szSetting, _countof(cid.setting));
- if (_clrs[i].def & 0xff000000)
- cid.defcolour = GetSysColor(_clrs[i].def & 0x000000ff);
+ for (auto &it : _clrs) {
+ cid.order = it.order;
+ wcsncpy(cid.group, it.tszGroup, _countof(fid.group));
+ wcsncpy(cid.name, it.tszName, _countof(cid.name));
+ strncpy(cid.setting, it.szSetting, _countof(cid.setting));
+ if (it.def & 0xff000000)
+ cid.defcolour = GetSysColor(it.def & 0x000000ff);
else
- cid.defcolour = _clrs[i].def;
+ cid.defcolour = it.def;
Colour_RegisterW(&cid);
}
strncpy(cid.dbSettingsGroup, SRMSGMOD_T, _countof(fid.dbSettingsGroup));
// text and background colors for tabs
- for (int i = 0; i < _countof(_tabclrs); i++) {
- cid.order = _tabclrs[i].order;
- wcsncpy(cid.group, _tabclrs[i].tszGroup, _countof(fid.group));
- wcsncpy(cid.name, _tabclrs[i].tszName, _countof(cid.name));
- strncpy(cid.setting, _tabclrs[i].szSetting, _countof(cid.setting));
- if (_tabclrs[i].def & 0xff000000)
- cid.defcolour = GetSysColor(_tabclrs[i].def & 0x000000ff);
+ for (auto &it : _tabclrs) {
+ cid.order = it.order;
+ wcsncpy(cid.group, it.tszGroup, _countof(fid.group));
+ wcsncpy(cid.name, it.tszName, _countof(cid.name));
+ strncpy(cid.setting, it.szSetting, _countof(cid.setting));
+ if (it.def & 0xff000000)
+ cid.defcolour = GetSysColor(it.def & 0x000000ff);
else
- cid.defcolour = _tabclrs[i].def;
+ cid.defcolour = it.def;
Colour_RegisterW(&cid);
}
diff --git a/plugins/TabSRMM/src/chat_window.cpp b/plugins/TabSRMM/src/chat_window.cpp
index 89fcf34b19..d7a9cb4cf2 100644
--- a/plugins/TabSRMM/src/chat_window.cpp
+++ b/plugins/TabSRMM/src/chat_window.cpp
@@ -1595,10 +1595,10 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
int iFlags = 0, i;
DWORD dwMask = 0;
- for (i = 0; i < _countof(_eventorder); i++) {
+ for (auto &it : _eventorder) {
int result = IsDlgButtonChecked(hwndDlg, IDC_1 + i);
- dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0);
- iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0);
+ dwMask |= (result != BST_INDETERMINATE ? it : 0);
+ iFlags |= (result == BST_CHECKED ? it : 0);
}
if (iFlags & GC_EVENT_ADDSTATUS)
@@ -1617,10 +1617,10 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
dwMask = iFlags = 0;
- for (i = 0; i < _countof(_eventorder); i++) {
+ for (auto &it : _eventorder) {
int result = IsDlgButtonChecked(hwndDlg, IDC_P1 + i);
- dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0);
- iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0);
+ dwMask |= (result != BST_INDETERMINATE ? it : 0);
+ iFlags |= (result == BST_CHECKED ? it : 0);
}
if (iFlags & GC_EVENT_ADDSTATUS)
@@ -1639,10 +1639,10 @@ INT_PTR CALLBACK CChatRoomDlg::FilterWndProc(HWND hwndDlg, UINT uMsg, WPARAM wPa
dwMask = iFlags = 0;
- for (i = 0; i < _countof(_eventorder); i++) {
+ for (auto &it : _eventorder) {
int result = IsDlgButtonChecked(hwndDlg, IDC_T1 + i);
- dwMask |= (result != BST_INDETERMINATE ? _eventorder[i] : 0);
- iFlags |= (result == BST_CHECKED ? _eventorder[i] : 0);
+ dwMask |= (result != BST_INDETERMINATE ? it : 0);
+ iFlags |= (result == BST_CHECKED ? it : 0);
}
if (iFlags & GC_EVENT_ADDSTATUS)
iFlags |= GC_EVENT_REMOVESTATUS;
diff --git a/plugins/TabSRMM/src/hotkeyhandler.cpp b/plugins/TabSRMM/src/hotkeyhandler.cpp
index 7f20c84d5c..b53ec868d1 100644
--- a/plugins/TabSRMM/src/hotkeyhandler.cpp
+++ b/plugins/TabSRMM/src/hotkeyhandler.cpp
@@ -132,8 +132,8 @@ LONG_PTR CALLBACK HotkeyHandlerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
switch (msg) {
case WM_CREATE:
- for (int i = 0; i < _countof(_hotkeydescs); i++)
- Hotkey_Register(&_hotkeydescs[i]);
+ for (auto &it : _hotkeydescs)
+ Hotkey_Register(&it);
WM_TASKBARCREATED = RegisterWindowMessageA("TaskbarCreated");
ShowWindow(hwndDlg, SW_HIDE);
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index aec44485c5..b7aad94078 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -636,8 +636,8 @@ void CSrmmWindow::OnInitDialog()
}
else m_wStatus = ID_STATUS_OFFLINE;
- for (int i = 0; i < _countof(btnControls); i++)
- CustomizeButton(GetDlgItem(m_hwnd, btnControls[i]));
+ for (auto &it : btnControls)
+ CustomizeButton(GetDlgItem(m_hwnd, it));
GetMYUIN();
GetClientIcon();
@@ -721,8 +721,8 @@ void CSrmmWindow::OnInitDialog()
NotifyEvent(MSG_WINDOW_EVT_OPENING);
- for (int i = 0; i < _countof(tooltips); i++)
- SendDlgItemMessage(m_hwnd, tooltips[i].id, BUTTONADDTOOLTIP, (WPARAM)TranslateW(tooltips[i].text), BATF_UNICODE);
+ for (auto &it : tooltips)
+ SendDlgItemMessage(m_hwnd, it.id, BUTTONADDTOOLTIP, (WPARAM)TranslateW(it.text), BATF_UNICODE);
SetDlgItemText(m_hwnd, IDC_LOGFROZENTEXT, m_bNotOnList ? TranslateT("Contact not on list. You may add it...") :
TranslateT("Auto scrolling is disabled (press F12 to enable it)"));
@@ -733,10 +733,10 @@ void CSrmmWindow::OnInitDialog()
SetDlgItemText(m_hwnd, IDC_RETRY, TranslateT("Retry"));
{
UINT _ctrls[] = { IDC_RETRY, IDC_CANCELSEND, IDC_MSGSENDLATER };
- for (int i = 0; i < _countof(_ctrls); i++) {
- SendDlgItemMessage(m_hwnd, _ctrls[i], BUTTONSETASPUSHBTN, TRUE, 0);
- SendDlgItemMessage(m_hwnd, _ctrls[i], BUTTONSETASFLATBTN, FALSE, 0);
- SendDlgItemMessage(m_hwnd, _ctrls[i], BUTTONSETASTHEMEDBTN, TRUE, 0);
+ for (auto &it : _ctrls) {
+ SendDlgItemMessage(m_hwnd, it, BUTTONSETASPUSHBTN, TRUE, 0);
+ SendDlgItemMessage(m_hwnd, it, BUTTONSETASFLATBTN, FALSE, 0);
+ SendDlgItemMessage(m_hwnd, it, BUTTONSETASTHEMEDBTN, TRUE, 0);
}
}
@@ -2443,9 +2443,9 @@ INT_PTR CSrmmWindow::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam)
return 0;
case WM_CBD_LOADICONS:
- for (int i = 0; i < _countof(buttonicons); i++) {
- SendDlgItemMessage(m_hwnd, buttonicons[i].id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)*buttonicons[i].pIcon);
- SendDlgItemMessage(m_hwnd, buttonicons[i].id, BUTTONSETCONTAINER, (LPARAM)m_pContainer, 0);
+ for (auto &it : buttonicons) {
+ SendDlgItemMessage(m_hwnd, it.id, BM_SETIMAGE, IMAGE_ICON, (LPARAM)*it.pIcon);
+ SendDlgItemMessage(m_hwnd, it.id, BUTTONSETCONTAINER, (LPARAM)m_pContainer, 0);
}
Srmm_UpdateToolbarIcons(m_hwnd);
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index 76cc3fbb1f..8635b41daf 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -1238,8 +1238,8 @@ void CTabBaseDlg::GetSendFormat()
else if (m_SendFormat == 0)
m_SendFormat = PluginConfig.m_SendFormat ? 1 : 0;
- for (int i = 0; i < _countof(controls); i++)
- Utils::enableDlgControl(m_hwnd, controls[i], m_SendFormat != 0);
+ for (auto &it : controls)
+ Utils::enableDlgControl(m_hwnd, it, m_SendFormat != 0);
return;
}
diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp
index 5f32b2bd90..8d1760ac6b 100644
--- a/plugins/TabSRMM/src/msgoptions.cpp
+++ b/plugins/TabSRMM/src/msgoptions.cpp
@@ -666,8 +666,8 @@ class COptLogDlg : public CDlgBase
Utils::showDlgControl(m_hwnd, IDC_EXPLAINMSGLOGSETTINGS, r == 0 ? SW_HIDE : SW_SHOW);
Utils::showDlgControl(m_hwnd, IDC_LOGOPTIONS, r == 0 ? SW_SHOW : SW_HIDE);
- for (int i = 0; i < _countof(__ctrls); i++)
- Utils::enableDlgControl(m_hwnd, __ctrls[i], r == 0);
+ for (auto &it : __ctrls)
+ Utils::enableDlgControl(m_hwnd, it, r == 0);
}
public:
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp
index 416c2a1641..57a8b76483 100644
--- a/plugins/TabSRMM/src/msgs.cpp
+++ b/plugins/TabSRMM/src/msgs.cpp
@@ -879,11 +879,12 @@ static int TSAPI SetupIconLibConfig()
sid.flags = SIDF_PATH_UNICODE;
for (int n = 0; n < _countof(ICONBLOCKS); n++) {
- sid.section.a = ICONBLOCKS[n].szSection;
- for (int i = 0; i < ICONBLOCKS[n].nItems; i++) {
- sid.pszName = ICONBLOCKS[n].idesc[i].szName;
- sid.description.a = ICONBLOCKS[n].idesc[i].szDesc;
- sid.iDefaultIndex = ICONBLOCKS[n].idesc[i].uId == -IDI_HISTORY ? 0 : ICONBLOCKS[n].idesc[i].uId; // workaround problem /w icoLib and a resource id of 1 (actually, a Windows problem)
+ auto &it = ICONBLOCKS[n];
+ sid.section.a = it.szSection;
+ for (int i = 0; i < it.nItems; i++) {
+ sid.pszName = it.idesc[i].szName;
+ sid.description.a = it.idesc[i].szDesc;
+ sid.iDefaultIndex = it.idesc[i].uId == -IDI_HISTORY ? 0 : it.idesc[i].uId; // workaround problem /w icoLib and a resource id of 1 (actually, a Windows problem)
if (n > 0 && n < 4)
PluginConfig.g_buttonBarIconHandles[j++] = IcoLib_AddIcon(&sid);
@@ -927,9 +928,9 @@ static int TSAPI SetupIconLibConfig()
// load the icon theme from IconLib - check if it exists...
static int TSAPI LoadFromIconLib()
{
- for (int n = 0; n < _countof(ICONBLOCKS); n++)
- for (int i = 0; i < ICONBLOCKS[n].nItems; i++)
- *(ICONBLOCKS[n].idesc[i].phIcon) = IcoLib_GetIcon(ICONBLOCKS[n].idesc[i].szName);
+ for (auto &it : ICONBLOCKS)
+ for (int i = 0; i < it.nItems; i++)
+ *(it.idesc[i].phIcon) = IcoLib_GetIcon(it.idesc[i].szName);
PluginConfig.g_buttonBarIcons[0] = Skin_LoadIcon(SKINICON_OTHER_ADDCONTACT);
PluginConfig.g_buttonBarIcons[1] = Skin_LoadIcon(SKINICON_OTHER_HISTORY);
@@ -969,11 +970,11 @@ void TSAPI LoadIconTheme()
static void UnloadIcons()
{
- for (int n = 0; n < _countof(ICONBLOCKS); n++)
- for (int i = 0; i < ICONBLOCKS[n].nItems; i++)
- if (*(ICONBLOCKS[n].idesc[i].phIcon) != nullptr) {
- DestroyIcon(*(ICONBLOCKS[n].idesc[i].phIcon));
- *(ICONBLOCKS[n].idesc[i].phIcon) = nullptr;
+ for (auto &it : ICONBLOCKS)
+ for (int i = 0; i < it.nItems; i++)
+ if (*(it.idesc[i].phIcon) != nullptr) {
+ DestroyIcon(*(it.idesc[i].phIcon));
+ *(it.idesc[i].phIcon) = nullptr;
}
if (PluginConfig.g_hbmUnknown)
diff --git a/plugins/TabSRMM/src/tabctrl.cpp b/plugins/TabSRMM/src/tabctrl.cpp
index 49c4add36a..ca27b71ce8 100644
--- a/plugins/TabSRMM/src/tabctrl.cpp
+++ b/plugins/TabSRMM/src/tabctrl.cpp
@@ -1348,9 +1348,9 @@ void TSAPI FreeTabConfig()
if (PluginConfig.tabConfig.m_hMenuFont)
DeleteObject(PluginConfig.tabConfig.m_hMenuFont);
- for (int i = 0; i < _countof(PluginConfig.tabConfig.m_brushes); i++)
- if (PluginConfig.tabConfig.m_brushes[i])
- DeleteObject(PluginConfig.tabConfig.m_brushes[i]);
+ for (auto &it : PluginConfig.tabConfig.m_brushes)
+ if (it)
+ DeleteObject(it);
memset(&PluginConfig.tabConfig, 0, sizeof(PluginConfig.tabConfig));
}
diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp
index 674c9bf512..5916d9f7cb 100644
--- a/plugins/TabSRMM/src/themeio.cpp
+++ b/plugins/TabSRMM/src/themeio.cpp
@@ -211,15 +211,11 @@ void TSAPI WriteThemeToINI(const wchar_t *szIniFilenameT, CSrmmWindow *dat)
}
def = SRMSGDEFSET_BKGCOLOUR;
- for (i = 0; i < _countof(_extSettings); i++) {
- auto &p = _extSettings[i];
- WritePrivateProfileStringA(p.szIniSection, p.szIniName, _itoa(M.GetDword(p.szDbModule, p.szDbSetting, p.dwDef), szBuf, 10), szIniFilename);
- }
+ for (auto &it : _extSettings)
+ WritePrivateProfileStringA(it.szIniSection, it.szIniName, _itoa(M.GetDword(it.szDbModule, it.szDbSetting, it.dwDef), szBuf, 10), szIniFilename);
- for (i = 0; i < _countof(_extSettings_v5); i++) {
- auto &p = _extSettings_v5[i];
- WritePrivateProfileStringA(p.szIniSection, p.szIniName, _itoa(M.GetDword(p.szDbModule, p.szDbSetting, p.dwDef), szBuf, 10), szIniFilename);
- }
+ for (auto &it : _extSettings_v5)
+ WritePrivateProfileStringA(it.szIniSection, it.szIniName, _itoa(M.GetDword(it.szDbModule, it.szDbSetting, it.dwDef), szBuf, 10), szIniFilename);
WritePrivateProfileStringA("Message Log", "VGrid", _itoa(M.GetByte("wantvgrid", 0), szBuf, 10), szIniFilename);
WritePrivateProfileStringA("Message Log", "ExtraMicroLF", _itoa(M.GetByte("extramicrolf", 0), szBuf, 10), szIniFilename);
@@ -307,17 +303,12 @@ void TSAPI ReadThemeFromINI(const wchar_t *szIniFilenameT, TContainerData *dat,
if (dwFlags & THEME_READ_FONTS) {
COLORREF defclr;
- for (i = 0; i < _countof(_extSettings); i++) {
- db_set_dw(0, _extSettings[i].szDbModule, _extSettings[i].szDbSetting,
- GetPrivateProfileIntA(_extSettings[i].szIniSection, _extSettings[i].szIniName, _extSettings[i].dwDef, szIniFilename));
- }
+ for (auto &it : _extSettings)
+ db_set_dw(0, it.szDbModule, it.szDbSetting, GetPrivateProfileIntA(it.szIniSection, it.szIniName, it.dwDef, szIniFilename));
- if (version >= 5) {
- for (i = 0; i < _countof(_extSettings_v5); i++) {
- db_set_dw(0, _extSettings_v5[i].szDbModule, _extSettings_v5[i].szDbSetting,
- GetPrivateProfileIntA(_extSettings_v5[i].szIniSection, _extSettings_v5[i].szIniName, _extSettings_v5[i].dwDef, szIniFilename));
- }
- }
+ if (version >= 5)
+ for (auto &it : _extSettings_v5)
+ db_set_dw(0, it.szDbModule, it.szDbSetting, GetPrivateProfileIntA(it.szIniSection, it.szIniName, it.dwDef, szIniFilename));
db_set_b(0, SRMSGMOD_T, "wantvgrid", (BYTE)(GetPrivateProfileIntA("Message Log", "VGrid", 0, szIniFilename)));
db_set_b(0, SRMSGMOD_T, "extramicrolf", (BYTE)(GetPrivateProfileIntA("Message Log", "ExtraMicroLF", 0, szIniFilename)));
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp
index 1b58c8715d..1ef9533f8e 100644
--- a/plugins/TabSRMM/src/themes.cpp
+++ b/plugins/TabSRMM/src/themes.cpp
@@ -753,7 +753,6 @@ static struct
void CImageItem::Create(const wchar_t *szImageFile)
{
HBITMAP hbm = Bitmap_Load(szImageFile);
- BITMAP bm;
m_hdc = nullptr;
m_hbmOld = nullptr;
@@ -765,6 +764,7 @@ void CImageItem::Create(const wchar_t *szImageFile)
m_bf.BlendOp = AC_SRC_OVER;
m_bf.AlphaFormat = 0;
+ BITMAP bm;
GetObject(hbm, sizeof(bm), &bm);
if (bm.bmBitsPixel == 32 && m_dwFlags & IMAGE_PERPIXEL_ALPHA) {
CImageItem::PreMultiply(m_hbm, 1);
@@ -2428,8 +2428,8 @@ void CSkin::extractSkinsAndLogo(bool fForceOverwrite) const
m_fAeroSkinsValid = true;
- for (int i = 0; i < _countof(my_default_skin); i++)
- if (!Utils::extractResource(g_hInst, my_default_skin[i].ulID, L"SKIN_GLYPH", tszBasePath, my_default_skin[i].tszName, fForceOverwrite))
+ for (auto &it : my_default_skin)
+ if (!Utils::extractResource(g_hInst, it.ulID, L"SKIN_GLYPH", tszBasePath, it.tszName, fForceOverwrite))
m_fAeroSkinsValid = false;
}
diff --git a/plugins/TabSRMM/src/typingnotify.cpp b/plugins/TabSRMM/src/typingnotify.cpp
index 148505f51b..1f5d6f7d8a 100644
--- a/plugins/TabSRMM/src/typingnotify.cpp
+++ b/plugins/TabSRMM/src/typingnotify.cpp
@@ -191,9 +191,9 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
CheckDlgButton(hwndDlg, IDC_USEPOPUPCOLORS, BST_CHECKED);
}
- for (int i = 0; i < _countof(colorPicker); i++) {
- SendDlgItemMessage(hwndDlg, colorPicker[i].res, CPM_SETCOLOUR, 0, colorPicker[i].color);
- Utils::enableDlgControl(hwndDlg, colorPicker[i].res, (ColorMode == COLOR_OWN));
+ for (auto &it : colorPicker) {
+ SendDlgItemMessage(hwndDlg, it.res, CPM_SETCOLOUR, 0, it.color);
+ Utils::enableDlgControl(hwndDlg, it.res, (ColorMode == COLOR_OWN));
}
CheckDlgButton(hwndDlg, IDC_TIMEOUT_PERMANENT, (TimeoutMode == TIMEOUT_PERMANENT) ? BST_CHECKED : BST_UNCHECKED);
@@ -248,8 +248,8 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
bEnableOthers = true;
}
- for (int i = 0; i < _countof(colorPicker); i++)
- Utils::enableDlgControl(hwndDlg, colorPicker[i].res, bEnableOthers);
+ for (auto &it : colorPicker)
+ Utils::enableDlgControl(hwndDlg, it.res, bEnableOthers);
Utils::enableDlgControl(hwndDlg, IDC_USEPOPUPCOLORS, bEnableOthers);
@@ -522,8 +522,8 @@ int TN_ModuleInit()
Timeout2 = M.GetByte(TypigModule, SET_TIMEOUT2, DEF_TIMEOUT2);
if (!(M.GetDword(TypigModule, colorPicker[0].desc, 1) && !M.GetDword(TypigModule, colorPicker[0].desc, 0)))
- for (i = 0; i < _countof(colorPicker); i++)
- colorPicker[i].color = M.GetDword(TypigModule, colorPicker[i].desc, 0);
+ for (auto &it : colorPicker)
+ it.color = M.GetDword(TypigModule, it.desc, 0);
mir_snwprintf(szStart, TranslateT("...is typing a message."));
mir_snwprintf(szStop, TranslateT("...has stopped typing."));
diff --git a/plugins/TipperYM/src/options.cpp b/plugins/TipperYM/src/options.cpp
index f9035502db..17b3d0b310 100644
--- a/plugins/TipperYM/src/options.cpp
+++ b/plugins/TipperYM/src/options.cpp
@@ -355,8 +355,7 @@ void LoadOptions()
opt.dsList = ds_node;
real_count++;
}
- else
- mir_free(ds_node);
+ else mir_free(ds_node);
}
opt.iDsCount = real_count;
@@ -375,8 +374,7 @@ void LoadOptions()
if (di_node->di.bIsVisible && wcsstr(di_node->di.swzValue, L"sys:status_msg"))
opt.bWaitForStatusMsg = true;
}
- else
- mir_free(di_node);
+ else mir_free(di_node);
}
opt.iDiCount = real_count;
@@ -535,105 +533,96 @@ INT_PTR CALLBACK DlgProcAddItem(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- di = (DISPLAYITEM *)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)di);
-
- SetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel);
- SetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue);
-
- for (int i = 0; i < _countof(displayItemTypes); i++) {
- int index = SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_ADDSTRING, (WPARAM)-1, (LPARAM)TranslateW(displayItemTypes[i].title));
- SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_SETITEMDATA, index, (LPARAM)displayItemTypes[i].type);
- if (displayItemTypes[i].type == di->type)
- SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_SETCURSEL, index, 0);
- }
+ TranslateDialogDefault(hwndDlg);
+ di = (DISPLAYITEM *)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)di);
- CheckDlgButton(hwndDlg, IDC_CHK_LINEABOVE, di->bLineAbove ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_VALNEWLINE, di->bValueNewline ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_PARSETIPPERFIRST, di->bParseTipperVarsFirst ? BST_CHECKED : BST_UNCHECKED);
+ SetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel);
+ SetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue);
- for (int i = 0; presetItems[i].szID; i++)
- SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_ADDSTRING, 0, (LPARAM)TranslateW(presetItems[i].swzName));
+ for (auto &it : displayItemTypes) {
+ int index = SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_ADDSTRING, (WPARAM)-1, (LPARAM)TranslateW(it.title));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_SETITEMDATA, index, (LPARAM)it.type);
+ if (it.type == di->type)
+ SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_SETCURSEL, index, 0);
+ }
- variables_skin_helpbutton(hwndDlg, IDC_BTN_VARIABLE);
+ CheckDlgButton(hwndDlg, IDC_CHK_LINEABOVE, di->bLineAbove ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_VALNEWLINE, di->bValueNewline ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_PARSETIPPERFIRST, di->bParseTipperVarsFirst ? BST_CHECKED : BST_UNCHECKED);
+
+ for (int i = 0; presetItems[i].szID; i++)
+ SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_ADDSTRING, 0, (LPARAM)TranslateW(presetItems[i].swzName));
+
+ variables_skin_helpbutton(hwndDlg, IDC_BTN_VARIABLE);
+
+ SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL));
+ return TRUE;
- SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL));
- return TRUE;
- }
case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDOK:
- {
- GetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel, LABEL_LEN);
- GetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue, VALUE_LEN);
-
- int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_GETCURSEL, 0, 0);
- int type = SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_GETITEMDATA, sel, 0);
- for (int i = 0; i < _countof(displayItemTypes); i++) {
- if (displayItemTypes[i].type == type)
- di->type = displayItemTypes[i].type;
- }
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
+ case IDOK:
+ GetDlgItemText(hwndDlg, IDC_ED_LABEL, di->swzLabel, LABEL_LEN);
+ GetDlgItemText(hwndDlg, IDC_ED_VALUE, di->swzValue, VALUE_LEN);
+ {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_GETCURSEL, 0, 0);
+ int type = SendDlgItemMessage(hwndDlg, IDC_CMB_TYPE, CB_GETITEMDATA, sel, 0);
+ for (auto &it : displayItemTypes)
+ if (it.type == type)
+ di->type = it.type;
- di->bLineAbove = (IsDlgButtonChecked(hwndDlg, IDC_CHK_LINEABOVE) ? true : false);
- di->bValueNewline = (IsDlgButtonChecked(hwndDlg, IDC_CHK_VALNEWLINE) ? true : false);
- di->bParseTipperVarsFirst = (IsDlgButtonChecked(hwndDlg, IDC_CHK_PARSETIPPERFIRST) ? true : false);
-
- sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0);
- if (sel != CB_ERR) {
- wchar_t buff[256];
- SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETLBTEXT, sel, (LPARAM)buff);
- for (int i = 0; presetItems[i].szID; i++) {
- if (mir_wstrcmp(buff, TranslateW(presetItems[i].swzName)) == 0) {
- if (presetItems[i].szNeededSubst[0])
- EndDialog(hwndDlg, IDPRESETITEM + i);
- else
- EndDialog(hwndDlg, IDOK);
- break;
- }
- }
- }
- else
- EndDialog(hwndDlg, IDOK);
+ di->bLineAbove = (IsDlgButtonChecked(hwndDlg, IDC_CHK_LINEABOVE) ? true : false);
+ di->bValueNewline = (IsDlgButtonChecked(hwndDlg, IDC_CHK_VALNEWLINE) ? true : false);
+ di->bParseTipperVarsFirst = (IsDlgButtonChecked(hwndDlg, IDC_CHK_PARSETIPPERFIRST) ? true : false);
- return TRUE;
- }
- case IDCANCEL:
- {
- EndDialog(hwndDlg, IDCANCEL);
- return TRUE;
- }
- case IDC_BTN_VARIABLE:
- {
- if (GetFocus() == GetDlgItem(hwndDlg, IDC_ED_LABEL))
- variables_showhelp(hwndDlg, IDC_ED_LABEL, VHF_FULLDLG, nullptr, nullptr);
- else
- variables_showhelp(hwndDlg, IDC_ED_VALUE, VHF_FULLDLG, nullptr, nullptr);
- return TRUE;
- }
- }
- }
- else if (HIWORD(wParam) == CBN_SELCHANGE) {
- if (LOWORD(wParam) == IDC_CMB_PRESETITEMS) {
- int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0);
+ sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0);
if (sel != CB_ERR) {
wchar_t buff[256];
SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETLBTEXT, sel, (LPARAM)buff);
for (int i = 0; presetItems[i].szID; i++) {
if (mir_wstrcmp(buff, TranslateW(presetItems[i].swzName)) == 0) {
- SetDlgItemText(hwndDlg, IDC_ED_LABEL, TranslateW(presetItems[i].swzLabel));
- SetDlgItemText(hwndDlg, IDC_ED_VALUE, presetItems[i].swzValue);
+ if (presetItems[i].szNeededSubst[0])
+ EndDialog(hwndDlg, IDPRESETITEM + i);
+ else
+ EndDialog(hwndDlg, IDOK);
break;
}
}
}
+ else EndDialog(hwndDlg, IDOK);
}
+ return TRUE;
+
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ return TRUE;
+
+ case IDC_BTN_VARIABLE:
+ if (GetFocus() == GetDlgItem(hwndDlg, IDC_ED_LABEL))
+ variables_showhelp(hwndDlg, IDC_ED_LABEL, VHF_FULLDLG, nullptr, nullptr);
+ else
+ variables_showhelp(hwndDlg, IDC_ED_VALUE, VHF_FULLDLG, nullptr, nullptr);
+ return TRUE;
}
- break;
}
+ else if (HIWORD(wParam) == CBN_SELCHANGE) {
+ if (LOWORD(wParam) == IDC_CMB_PRESETITEMS) {
+ int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETCURSEL, 0, 0);
+ if (sel != CB_ERR) {
+ wchar_t buff[256];
+ SendDlgItemMessage(hwndDlg, IDC_CMB_PRESETITEMS, CB_GETLBTEXT, sel, (LPARAM)buff);
+ for (int i = 0; presetItems[i].szID; i++) {
+ if (mir_wstrcmp(buff, TranslateW(presetItems[i].swzName)) == 0) {
+ SetDlgItemText(hwndDlg, IDC_ED_LABEL, TranslateW(presetItems[i].swzLabel));
+ SetDlgItemText(hwndDlg, IDC_ED_VALUE, presetItems[i].swzValue);
+ break;
+ }
+ }
+ }
+ }
+ }
+ break;
}
return 0;
@@ -645,39 +634,38 @@ INT_PTR CALLBACK DlgProcAddSubst(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- ds = (DISPLAYSUBST *)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)ds);
-
- SetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName);
+ TranslateDialogDefault(hwndDlg);
+ ds = (DISPLAYSUBST *)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)ds);
- switch (ds->type) {
- case DVT_PROTODB:
- CheckDlgButton(hwndDlg, IDC_CHK_PROTOMOD, BST_CHECKED);
- SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName);
- break;
- case DVT_DB:
- SetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName);
- SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName);
- break;
- }
+ SetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName);
- for (int i = 0; i < iTransFuncsCount; i++) {
- int index = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_ADDSTRING, (WPARAM)-1, (LPARAM)TranslateW(translations[i].swzName));
- SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETITEMDATA, index, (LPARAM)translations[i].id);
- }
+ switch (ds->type) {
+ case DVT_PROTODB:
+ CheckDlgButton(hwndDlg, IDC_CHK_PROTOMOD, BST_CHECKED);
+ SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName);
+ break;
+ case DVT_DB:
+ SetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName);
+ SetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName);
+ break;
+ }
- for (int i = 0; i < iTransFuncsCount; i++) {
- int id = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, i, 0);
- if (id == ds->iTranslateFuncId)
- SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETCURSEL, i, 0);
- }
+ for (int i = 0; i < iTransFuncsCount; i++) {
+ int index = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_ADDSTRING, (WPARAM)-1, (LPARAM)TranslateW(translations[i].swzName));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETITEMDATA, index, (LPARAM)translations[i].id);
+ }
- SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0);
- SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL));
- return TRUE;
+ for (int i = 0; i < iTransFuncsCount; i++) {
+ int id = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, i, 0);
+ if (id == ds->iTranslateFuncId)
+ SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_SETCURSEL, i, 0);
}
+
+ SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0);
+ SetFocus(GetDlgItem(hwndDlg, IDC_ED_LABEL));
+ return TRUE;
+
case WMU_ENABLE_MODULE_ENTRY:
{
HWND hw = GetDlgItem(hwndDlg, IDC_CHK_PROTOMOD);
@@ -686,52 +674,46 @@ INT_PTR CALLBACK DlgProcAddSubst(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
EnableWindow(hw, BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD));
hw = GetDlgItem(hwndDlg, IDC_ED_SETTING);
EnableWindow(hw, TRUE);
- return TRUE;
}
+ return TRUE;
+
case WM_COMMAND:
- {
- if (HIWORD(wParam) == BN_CLICKED) {
- switch (LOWORD(wParam)) {
- case IDC_CHK_PROTOMOD:
- {
- SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0);
- break;
- }
- case IDOK:
- {
- GetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName, LABEL_LEN);
- if (ds->swzName[0] == 0) {
- MessageBox(hwndDlg, TranslateT("You must enter a label"), TranslateT("Invalid Substitution"), MB_OK | MB_ICONWARNING);
- return TRUE;
- }
+ if (HIWORD(wParam) == BN_CLICKED) {
+ switch (LOWORD(wParam)) {
+ case IDC_CHK_PROTOMOD:
+ SendMessage(hwndDlg, WMU_ENABLE_MODULE_ENTRY, 0, 0);
+ break;
- if (IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD))
- ds->type = DVT_PROTODB;
- else {
- ds->type = DVT_DB;
- GetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName, _countof(ds->szModuleName));
- }
+ case IDOK:
+ GetDlgItemText(hwndDlg, IDC_ED_LABEL, ds->swzName, LABEL_LEN);
+ if (ds->swzName[0] == 0) {
+ MessageBox(hwndDlg, TranslateT("You must enter a label"), TranslateT("Invalid Substitution"), MB_OK | MB_ICONWARNING);
+ return TRUE;
+ }
- GetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName, _countof(ds->szSettingName));
+ if (IsDlgButtonChecked(hwndDlg, IDC_CHK_PROTOMOD))
+ ds->type = DVT_PROTODB;
+ else {
+ ds->type = DVT_DB;
+ GetDlgItemTextA(hwndDlg, IDC_ED_MODULE, ds->szModuleName, _countof(ds->szModuleName));
+ }
- int sel = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETCURSEL, 0, 0);
- ds->iTranslateFuncId = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, sel, 0);
+ GetDlgItemTextA(hwndDlg, IDC_ED_SETTING, ds->szSettingName, _countof(ds->szSettingName));
- EndDialog(hwndDlg, IDOK);
- return TRUE;
- }
- case IDCANCEL:
- {
- EndDialog(hwndDlg, IDCANCEL);
- return TRUE;
- }
- }
- }
- else if (HIWORD(wParam) == CBN_SELCHANGE)
+ ds->iTranslateFuncId = SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_CMB_TRANSLATE, CB_GETCURSEL, 0, 0), 0);
+
+ EndDialog(hwndDlg, IDOK);
return TRUE;
- break;
+ case IDCANCEL:
+ EndDialog(hwndDlg, IDCANCEL);
+ return TRUE;
+ }
}
+ else if (HIWORD(wParam) == CBN_SELCHANGE)
+ return TRUE;
+
+ break;
}
return 0;
@@ -793,7 +775,6 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE) | TVS_CHECKBOXES);
{
-
TVINSERTSTRUCT tvi = {};
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
@@ -1174,6 +1155,7 @@ INT_PTR CALLBACK DlgProcOptsContent(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
break;
}
+
case NM_CLICK:
TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(GetMessagePos());
@@ -1233,196 +1215,191 @@ INT_PTR CALLBACK DlgProcOptsAppearance(HWND hwndDlg, UINT msg, WPARAM wParam, LP
{
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_CHK_SHOWTITLE, opt.bShowTitle ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_NOFOCUS, opt.bShowNoFocus ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_SBAR, opt.bStatusBarTips ? BST_CHECKED : BST_UNCHECKED);
-
- SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No icon"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (int)opt.titleIconLayout, 0);
-
- SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_SETCURSEL, (int)opt.pos, 0);
-
- SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Center"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom"));
- switch (opt.iLabelValign) {
- case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 0, 0); break;
- case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 1, 0); break;
- case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 2, 0); break;
- }
+ TranslateDialogDefault(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Center"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom"));
- switch (opt.iValueValign) {
- case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 0, 0); break;
- case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 1, 0); break;
- case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 2, 0); break;
- }
+ CheckDlgButton(hwndDlg, IDC_CHK_SHOWTITLE, opt.bShowTitle ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_NOFOCUS, opt.bShowNoFocus ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_SBAR, opt.bStatusBarTips ? BST_CHECKED : BST_UNCHECKED);
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("No icon"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_ADDSTRING, 0, (LPARAM)TranslateT("Icon on right"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_SETCURSEL, (int)opt.titleIconLayout, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom right"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top right"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_SETCURSEL, (int)opt.pos, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Center"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom"));
+ switch (opt.iLabelValign) {
+ case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 0, 0); break;
+ case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 1, 0); break;
+ case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_SETCURSEL, 2, 0); break;
+ }
- SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right"));
- switch (opt.iLabelHalign) {
- case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 0, 0); break;
- case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 1, 0); break;
- }
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Top"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Center"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Bottom"));
+ switch (opt.iValueValign) {
+ case DT_TOP: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 0, 0); break;
+ case DT_VCENTER: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 1, 0); break;
+ case DT_BOTTOM: SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_SETCURSEL, 2, 0); break;
+ }
- SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right"));
- switch (opt.iValueHalign) {
- case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 0, 0); break;
- case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 1, 0); break;
- }
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right"));
+ switch (opt.iLabelHalign) {
+ case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 0, 0); break;
+ case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_SETCURSEL, 1, 0); break;
+ }
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar"));
- if (ServiceExists(MS_AV_DRAWAVATAR)) {
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar"));
- }
- else {
- HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV);
- EnableWindow(hw, FALSE);
- hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE);
- EnableWindow(hw, FALSE);
- hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE);
- EnableWindow(hw, FALSE);
- }
- SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)opt.avatarLayout, 0);
-
- SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_MINWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_MINHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_TITLEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_VALUEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_TEXTPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_OUTAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_INAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_HOVER, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 5));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0));
-
- SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, opt.iWinWidth, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, opt.iWinMaxHeight, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, opt.iMinWidth, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, opt.iMinHeight, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, opt.iAvatarSize, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_INDENT, opt.iTextIndent, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, opt.iTitleIndent, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, opt.iValueIndent, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_PADDING, opt.iPadding, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, opt.iTextPadding, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, opt.iOuterAvatarPadding, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, opt.iInnerAvatarPadding, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_HOVER, opt.iTimeIn, FALSE);
- SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, opt.iSidebarWidth, FALSE);
-
- CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, opt.bAvatarRound ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_AVBORDER, opt.bAvatarBorder ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_ORIGINALAVSIZE, opt.bOriginalAvatarSize ? BST_CHECKED : BST_UNCHECKED);
-
- if (opt.bOriginalAvatarSize)
- SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Max avatar size:"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right"));
+ switch (opt.iValueHalign) {
+ case DT_LEFT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 0, 0); break;
+ case DT_RIGHT: SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_SETCURSEL, 1, 0); break;
+ }
- return FALSE;
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("No avatar"));
+ if (ServiceExists(MS_AV_DRAWAVATAR)) {
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Left avatar"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_ADDSTRING, 0, (LPARAM)TranslateT("Right avatar"));
}
+ else {
+ HWND hw = GetDlgItem(hwndDlg, IDC_CMB_AV);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_SPIN_AVSIZE);
+ EnableWindow(hw, FALSE);
+ hw = GetDlgItem(hwndDlg, IDC_ED_AVSIZE);
+ EnableWindow(hw, FALSE);
+ }
+ SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_SETCURSEL, (int)opt.avatarLayout, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_WIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_MINWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_MAXHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_MINHEIGHT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_AVSIZE, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 16));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_INDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_TITLEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_VALUEINDENT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(400, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_PADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_TEXTPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_OUTAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_INAVPADDING, UDM_SETRANGE, 0, (LPARAM)MAKELONG(128, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_HOVER, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 5));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_SBWIDTH, UDM_SETRANGE, 0, (LPARAM)MAKELONG(2048, 0));
+
+ SetDlgItemInt(hwndDlg, IDC_ED_WIDTH, opt.iWinWidth, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, opt.iWinMaxHeight, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, opt.iMinWidth, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, opt.iMinHeight, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, opt.iAvatarSize, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_INDENT, opt.iTextIndent, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, opt.iTitleIndent, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, opt.iValueIndent, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_PADDING, opt.iPadding, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, opt.iTextPadding, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, opt.iOuterAvatarPadding, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, opt.iInnerAvatarPadding, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_HOVER, opt.iTimeIn, FALSE);
+ SetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, opt.iSidebarWidth, FALSE);
+
+ CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERSAV, opt.bAvatarRound ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_AVBORDER, opt.bAvatarBorder ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_ORIGINALAVSIZE, opt.bOriginalAvatarSize ? BST_CHECKED : BST_UNCHECKED);
+
+ if (opt.bOriginalAvatarSize)
+ SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, TranslateT("Max avatar size:"));
+ return FALSE;
+
case WM_COMMAND:
- {
- if (LOWORD(wParam) == IDC_CHK_ORIGINALAVSIZE)
- SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE) ? TranslateT("Max avatar size:") : TranslateT("Avatar size:"));
+ if (LOWORD(wParam) == IDC_CHK_ORIGINALAVSIZE)
+ SetDlgItemText(hwndDlg, IDC_STATIC_AVATARSIZE, IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE) ? TranslateT("Max avatar size:") : TranslateT("Avatar size:"));
- if (HIWORD(wParam) == CBN_SELCHANGE)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- else if (HIWORD(wParam) == BN_CLICKED)
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ if (HIWORD(wParam) == CBN_SELCHANGE)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ else if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ else if (HIWORD(wParam) == BN_CLICKED)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
- BOOL trans;
- int new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE);
- if (trans) opt.iWinWidth = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE);
- if (trans) opt.iMinWidth = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE);
- if (trans) opt.iWinMaxHeight = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, &trans, FALSE);
- if (trans) opt.iMinHeight = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE);
- if (trans) opt.iAvatarSize = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE);
- if (trans) opt.iTextIndent = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, &trans, FALSE);
- if (trans) opt.iTitleIndent = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, &trans, FALSE);
- if (trans) opt.iValueIndent = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE);
- if (trans) opt.iPadding = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, &trans, FALSE);
- if (trans) opt.iTextPadding = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, &trans, FALSE);
- if (trans) opt.iOuterAvatarPadding = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, &trans, FALSE);
- if (trans) opt.iInnerAvatarPadding = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_HOVER, &trans, FALSE);
- if (trans) opt.iTimeIn = new_val;
- new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE);
- if (trans) opt.iSidebarWidth = new_val;
-
- opt.titleIconLayout = (PopupIconTitleLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0);
- opt.avatarLayout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0);
- opt.pos = (PopupPosition)SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_GETCURSEL, 0, 0);
-
- opt.bAvatarBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_AVBORDER) ? true : false;
- opt.bAvatarRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false;
- opt.bOriginalAvatarSize = IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE) ? true : false;
-
- opt.bShowTitle = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHOWTITLE) ? true : false;
- opt.bShowNoFocus = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOFOCUS) ? true : false;
- opt.bStatusBarTips = IsDlgButtonChecked(hwndDlg, IDC_CHK_SBAR) ? true : false;
-
- switch (SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_GETCURSEL, 0, 0)) {
- case 0: opt.iLabelValign = DT_TOP; break;
- case 1: opt.iLabelValign = DT_VCENTER; break;
- case 2: opt.iLabelValign = DT_BOTTOM; break;
- }
+ break;
- switch (SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_GETCURSEL, 0, 0)) {
- case 0: opt.iValueValign = DT_TOP; break;
- case 1: opt.iValueValign = DT_VCENTER; break;
- case 2: opt.iValueValign = DT_BOTTOM; break;
- }
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
+ BOOL trans;
+ int new_val = GetDlgItemInt(hwndDlg, IDC_ED_WIDTH, &trans, FALSE);
+ if (trans) opt.iWinWidth = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINWIDTH, &trans, FALSE);
+ if (trans) opt.iMinWidth = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_MAXHEIGHT, &trans, FALSE);
+ if (trans) opt.iWinMaxHeight = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_MINHEIGHT, &trans, FALSE);
+ if (trans) opt.iMinHeight = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_AVSIZE, &trans, FALSE);
+ if (trans) opt.iAvatarSize = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_INDENT, &trans, FALSE);
+ if (trans) opt.iTextIndent = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_TITLEINDENT, &trans, FALSE);
+ if (trans) opt.iTitleIndent = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_VALUEINDENT, &trans, FALSE);
+ if (trans) opt.iValueIndent = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_PADDING, &trans, FALSE);
+ if (trans) opt.iPadding = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_TEXTPADDING, &trans, FALSE);
+ if (trans) opt.iTextPadding = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_OUTAVPADDING, &trans, FALSE);
+ if (trans) opt.iOuterAvatarPadding = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_INAVPADDING, &trans, FALSE);
+ if (trans) opt.iInnerAvatarPadding = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_HOVER, &trans, FALSE);
+ if (trans) opt.iTimeIn = new_val;
+ new_val = GetDlgItemInt(hwndDlg, IDC_ED_SBWIDTH, &trans, FALSE);
+ if (trans) opt.iSidebarWidth = new_val;
+
+ opt.titleIconLayout = (PopupIconTitleLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_ICON, CB_GETCURSEL, 0, 0);
+ opt.avatarLayout = (PopupAvLayout)SendDlgItemMessage(hwndDlg, IDC_CMB_AV, CB_GETCURSEL, 0, 0);
+ opt.pos = (PopupPosition)SendDlgItemMessage(hwndDlg, IDC_CMB_POS, CB_GETCURSEL, 0, 0);
+
+ opt.bAvatarBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_AVBORDER) ? true : false;
+ opt.bAvatarRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERSAV) && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_CHK_ROUNDCORNERSAV)) ? true : false;
+ opt.bOriginalAvatarSize = IsDlgButtonChecked(hwndDlg, IDC_CHK_ORIGINALAVSIZE) ? true : false;
+
+ opt.bShowTitle = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHOWTITLE) ? true : false;
+ opt.bShowNoFocus = IsDlgButtonChecked(hwndDlg, IDC_CHK_NOFOCUS) ? true : false;
+ opt.bStatusBarTips = IsDlgButtonChecked(hwndDlg, IDC_CHK_SBAR) ? true : false;
+
+ switch (SendDlgItemMessage(hwndDlg, IDC_CMB_LV, CB_GETCURSEL, 0, 0)) {
+ case 0: opt.iLabelValign = DT_TOP; break;
+ case 1: opt.iLabelValign = DT_VCENTER; break;
+ case 2: opt.iLabelValign = DT_BOTTOM; break;
+ }
- switch (SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_GETCURSEL, 0, 0)) {
- case 0: opt.iLabelHalign = DT_LEFT; break;
- case 1: opt.iLabelHalign = DT_RIGHT; break;
- }
+ switch (SendDlgItemMessage(hwndDlg, IDC_CMB_VV, CB_GETCURSEL, 0, 0)) {
+ case 0: opt.iValueValign = DT_TOP; break;
+ case 1: opt.iValueValign = DT_VCENTER; break;
+ case 2: opt.iValueValign = DT_BOTTOM; break;
+ }
- switch (SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_GETCURSEL, 0, 0)) {
- case 0: opt.iValueHalign = DT_LEFT; break;
- case 1: opt.iValueHalign = DT_RIGHT; break;
- }
+ switch (SendDlgItemMessage(hwndDlg, IDC_CMB_LH, CB_GETCURSEL, 0, 0)) {
+ case 0: opt.iLabelHalign = DT_LEFT; break;
+ case 1: opt.iLabelHalign = DT_RIGHT; break;
+ }
- SaveOptions();
- return TRUE;
+ switch (SendDlgItemMessage(hwndDlg, IDC_CMB_VH, CB_GETCURSEL, 0, 0)) {
+ case 0: opt.iValueHalign = DT_LEFT; break;
+ case 1: opt.iValueHalign = DT_RIGHT; break;
}
- break;
+
+ SaveOptions();
+ return TRUE;
}
+ break;
}
return 0;
@@ -1434,40 +1411,40 @@ INT_PTR CALLBACK DlgProcOptsExtra(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_CHK_WAITFORCONTENT, opt.bWaitForContent ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_GETSTATUSMSG, opt.bGetNewStatusMsg ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_DISABLEINVISIBLE, opt.bDisableIfInvisible ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_RETRIEVEXSTATUS, opt.bRetrieveXstatus ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_LIMITMSG, opt.bLimitMsg ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_ENABLESMILEYS, opt.iSmileyAddFlags & SMILEYADD_ENABLE ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_USEPROTOSMILEYS, opt.iSmileyAddFlags & SMILEYADD_USEPROTO ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_ONLYISOLATED, opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_RESIZESMILEYS, opt.iSmileyAddFlags & SMILEYADD_RESIZE ? BST_CHECKED : BST_UNCHECKED);
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), opt.bGetNewStatusMsg);
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg, IDC_CHK_WAITFORCONTENT, opt.bWaitForContent ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_GETSTATUSMSG, opt.bGetNewStatusMsg ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_DISABLEINVISIBLE, opt.bDisableIfInvisible ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_RETRIEVEXSTATUS, opt.bRetrieveXstatus ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_LIMITMSG, opt.bLimitMsg ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_ENABLESMILEYS, opt.iSmileyAddFlags & SMILEYADD_ENABLE ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_USEPROTOSMILEYS, opt.iSmileyAddFlags & SMILEYADD_USEPROTO ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_ONLYISOLATED, opt.iSmileyAddFlags & SMILEYADD_ONLYISOLATED ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_RESIZESMILEYS, opt.iSmileyAddFlags & SMILEYADD_RESIZE ? BST_CHECKED : BST_UNCHECKED);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), opt.bGetNewStatusMsg);
+ {
BOOL bEnable = opt.iSmileyAddFlags & SMILEYADD_ENABLE;
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEPROTOSMILEYS), bEnable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ONLYISOLATED), bEnable);
EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable);
+ }
- SendDlgItemMessage(hwndDlg, IDC_SPIN_CHARCOUNT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(1024, 16));
- SetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, opt.iLimitCharCount, FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), opt.bLimitMsg);
-
- for (int i = 0; i < EXICONS_COUNT; i++) {
- exIcons[i].order = opt.exIconsOrder[i];
- exIcons[i].vis = opt.exIconsVis[i];
- }
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_CHARCOUNT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(1024, 16));
+ SetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, opt.iLimitCharCount, FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), opt.bLimitMsg);
- dat = (EXTRAICONDATA *)mir_alloc(sizeof(EXTRAICONDATA));
- dat->bDragging = false;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
+ for (int i = 0; i < EXICONS_COUNT; i++) {
+ exIcons[i].order = opt.exIconsOrder[i];
+ exIcons[i].vis = opt.exIconsVis[i];
+ }
+ dat = (EXTRAICONDATA *)mir_alloc(sizeof(EXTRAICONDATA));
+ dat->bDragging = false;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
+ {
TVINSERTSTRUCT tvi = {};
tvi.hParent = nullptr;
tvi.hInsertAfter = TVI_LAST;
@@ -1479,129 +1456,115 @@ INT_PTR CALLBACK DlgProcOptsExtra(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
tvi.item.state = INDEXTOSTATEIMAGEMASK(exIcons[i].vis ? 2 : 1);
TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvi);
}
-
- return TRUE;
}
+ return TRUE;
+
case WM_COMMAND:
- {
- switch (LOWORD(wParam)) {
- case IDC_CHK_ENABLESMILEYS:
- {
- BOOL bEnable = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEPROTOSMILEYS), bEnable);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ONLYISOLATED), bEnable);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable);
- break;
- }
- case IDC_CHK_LIMITMSG:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG));
- break;
- }
- case IDC_CHK_GETSTATUSMSG:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG));
- break;
- }
+ switch (LOWORD(wParam)) {
+ case IDC_CHK_ENABLESMILEYS:
+ {
+ BOOL bEnable = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_USEPROTOSMILEYS), bEnable);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_ONLYISOLATED), bEnable);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_RESIZESMILEYS), bEnable);
}
+ break;
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ case IDC_CHK_LIMITMSG:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ED_CHARCOUNT), IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG));
+ break;
+ case IDC_CHK_GETSTATUSMSG:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_DISABLEINVISIBLE), IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG));
break;
}
+
+ if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
case WM_NOTIFY:
- {
- switch (((LPNMHDR)lParam)->idFrom) {
- case 0:
- {
- if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
- TVITEM item = { 0 };
- item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS));
-
- int i = 0;
- while (item.hItem != nullptr) {
- item.mask = TVIF_HANDLE | TVIF_PARAM;
- TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item);
- opt.exIconsOrder[i] = ((ICONSTATE *)item.lParam)->order;
- opt.exIconsVis[i] = ((ICONSTATE *)item.lParam)->vis;
- item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), item.hItem);
- i++;
- }
- db_set_blob(NULL, MODULE, "IconOrder", opt.exIconsOrder, _countof(opt.exIconsOrder));
- db_set_blob(NULL, MODULE, "icons_vis", opt.exIconsVis, _countof(opt.exIconsVis));
-
- opt.iSmileyAddFlags = 0;
- opt.iSmileyAddFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS) ? SMILEYADD_ENABLE : 0)
- | (IsDlgButtonChecked(hwndDlg, IDC_CHK_USEPROTOSMILEYS) ? SMILEYADD_USEPROTO : 0)
- | (IsDlgButtonChecked(hwndDlg, IDC_CHK_ONLYISOLATED) ? SMILEYADD_ONLYISOLATED : 0)
- | (IsDlgButtonChecked(hwndDlg, IDC_CHK_RESIZESMILEYS) ? SMILEYADD_RESIZE : 0);
-
- opt.bWaitForContent = IsDlgButtonChecked(hwndDlg, IDC_CHK_WAITFORCONTENT) ? true : false;
- opt.bGetNewStatusMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG) ? true : false;
- opt.bDisableIfInvisible = IsDlgButtonChecked(hwndDlg, IDC_CHK_DISABLEINVISIBLE) ? true : false;
- opt.bRetrieveXstatus = IsDlgButtonChecked(hwndDlg, IDC_CHK_RETRIEVEXSTATUS) ? true : false;
- opt.bLimitMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG) ? true : false;
- opt.iLimitCharCount = GetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, nullptr, FALSE);
-
- db_set_dw(0, MODULE, "SmileyAddFlags", opt.iSmileyAddFlags);
- db_set_b(0, MODULE, "WaitForContent", opt.bWaitForContent ? 1 : 0);
- db_set_b(0, MODULE, "GetNewStatusMsg", opt.bGetNewStatusMsg ? 1 : 0);
- db_set_b(0, MODULE, "DisableInvisible", opt.bDisableIfInvisible ? 1 : 0);
- db_set_b(0, MODULE, "RetrieveXStatus", opt.bRetrieveXstatus ? 1 : 0);
- db_set_b(0, MODULE, "LimitMsg", opt.bLimitMsg ? 1 : 0);
- db_set_b(0, MODULE, "LimitCharCount", opt.iLimitCharCount);
-
- return TRUE;
- }
- break;
+ switch (((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
+ TVITEM item = {};
+ item.hItem = TreeView_GetRoot(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS));
+
+ int i = 0;
+ while (item.hItem != nullptr) {
+ item.mask = TVIF_HANDLE | TVIF_PARAM;
+ TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item);
+ opt.exIconsOrder[i] = ((ICONSTATE *)item.lParam)->order;
+ opt.exIconsVis[i] = ((ICONSTATE *)item.lParam)->vis;
+ item.hItem = TreeView_GetNextSibling(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), item.hItem);
+ i++;
}
- case IDC_TREE_EXTRAICONS:
- {
- switch (((LPNMHDR)lParam)->code) {
- case TVN_BEGINDRAG:
- SetCapture(hwndDlg);
- dat->bDragging = true;
- dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
- TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem);
- break;
-
- case NM_CLICK:
- {
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(GetMessagePos());
- hti.pt.y = (short)HIWORD(GetMessagePos());
- ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
- if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) {
- if (hti.flags & TVHT_ONITEMSTATEICON) {
- TVITEMA item;
- item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_STATE;
- item.stateMask = TVIS_STATEIMAGEMASK;
- item.hItem = hti.hItem;
- TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
- if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1)
- ((ICONSTATE *)item.lParam)->vis = 1;
- else
- ((ICONSTATE *)item.lParam)->vis = 0;
-
- TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item);
- SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
- }
- break;
- }
+ db_set_blob(NULL, MODULE, "IconOrder", opt.exIconsOrder, _countof(opt.exIconsOrder));
+ db_set_blob(NULL, MODULE, "icons_vis", opt.exIconsVis, _countof(opt.exIconsVis));
+
+ opt.iSmileyAddFlags = 0;
+ opt.iSmileyAddFlags |= (IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLESMILEYS) ? SMILEYADD_ENABLE : 0)
+ | (IsDlgButtonChecked(hwndDlg, IDC_CHK_USEPROTOSMILEYS) ? SMILEYADD_USEPROTO : 0)
+ | (IsDlgButtonChecked(hwndDlg, IDC_CHK_ONLYISOLATED) ? SMILEYADD_ONLYISOLATED : 0)
+ | (IsDlgButtonChecked(hwndDlg, IDC_CHK_RESIZESMILEYS) ? SMILEYADD_RESIZE : 0);
+
+ opt.bWaitForContent = IsDlgButtonChecked(hwndDlg, IDC_CHK_WAITFORCONTENT) ? true : false;
+ opt.bGetNewStatusMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_GETSTATUSMSG) ? true : false;
+ opt.bDisableIfInvisible = IsDlgButtonChecked(hwndDlg, IDC_CHK_DISABLEINVISIBLE) ? true : false;
+ opt.bRetrieveXstatus = IsDlgButtonChecked(hwndDlg, IDC_CHK_RETRIEVEXSTATUS) ? true : false;
+ opt.bLimitMsg = IsDlgButtonChecked(hwndDlg, IDC_CHK_LIMITMSG) ? true : false;
+ opt.iLimitCharCount = GetDlgItemInt(hwndDlg, IDC_ED_CHARCOUNT, nullptr, FALSE);
+
+ db_set_dw(0, MODULE, "SmileyAddFlags", opt.iSmileyAddFlags);
+ db_set_b(0, MODULE, "WaitForContent", opt.bWaitForContent ? 1 : 0);
+ db_set_b(0, MODULE, "GetNewStatusMsg", opt.bGetNewStatusMsg ? 1 : 0);
+ db_set_b(0, MODULE, "DisableInvisible", opt.bDisableIfInvisible ? 1 : 0);
+ db_set_b(0, MODULE, "RetrieveXStatus", opt.bRetrieveXstatus ? 1 : 0);
+ db_set_b(0, MODULE, "LimitMsg", opt.bLimitMsg ? 1 : 0);
+ db_set_b(0, MODULE, "LimitCharCount", opt.iLimitCharCount);
+
+ return TRUE;
+ }
+ break;
+
+ case IDC_TREE_EXTRAICONS:
+ switch (((LPNMHDR)lParam)->code) {
+ case TVN_BEGINDRAG:
+ SetCapture(hwndDlg);
+ dat->bDragging = true;
+ dat->hDragItem = ((LPNMTREEVIEW)lParam)->itemNew.hItem;
+ TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem);
+ break;
+
+ case NM_CLICK:
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(GetMessagePos());
+ hti.pt.y = (short)HIWORD(GetMessagePos());
+ ScreenToClient(((LPNMHDR)lParam)->hwndFrom, &hti.pt);
+ if (TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &hti)) {
+ if (hti.flags & TVHT_ONITEMSTATEICON) {
+ TVITEMA item;
+ item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_STATE;
+ item.stateMask = TVIS_STATEIMAGEMASK;
+ item.hItem = hti.hItem;
+ TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
+ if (((item.state & TVIS_STATEIMAGEMASK) >> 12) == 1)
+ ((ICONSTATE *)item.lParam)->vis = 1;
+ else
+ ((ICONSTATE *)item.lParam)->vis = 0;
+
+ TreeView_SetItem(((LPNMHDR)lParam)->hwndFrom, &item);
+ SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0);
}
- break;
}
+ break;
}
- break;
}
- case WM_MOUSEMOVE:
- {
- if (!dat->bDragging)
- break;
+ break;
+ case WM_MOUSEMOVE:
+ if (dat->bDragging) {
TVHITTESTINFO hti;
hti.pt.x = (short)LOWORD(lParam);
hti.pt.y = (short)HIWORD(lParam);
@@ -1625,58 +1588,56 @@ INT_PTR CALLBACK DlgProcOptsExtra(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), 0, 0);
}
- break;
}
+ break;
+
case WM_LBUTTONUP:
- {
- if (!dat->bDragging)
- break;
+ if (!dat->bDragging)
+ break;
- TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), 0, 0);
- dat->bDragging = false;
- ReleaseCapture();
+ TreeView_SetInsertMark(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), 0, 0);
+ dat->bDragging = false;
+ ReleaseCapture();
+
+ TVHITTESTINFO hti;
+ hti.pt.x = (short)LOWORD(lParam);
+ hti.pt.y = (short)HIWORD(lParam);
+ ClientToScreen(hwndDlg, &hti.pt);
+ ScreenToClient(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti.pt);
+ hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)) / 2;
+ TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti);
+ if (dat->hDragItem == hti.hItem)
+ break;
- TVHITTESTINFO hti;
- hti.pt.x = (short)LOWORD(lParam);
- hti.pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwndDlg, &hti.pt);
- ScreenToClient(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti.pt);
- hti.pt.y -= TreeView_GetItemHeight(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS)) / 2;
- TreeView_HitTest(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &hti);
- if (dat->hDragItem == hti.hItem)
- break;
+ if (hti.flags & TVHT_ABOVE)
+ hti.hItem = TVI_FIRST;
+
+ TVITEM item;
+ item.mask = TVIF_HANDLE | TVIF_PARAM;
+ item.hItem = dat->hDragItem;
+ TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item);
+ if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
+ TVINSERTSTRUCT tvis;
+ wchar_t swzName[256];
+ tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_STATE;
+ tvis.item.stateMask = TVIS_STATEIMAGEMASK;
+ tvis.item.pszText = swzName;
+ tvis.item.cchTextMax = _countof(swzName);
+ tvis.item.hItem = dat->hDragItem;
+ tvis.item.state = INDEXTOSTATEIMAGEMASK(((ICONSTATE *)item.lParam)->vis ? 2 : 1);
+ TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis.item);
+ TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem);
+ tvis.hParent = nullptr;
+ tvis.hInsertAfter = hti.hItem;
+ TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis));
+ SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+ }
- if (hti.flags & TVHT_ABOVE)
- hti.hItem = TVI_FIRST;
-
- TVITEM item;
- item.mask = TVIF_HANDLE | TVIF_PARAM;
- item.hItem = dat->hDragItem;
- TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &item);
- if (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT) || (hti.hItem == TVI_FIRST)) {
- TVINSERTSTRUCT tvis;
- wchar_t swzName[256];
- tvis.item.mask = TVIF_HANDLE | TVIF_PARAM | TVIF_TEXT | TVIF_STATE;
- tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.pszText = swzName;
- tvis.item.cchTextMax = _countof(swzName);
- tvis.item.hItem = dat->hDragItem;
- tvis.item.state = INDEXTOSTATEIMAGEMASK(((ICONSTATE *)item.lParam)->vis ? 2 : 1);
- TreeView_GetItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis.item);
- TreeView_DeleteItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), dat->hDragItem);
- tvis.hParent = nullptr;
- tvis.hInsertAfter = hti.hItem;
- TreeView_SelectItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_EXTRAICONS), &tvis));
- SendMessage((GetParent(hwndDlg)), PSM_CHANGED, (WPARAM)hwndDlg, 0);
- }
+ break;
- break;
- }
case WM_DESTROY:
- {
- mir_free(dat);
- break;
- }
+ mir_free(dat);
+ break;
}
return 0;
}
@@ -1710,174 +1671,166 @@ INT_PTR CALLBACK DlgProcOptsSkin(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
{
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- iLastSel = RefreshSkinList(hwndDlg);
+ TranslateDialogDefault(hwndDlg);
+ iLastSel = RefreshSkinList(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Reload skin list"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[5].hIcolib));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Reload skin list"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_RELOADLIST, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[5].hIcolib));
- SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Apply skin"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[6].hIcolib));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Apply skin"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_APPLYSKIN, BM_SETIMAGE, IMAGE_ICON, (LPARAM)IcoLib_GetIconByHandle(iconList[6].hIcolib));
- SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Get more skins"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_URL));
+ SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Get more skins"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_BTN_GETSKINS, BM_SETIMAGE, IMAGE_ICON, (LPARAM)Skin_LoadIcon(SKINICON_EVENT_URL));
- SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0));
- SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE);
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_TRANS, UDM_SETRANGE, 0, (LPARAM)MAKELONG(100, 0));
+ SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE);
- CheckDlgButton(hwndDlg, IDC_CHK_BORDER, opt.bBorder ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, opt.bRound ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_SHADOW, opt.bDropShadow ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_AEROGLASS, opt.bAeroGlass ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_LOADFONTS, opt.bLoadFonts ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_LOADPROPORTIONS, opt.bLoadProportions ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_BORDER, opt.bBorder ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_ROUNDCORNERS, opt.bRound ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_SHADOW, opt.bDropShadow ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_AEROGLASS, opt.bAeroGlass ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_LOADFONTS, opt.bLoadFonts ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_LOADPROPORTIONS, opt.bLoadProportions ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_AEROGLASS), MyDwmEnableBlurBehindWindow != nullptr);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_CHK_AEROGLASS), MyDwmEnableBlurBehindWindow != nullptr);
- SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("None"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Animation"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Fade"));
- SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_SETCURSEL, (int)opt.showEffect, 0);
+ SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("None"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Animation"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Fade"));
+ SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_SETCURSEL, (int)opt.showEffect, 0);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_SPEED, UDM_SETRANGE, 0, (LPARAM)MAKELONG(20, 1));
- SetDlgItemInt(hwndDlg, IDC_ED_SPEED, opt.iAnimateSpeed, FALSE);
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_SPEED, UDM_SETRANGE, 0, (LPARAM)MAKELONG(20, 1));
+ SetDlgItemInt(hwndDlg, IDC_ED_SPEED, opt.iAnimateSpeed, FALSE);
- EnableControls(hwndDlg, opt.skinMode == SM_IMAGE);
- return TRUE;
- }
- case WM_DRAWITEM:
- {
- if (wParam == IDC_PIC_PREVIEW) {
- DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
- HBRUSH hbr = GetSysColorBrush(COLOR_BTNFACE);
- FillRect(dis->hDC, &dis->rcItem, hbr);
-
- if (opt.szPreviewFile[0]) {
- HDC hdcMem = CreateCompatibleDC(dis->hDC);
- HBITMAP hbmpPreview = Bitmap_Load(opt.szPreviewFile);
- if (hbmpPreview) {
- int iWidth = dis->rcItem.right - dis->rcItem.left;
- int iHeight = dis->rcItem.bottom - dis->rcItem.top;
-
- ResizeBitmap rb = { 0 };
- rb.size = sizeof(rb);
- rb.hBmp = hbmpPreview;
- rb.max_width = iWidth;
- rb.max_height = iHeight;
- rb.fit = RESIZEBITMAP_KEEP_PROPORTIONS;
- HBITMAP hbmpRes = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0);
- if (hbmpRes) {
- BITMAP bmp;
- GetObject(hbmpRes, sizeof(bmp), &bmp);
- SelectObject(hdcMem, hbmpRes);
- BitBlt(dis->hDC, (iWidth - bmp.bmWidth) / 2, (iHeight - bmp.bmHeight) / 2, iWidth, iHeight, hdcMem, 0, 0, SRCCOPY);
- if (hbmpPreview != hbmpRes)
- DeleteBitmap(hbmpRes);
- }
+ EnableControls(hwndDlg, opt.skinMode == SM_IMAGE);
+ return TRUE;
- DeleteBitmap(hbmpPreview);
+ case WM_DRAWITEM:
+ if (wParam == IDC_PIC_PREVIEW) {
+ DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)lParam;
+ HBRUSH hbr = GetSysColorBrush(COLOR_BTNFACE);
+ FillRect(dis->hDC, &dis->rcItem, hbr);
+
+ if (opt.szPreviewFile[0]) {
+ HDC hdcMem = CreateCompatibleDC(dis->hDC);
+ HBITMAP hbmpPreview = Bitmap_Load(opt.szPreviewFile);
+ if (hbmpPreview) {
+ int iWidth = dis->rcItem.right - dis->rcItem.left;
+ int iHeight = dis->rcItem.bottom - dis->rcItem.top;
+
+ ResizeBitmap rb = { 0 };
+ rb.size = sizeof(rb);
+ rb.hBmp = hbmpPreview;
+ rb.max_width = iWidth;
+ rb.max_height = iHeight;
+ rb.fit = RESIZEBITMAP_KEEP_PROPORTIONS;
+ HBITMAP hbmpRes = (HBITMAP)CallService(MS_IMG_RESIZE, (WPARAM)&rb, 0);
+ if (hbmpRes) {
+ BITMAP bmp;
+ GetObject(hbmpRes, sizeof(bmp), &bmp);
+ SelectObject(hdcMem, hbmpRes);
+ BitBlt(dis->hDC, (iWidth - bmp.bmWidth) / 2, (iHeight - bmp.bmHeight) / 2, iWidth, iHeight, hdcMem, 0, 0, SRCCOPY);
+ if (hbmpPreview != hbmpRes)
+ DeleteBitmap(hbmpRes);
}
- DeleteDC(hdcMem);
+ DeleteBitmap(hbmpPreview);
}
+
+ DeleteDC(hdcMem);
}
- break;
}
- case WM_COMMAND:
- {
- switch (HIWORD(wParam)) {
- case LBN_SELCHANGE:
- {
- if (LOWORD(wParam) == IDC_LB_SKINS) {
- HWND hwndList = GetDlgItem(hwndDlg, IDC_LB_SKINS);
- int iSel = ListBox_GetCurSel(hwndList);
- if (iSel != iLastSel) {
- if (iSel == 0) {
- opt.szPreviewFile[0] = 0;
- EnableControls(hwndDlg, false);
- }
- else if (iSel != LB_ERR) {
- wchar_t swzSkinName[256];
- if (ListBox_GetText(hwndList, iSel, swzSkinName) > 0)
- ParseSkinFile(swzSkinName, false, true);
- EnableControls(hwndDlg, true);
- }
+ break;
- InvalidateRect(GetDlgItem(hwndDlg, IDC_PIC_PREVIEW), nullptr, FALSE);
- iLastSel = iSel;
- }
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case LBN_SELCHANGE:
+ if (LOWORD(wParam) == IDC_LB_SKINS) {
+ HWND hwndList = GetDlgItem(hwndDlg, IDC_LB_SKINS);
+ int iSel = ListBox_GetCurSel(hwndList);
+ if (iSel != iLastSel) {
+ if (iSel == 0) {
+ opt.szPreviewFile[0] = 0;
+ EnableControls(hwndDlg, false);
}
- else if (LOWORD(wParam) == IDC_CMB_EFFECT) {
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ else if (iSel != LB_ERR) {
+ wchar_t swzSkinName[256];
+ if (ListBox_GetText(hwndList, iSel, swzSkinName) > 0)
+ ParseSkinFile(swzSkinName, false, true);
+ EnableControls(hwndDlg, true);
}
- break;
+ InvalidateRect(GetDlgItem(hwndDlg, IDC_PIC_PREVIEW), nullptr, FALSE);
+ iLastSel = iSel;
}
- case BN_CLICKED:
- {
- if (LOWORD(wParam) == IDC_BTN_APPLYSKIN) {
- int iSel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_LB_SKINS));
- if (iSel == 0) {
- opt.skinMode = SM_COLORFILL;
- opt.szSkinName[0] = 0;
- }
- else if (iSel != LB_ERR) {
- if (ListBox_GetText(GetDlgItem(hwndDlg, IDC_LB_SKINS), iSel, opt.szSkinName) > 0) {
- opt.skinMode = SM_IMAGE;
- ParseSkinFile(opt.szSkinName, false, false);
- ReloadFont(0, 0);
- SaveOptions();
- }
- }
+ }
+ else if (LOWORD(wParam) == IDC_CMB_EFFECT) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ }
- db_set_b(0, MODULE, "SkinEngine", opt.skinMode);
- db_set_ws(0, MODULE, "SkinName", opt.szSkinName);
+ break;
- DestroySkinBitmap();
- SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE);
+ case BN_CLICKED:
+ if (LOWORD(wParam) == IDC_BTN_APPLYSKIN) {
+ int iSel = ListBox_GetCurSel(GetDlgItem(hwndDlg, IDC_LB_SKINS));
+ if (iSel == 0) {
+ opt.skinMode = SM_COLORFILL;
+ opt.szSkinName[0] = 0;
+ }
+ else if (iSel != LB_ERR) {
+ if (ListBox_GetText(GetDlgItem(hwndDlg, IDC_LB_SKINS), iSel, opt.szSkinName) > 0) {
+ opt.skinMode = SM_IMAGE;
+ ParseSkinFile(opt.szSkinName, false, false);
+ ReloadFont(0, 0);
+ SaveOptions();
}
- else if (LOWORD(wParam) == IDC_BTN_RELOADLIST)
- iLastSel = RefreshSkinList(hwndDlg);
- else if (LOWORD(wParam) == IDC_CHK_LOADFONTS)
- opt.bLoadFonts = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADFONTS) ? true : false;
- else if (LOWORD(wParam) == IDC_CHK_LOADPROPORTIONS)
- opt.bLoadProportions = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADPROPORTIONS) ? true : false;
- else if (LOWORD(wParam) == IDC_BTN_GETSKINS)
- Utils_OpenUrl("https://miranda-ng.org/addons/category/48");
-
- break;
}
- }
- if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ db_set_b(0, MODULE, "SkinEngine", opt.skinMode);
+ db_set_ws(0, MODULE, "SkinName", opt.szSkinName);
- break;
- }
- case WM_NOTIFY:
- {
- if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
- opt.iOpacity = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, nullptr, 0);
- opt.bDropShadow = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHADOW) ? true : false;
- opt.bBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) ? true : false;
- opt.bRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) ? true : false;
- opt.bAeroGlass = IsDlgButtonChecked(hwndDlg, IDC_CHK_AEROGLASS) ? true : false;
- opt.showEffect = (PopupShowEffect)SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_GETCURSEL, 0, 0);
- opt.iAnimateSpeed = GetDlgItemInt(hwndDlg, IDC_ED_SPEED, nullptr, 0);
+ DestroySkinBitmap();
+ SetDlgItemInt(hwndDlg, IDC_ED_TRANS, opt.iOpacity, FALSE);
+ }
+ else if (LOWORD(wParam) == IDC_BTN_RELOADLIST)
+ iLastSel = RefreshSkinList(hwndDlg);
+ else if (LOWORD(wParam) == IDC_CHK_LOADFONTS)
opt.bLoadFonts = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADFONTS) ? true : false;
+ else if (LOWORD(wParam) == IDC_CHK_LOADPROPORTIONS)
opt.bLoadProportions = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADPROPORTIONS) ? true : false;
+ else if (LOWORD(wParam) == IDC_BTN_GETSKINS)
+ Utils_OpenUrl("https://miranda-ng.org/addons/category/48");
+
+ break;
+ }
- if (opt.iEnableColoring != -1)
- opt.iEnableColoring = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLECOLORING) ? true : false;
+ if ((HIWORD(wParam) == BN_CLICKED || HIWORD(wParam) == EN_CHANGE) && (HWND)lParam == GetFocus())
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- SaveSkinOptions();
- return TRUE;
- }
+ break;
+
+ case WM_NOTIFY:
+ if (((LPNMHDR)lParam)->code == (unsigned)PSN_APPLY) {
+ opt.iOpacity = GetDlgItemInt(hwndDlg, IDC_ED_TRANS, nullptr, 0);
+ opt.bDropShadow = IsDlgButtonChecked(hwndDlg, IDC_CHK_SHADOW) ? true : false;
+ opt.bBorder = IsDlgButtonChecked(hwndDlg, IDC_CHK_BORDER) ? true : false;
+ opt.bRound = IsDlgButtonChecked(hwndDlg, IDC_CHK_ROUNDCORNERS) ? true : false;
+ opt.bAeroGlass = IsDlgButtonChecked(hwndDlg, IDC_CHK_AEROGLASS) ? true : false;
+ opt.showEffect = (PopupShowEffect)SendDlgItemMessage(hwndDlg, IDC_CMB_EFFECT, CB_GETCURSEL, 0, 0);
+ opt.iAnimateSpeed = GetDlgItemInt(hwndDlg, IDC_ED_SPEED, nullptr, 0);
+ opt.bLoadFonts = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADFONTS) ? true : false;
+ opt.bLoadProportions = IsDlgButtonChecked(hwndDlg, IDC_CHK_LOADPROPORTIONS) ? true : false;
+
+ if (opt.iEnableColoring != -1)
+ opt.iEnableColoring = IsDlgButtonChecked(hwndDlg, IDC_CHK_ENABLECOLORING) ? true : false;
+
+ SaveSkinOptions();
+ return TRUE;
}
}
@@ -1894,13 +1847,13 @@ INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam,
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETUSEGROUPS, db_get_b(NULL, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT), 0);
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETGREYOUTFLAGS, 0, 0);
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETLEFTMARGIN, 2, 0);
- {
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
- HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0);
- if (hItem && db_get_b(hContact, MODULE, "FavouriteContact", 0))
- SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
- }
+
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_FINDCONTACT, hContact, 0);
+ if (hItem && db_get_b(hContact, MODULE, "FavouriteContact", 0))
+ SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, (WPARAM)hItem, 1);
}
+
CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.iFavoriteContFlags & FAVCONT_HIDE_OFFLINE ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_CHK_APPENDPROTO, opt.iFavoriteContFlags & FAVCONT_APPEND_PROTO ? BST_CHECKED : BST_UNCHECKED);
return TRUE;
@@ -1928,7 +1881,9 @@ INT_PTR CALLBACK DlgProcFavouriteContacts(HWND hwndDlg, UINT msg, WPARAM wParam,
| IsDlgButtonChecked(hwndDlg, IDC_CHK_APPENDPROTO) ? FAVCONT_APPEND_PROTO : 0;
db_set_dw(0, MODULE, "FavContFlags", opt.iFavoriteContFlags);
- } // fall through
+ }
+ // fall through
+
case IDC_BTN_CANCEL:
DestroyWindow(hwndDlg);
break;
@@ -1947,32 +1902,31 @@ INT_PTR CALLBACK DlgProcOptsTraytip(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
{
switch (msg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_CHK_ENABLETRAYTIP, opt.bTraytip ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_HANDLEBYTIPPER, opt.bHandleByTipper ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_EXPAND, opt.bExpandTraytip ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.bHideOffline ? BST_CHECKED : BST_UNCHECKED);
- SendDlgItemMessage(hwndDlg, IDC_SPIN_EXPANDTIME, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 10));
- SetDlgItemInt(hwndDlg, IDC_ED_EXPANDTIME, opt.iExpandTime, FALSE);
- SendMessage(hwndDlg, WM_COMMAND, MAKELONG(IDC_CHK_ENABLETRAYTIP, 0), 0);
-
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
+ TranslateDialogDefault(hwndDlg);
+ CheckDlgButton(hwndDlg, IDC_CHK_ENABLETRAYTIP, opt.bTraytip ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_HANDLEBYTIPPER, opt.bHandleByTipper ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_EXPAND, opt.bExpandTraytip ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_CHK_HIDEOFFLINE, opt.bHideOffline ? BST_CHECKED : BST_UNCHECKED);
+ SendDlgItemMessage(hwndDlg, IDC_SPIN_EXPANDTIME, UDM_SETRANGE, 0, (LPARAM)MAKELONG(5000, 10));
+ SetDlgItemInt(hwndDlg, IDC_ED_EXPANDTIME, opt.iExpandTime, FALSE);
+ SendMessage(hwndDlg, WM_COMMAND, MAKELONG(IDC_CHK_ENABLETRAYTIP, 0), 0);
+
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_PROTOS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_PROTOS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
+ {
TVINSERTSTRUCT tvi = {};
tvi.hParent = nullptr;
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_STATE;
- int i, count = 0;
+ int count = 0;
PROTOACCOUNT **accs;
Proto_EnumAccounts(&count, &accs);
- for (i = 0; i < count; i++) {
+ for (int i = 0; i < count; i++) {
if (CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) != 0) {
tvi.item.pszText = accs[i]->tszAccountName;
tvi.item.stateMask = TVIS_STATEIMAGEMASK;
@@ -1983,16 +1937,16 @@ INT_PTR CALLBACK DlgProcOptsTraytip(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
}
}
- for (i = 0; i < _countof(trayTipItems); i++) {
+ for (int i = 0; i < _countof(trayTipItems); i++) {
tvi.item.pszText = TranslateW(trayTipItems[i]);
tvi.item.state = INDEXTOSTATEIMAGEMASK(opt.iFirstItems & (1 << i) ? 2 : 1);
TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_FIRST_ITEMS), &tvi);
tvi.item.state = INDEXTOSTATEIMAGEMASK(opt.iSecondItems & (1 << i) ? 2 : 1);
TreeView_InsertItem(GetDlgItem(hwndDlg, IDC_TREE_SECOND_ITEMS), &tvi);
}
-
- return TRUE;
}
+ return TRUE;
+
case WM_COMMAND:
switch (LOWORD(wParam)) {
UINT state;
diff --git a/plugins/TipperYM/src/translations.cpp b/plugins/TipperYM/src/translations.cpp
index c8f8d58e18..086309c988 100644
--- a/plugins/TipperYM/src/translations.cpp
+++ b/plugins/TipperYM/src/translations.cpp
@@ -15,7 +15,7 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this file; see the file license.txt. If
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
+Boston, MA 02111-1307, USA.
*/
#include "stdafx.h"
@@ -26,33 +26,29 @@ DBVTranslation *translations = nullptr;
DWORD dwNextFuncId;
HANDLE hServiceAdd;
-void AddTranslation(DBVTranslation *newTrans)
+void AddTranslation(DBVTranslation *newTrans)
{
- DBVTranslation *ptranslations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * (iTransFuncsCount+1));
+ DBVTranslation *ptranslations = (DBVTranslation *)mir_realloc(translations, sizeof(DBVTranslation) * (iTransFuncsCount + 1));
if (ptranslations == nullptr)
return;
translations = ptranslations;
iTransFuncsCount++;
translations[iTransFuncsCount - 1] = *newTrans;
-
+
char *szName = mir_u2a(newTrans->swzName);
char szSetting[256];
- mir_snprintf(szSetting, sizeof(szSetting),"Trans_%s",szName);
+ mir_snprintf(szSetting, sizeof(szSetting), "Trans_%s", szName);
- if (mir_wstrcmp(newTrans->swzName, L"[No translation]") == 0)
- {
+ if (mir_wstrcmp(newTrans->swzName, L"[No translation]") == 0) {
translations[iTransFuncsCount - 1].id = 0;
- }
- else
- {
+ }
+ else {
DWORD id = db_get_dw(0, MODULE_ITEMS, szSetting, 0);
- if (id != 0)
- {
+ if (id != 0) {
translations[iTransFuncsCount - 1].id = id;
if (dwNextFuncId <= id) dwNextFuncId = id + 1;
- }
- else
- {
+ }
+ else {
translations[iTransFuncsCount - 1].id = dwNextFuncId++;
db_set_dw(0, MODULE_ITEMS, szSetting, translations[iTransFuncsCount - 1].id);
}
@@ -63,59 +59,59 @@ void AddTranslation(DBVTranslation *newTrans)
mir_free(szName);
}
-wchar_t *NullTranslation(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *NullTranslation(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
if (DBGetContactSettingAsString(hContact, szModuleName, szSettingName, buff, bufflen))
return buff;
return nullptr;
}
-wchar_t* TimestampToShortDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToShortDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"d", buff, bufflen);
}
-wchar_t* TimestampToLongDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToLongDate(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"D", buff, bufflen);
}
-wchar_t* TimestampToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"s", buff, bufflen);
}
-wchar_t* TimestampToTimeNoSecs(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToTimeNoSecs(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ts == 0)
return nullptr;
-
+
return TimeZone_ToStringT(ts, L"t", buff, bufflen);
}
-wchar_t* TimestampToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t* TimestampToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ts = db_get_dw(hContact, szModuleName, szSettingName, 0);
DWORD t = (DWORD)time(nullptr);
if (ts == 0) return nullptr;
-
+
DWORD diff = (ts > t) ? 0 : (t - ts);
int d = (diff / 60 / 60 / 24);
int h = (diff - d * 60 * 60 * 24) / 60 / 60;
- int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
+ int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
if (d > 0)
mir_snwprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m);
else if (h > 0)
@@ -126,12 +122,12 @@ wchar_t* TimestampToTimeDifference(MCONTACT hContact, const char *szModuleName,
return buff;
}
-wchar_t *SecondsToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *SecondsToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD diff = db_get_dw(hContact, szModuleName, szSettingName, 0);
int d = (diff / 60 / 60 / 24);
int h = (diff - d * 60 * 60 * 24) / 60 / 60;
- int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
+ int m = (diff - d * 60 * 60 * 24 - h * 60 * 60) / 60;
if (d > 0)
mir_snwprintf(buff, bufflen, TranslateT("%dd %dh %dm"), d, h, m);
else if (h > 0)
@@ -142,7 +138,7 @@ wchar_t *SecondsToTimeDifference(MCONTACT hContact, const char *szModuleName, co
return buff;
}
-wchar_t *WordToStatusDesc(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *WordToStatusDesc(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
WORD wStatus = db_get_w(hContact, szModuleName, szSettingName, ID_STATUS_OFFLINE);
wchar_t *szStatus = pcli->pfnGetStatusModeDescription(wStatus, 0);
@@ -150,13 +146,11 @@ wchar_t *WordToStatusDesc(MCONTACT hContact, const char *szModuleName, const cha
return buff;
}
-wchar_t *ByteToYesNo(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToYesNo(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (dbv.type == DBVT_BYTE)
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (dbv.type == DBVT_BYTE) {
if (dbv.bVal != 0)
wcsncpy(buff, L"Yes", bufflen);
else
@@ -170,7 +164,7 @@ wchar_t *ByteToYesNo(MCONTACT hContact, const char *szModuleName, const char *sz
return nullptr;
}
-wchar_t *ByteToGender(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToGender(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
BYTE val = (BYTE)db_get_b(hContact, szModuleName, szSettingName, 0);
if (val == 'F')
@@ -184,12 +178,11 @@ wchar_t *ByteToGender(MCONTACT hContact, const char *szModuleName, const char *s
return buff;
}
-wchar_t *WordToCountry(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *WordToCountry(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
char *szCountryName = nullptr;
WORD cid = (WORD)db_get_w(hContact, szModuleName, szSettingName, (WORD)-1);
- if (cid != (WORD)-1 && ServiceExists(MS_UTILS_GETCOUNTRYBYNUMBER) && (szCountryName = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, cid, 0)) != nullptr)
- {
+ if (cid != (WORD)-1 && ServiceExists(MS_UTILS_GETCOUNTRYBYNUMBER) && (szCountryName = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, cid, 0)) != nullptr) {
if (mir_strcmp(szCountryName, "Unknown") == 0)
return nullptr;
a2t(szCountryName, buff, bufflen);
@@ -199,7 +192,7 @@ wchar_t *WordToCountry(MCONTACT hContact, const char *szModuleName, const char *
return nullptr;
}
-wchar_t *DwordToIp(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *DwordToIp(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
DWORD ip = db_get_dw(hContact, szModuleName, szSettingName, 0);
if (ip) {
@@ -210,42 +203,37 @@ wchar_t *DwordToIp(MCONTACT hContact, const char *szModuleName, const char *szSe
return nullptr;
}
-bool GetInt(const DBVARIANT &dbv, int *iVal)
+bool GetInt(const DBVARIANT &dbv, int *iVal)
{
if (!iVal) return false;
- switch(dbv.type)
- {
- case DBVT_BYTE:
- if (iVal) *iVal = (int)dbv.bVal;
- return true;
- case DBVT_WORD:
- if (iVal) *iVal = (int)dbv.wVal;
- return true;
- case DBVT_DWORD:
- if (iVal) *iVal = (int)dbv.dVal;
- return true;
+ switch (dbv.type) {
+ case DBVT_BYTE:
+ if (iVal) *iVal = (int)dbv.bVal;
+ return true;
+ case DBVT_WORD:
+ if (iVal) *iVal = (int)dbv.wVal;
+ return true;
+ case DBVT_DWORD:
+ if (iVal) *iVal = (int)dbv.dVal;
+ return true;
}
return false;
}
-wchar_t *DayMonthYearToDate(MCONTACT hContact, const char *szModuleName, const char *prefix, wchar_t *buff, int bufflen)
+wchar_t *DayMonthYearToDate(MCONTACT hContact, const char *szModuleName, const char *prefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", prefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", prefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sYear", prefix);
int year = 0;
@@ -262,42 +250,36 @@ wchar_t *DayMonthYearToDate(MCONTACT hContact, const char *szModuleName, const c
wcsftime(buff, bufflen, L"%x", &time);
return buff;
-
- }
- else
+
+ }
+ else
db_free(&dbv);
}
- }
- else
+ }
+ else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *DayMonthYearToAge(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *DayMonthYearToAge(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", szPrefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sYear", szPrefix);
int year = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &year) && year != 0)
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &year) && year != 0) {
db_free(&dbv);
SYSTEMTIME now;
@@ -308,149 +290,129 @@ wchar_t *DayMonthYearToAge(MCONTACT hContact, const char *szModuleName, const ch
age--;
mir_snwprintf(buff, bufflen, L"%d", age);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *HoursMinutesSecondsToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *HoursMinutesSecondsToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sHours", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int hours = 0;
- if (GetInt(dbv, &hours))
- {
+ if (GetInt(dbv, &hours)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMinutes", szPrefix);
int minutes = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &minutes))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &minutes)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sSeconds", szPrefix);
int seconds = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
GetInt(dbv, &seconds);
db_free(&dbv);
}
- SYSTEMTIME st = {0};
+ SYSTEMTIME st = { 0 };
st.wHour = hours;
st.wMinute = minutes;
st.wSecond = seconds;
- GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, buff, bufflen);
+ GetTimeFormat(LOCALE_USER_DEFAULT, 0, &st, nullptr, buff, bufflen);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *HoursMinutesToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *HoursMinutesToTime(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sHours", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int hours = 0;
- if (GetInt(dbv, &hours))
- {
+ if (GetInt(dbv, &hours)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMinutes", szPrefix);
int minutes = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &minutes))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &minutes)) {
db_free(&dbv);
- SYSTEMTIME st = {0};
+ SYSTEMTIME st = { 0 };
st.wHour = hours;
st.wMinute = minutes;
- GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, nullptr, buff, bufflen);
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, nullptr, buff, bufflen);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", szPrefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sYear", szPrefix);
int year = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &year))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &year)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sHours", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int hours = 0;
- if (GetInt(dbv, &hours))
- {
+ if (GetInt(dbv, &hours)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMinutes", szPrefix);
int minutes = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &minutes))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &minutes)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sSeconds", szPrefix);
int seconds = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
GetInt(dbv, &seconds);
db_free(&dbv);
}
- SYSTEMTIME st = {0}, st_now;
+ SYSTEMTIME st = { 0 }, st_now;
st.wDay = day;
st.wMonth = month;
st.wYear = year;
@@ -462,7 +424,7 @@ wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const
FILETIME ft, ft_now;
SystemTimeToFileTime(&st, &ft);
SystemTimeToFileTime(&st_now, &ft_now);
-
+
LARGE_INTEGER li, li_now;
li.HighPart = ft.dwHighDateTime; li.LowPart = ft.dwLowDateTime;
li_now.HighPart = ft_now.dwHighDateTime; li_now.LowPart = ft_now.dwLowDateTime;
@@ -471,7 +433,7 @@ wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const
int y = diff / 60 / 60 / 24 / 365;
int d = (diff - y * 60 * 60 * 24 * 365) / 60 / 60 / 24;
int h = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24) / 60 / 60;
- int m = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24 - h * 60 * 60) / 60;
+ int m = (diff - y * 60 * 60 * 24 * 365 - d * 60 * 60 * 24 - h * 60 * 60) / 60;
if (y != 0)
mir_snwprintf(buff, bufflen, TranslateT("%dy %dd %dh %dm"), y, d, h, m);
else if (d != 0)
@@ -482,46 +444,42 @@ wchar_t *DmyToTimeDifference(MCONTACT hContact, const char *szModuleName, const
mir_snwprintf(buff, bufflen, TranslateT("%dm"), m);
return buff;
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
- }
+ }
else
db_free(&dbv);
}
return nullptr;
}
-wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
+wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleName, const char *szPrefix, wchar_t *buff, int bufflen)
{
DBVARIANT dbv;
char szSettingName[256];
mir_snprintf(szSettingName, "%sDay", szPrefix);
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
int day = 0;
- if (GetInt(dbv, &day))
- {
+ if (GetInt(dbv, &day)) {
db_free(&dbv);
mir_snprintf(szSettingName, "%sMonth", szPrefix);
int month = 0;
- if (!db_get(hContact, szModuleName, szSettingName, &dbv))
- {
- if (GetInt(dbv, &month))
- {
+ if (!db_get(hContact, szModuleName, szSettingName, &dbv)) {
+ if (GetInt(dbv, &month)) {
db_free(&dbv);
time_t now = time(nullptr);
struct tm *ti = localtime(&now);
@@ -532,25 +490,22 @@ wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleNam
mktime(ti);
int yday_birth = ti->tm_yday;
- if (yday_birth < yday_now)
- {
+ if (yday_birth < yday_now) {
yday_now -= 365;
- yday_now -= (ti->tm_year % 4) ? 0 : 1;
+ yday_now -= (ti->tm_year % 4) ? 0 : 1;
}
int diff = yday_birth - yday_now;
mir_snwprintf(buff, bufflen, TranslateT("%dd"), diff);
-
+
return buff;
}
- else
- {
+ else {
db_free(&dbv);
}
}
- }
- else
- {
+ }
+ else {
db_free(&dbv);
}
}
@@ -558,17 +513,16 @@ wchar_t *DayMonthToDaysToNextBirthday(MCONTACT hContact, const char *szModuleNam
}
-wchar_t *EmptyXStatusToDefaultName(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *EmptyXStatusToDefaultName(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
wchar_t szDefaultName[1024];
- CUSTOM_STATUS xstatus = {0};
+ CUSTOM_STATUS xstatus = { 0 };
DBVARIANT dbv;
// translate jabber mood
if (ProtoServiceExists(szModuleName, "/SendXML")) // jabber protocol?
- {
- if (!db_get_ws(hContact, szModuleName, szSettingName, &dbv))
- {
+ {
+ if (!db_get_ws(hContact, szModuleName, szSettingName, &dbv)) {
wcsncpy(buff, TranslateW(dbv.ptszVal), bufflen);
buff[bufflen - 1] = 0;
return buff;
@@ -576,32 +530,31 @@ wchar_t *EmptyXStatusToDefaultName(MCONTACT hContact, const char *szModuleName,
}
if (NullTranslation(hContact, szModuleName, szSettingName, buff, bufflen))
- return buff;
-
+ return buff;
+
int status = db_get_b(hContact, szModuleName, "XStatusId", 0);
if (!status) return nullptr;
-
- if (ProtoServiceExists(szModuleName, PS_GETCUSTOMSTATUSEX))
- {
+
+ if (ProtoServiceExists(szModuleName, PS_GETCUSTOMSTATUSEX)) {
xstatus.cbSize = sizeof(CUSTOM_STATUS);
xstatus.flags = CSSF_MASK_NAME | CSSF_DEFAULT_NAME | CSSF_UNICODE;
xstatus.ptszName = szDefaultName;
xstatus.wParam = (WPARAM *)&status;
if (CallProtoService(szModuleName, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&xstatus))
- return nullptr;
-
+ return nullptr;
+
wcsncpy(buff, TranslateW(szDefaultName), bufflen);
buff[bufflen - 1] = 0;
return buff;
- }
+ }
return nullptr;
}
-wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
- int timezone = db_get_b(hContact,szModuleName,szSettingName,256);
- if (timezone==256 || (char)timezone==-100)
+ int timezone = db_get_b(hContact, szModuleName, szSettingName, 256);
+ if (timezone == 256 || (char)timezone == -100)
return nullptr;
TIME_ZONE_INFORMATION tzi;
@@ -609,7 +562,7 @@ wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char
LARGE_INTEGER lift;
SYSTEMTIME st;
- timezone=(char)timezone;
+ timezone = (char)timezone;
GetSystemTimeAsFileTime(&ft);
if (GetTimeZoneInformation(&tzi) == TIME_ZONE_ID_DAYLIGHT)
timezone += tzi.DaylightBias / 30;
@@ -623,11 +576,10 @@ wchar_t *TimezoneToTime(MCONTACT hContact, const char *szModuleName, const char
return buff;
}
-wchar_t *ByteToDay(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToDay(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
int iDay = db_get_w(hContact, szModuleName, szSettingName, -1);
- if (iDay > -1 && iDay < 7)
- {
+ if (iDay > -1 && iDay < 7) {
a2t(Translate(days[iDay]), buff, bufflen);
buff[bufflen - 1] = 0;
return buff;
@@ -636,11 +588,10 @@ wchar_t *ByteToDay(MCONTACT hContact, const char *szModuleName, const char *szSe
return nullptr;
}
-wchar_t *ByteToMonth(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToMonth(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
int iMonth = db_get_w(hContact, szModuleName, szSettingName, 0);
- if (iMonth > 0 && iMonth < 13)
- {
+ if (iMonth > 0 && iMonth < 13) {
a2t(Translate(months[iMonth - 1]), buff, bufflen);
buff[bufflen - 1] = 0;
return buff;
@@ -649,16 +600,13 @@ wchar_t *ByteToMonth(MCONTACT hContact, const char *szModuleName, const char *sz
return nullptr;
}
-wchar_t *ByteToLanguage(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
+wchar_t *ByteToLanguage(MCONTACT hContact, const char *szModuleName, const char *szSettingName, wchar_t *buff, int bufflen)
{
int iLang = db_get_b(hContact, szModuleName, szSettingName, 0);
- if (iLang)
- {
- for (int i = 0; i < _countof(languages); i++)
- {
- if (iLang == languages[i].id)
- {
- a2t(Translate(languages[i].szValue), buff, bufflen);
+ if (iLang) {
+ for (auto &it : languages) {
+ if (iLang == it.id) {
+ a2t(Translate(it.szValue), buff, bufflen);
buff[bufflen - 1] = 0;
return buff;
}
@@ -668,7 +616,7 @@ wchar_t *ByteToLanguage(MCONTACT hContact, const char *szModuleName, const char
return nullptr;
}
-INT_PTR ServiceAddTranslation(WPARAM, LPARAM lParam)
+INT_PTR ServiceAddTranslation(WPARAM, LPARAM lParam)
{
if (!lParam) return 1;
@@ -678,7 +626,7 @@ INT_PTR ServiceAddTranslation(WPARAM, LPARAM lParam)
return 0;
}
-static DBVTranslation internalTranslations[] =
+static DBVTranslation internalTranslations[] =
{
{ NullTranslation, LPGENW("[No translation]") },
{ WordToStatusDesc, LPGENW("WORD to status description") },
@@ -705,11 +653,11 @@ static DBVTranslation internalTranslations[] =
{ ByteToLanguage, LPGENW("BYTE to language (ICQ)") },
};
-void InitTranslations()
+void InitTranslations()
{
dwNextFuncId = db_get_dw(0, MODULE_ITEMS, "NextFuncId", 1);
- for (int i = 0; i < _countof(internalTranslations); i++)
- AddTranslation(&internalTranslations[i]);
+ for (auto &it : internalTranslations)
+ AddTranslation(&it);
hServiceAdd = CreateServiceFunction(MS_TIPPER_ADDTRANSLATION, ServiceAddTranslation);
}
@@ -719,4 +667,3 @@ void DeinitTranslations()
DestroyServiceFunction(hServiceAdd);
mir_free(translations);
}
-
diff --git a/plugins/UserInfoEx/src/ctrl_annivedit.cpp b/plugins/UserInfoEx/src/ctrl_annivedit.cpp
index 283710341a..7f43748282 100644
--- a/plugins/UserInfoEx/src/ctrl_annivedit.cpp
+++ b/plugins/UserInfoEx/src/ctrl_annivedit.cpp
@@ -366,8 +366,8 @@ INT_PTR CAnnivEditCtrl::DBWriteAnniversaries(MCONTACT hContact)
do {
ofs = mir_snprintf(szSet0, "Anniv%d", wIndex);
ret = 1;
- for (i = 0; i < _countof(szPrefix); i++) {
- mir_strncpy(szSet0 + ofs, szPrefix[i], _countof(szSet0) - ofs);
+ for (auto &it : szPrefix) {
+ mir_strncpy(szSet0 + ofs, it, _countof(szSet0) - ofs);
ret &= db_unset(hContact, USERINFO, szSet0);
}
}
diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp
index 948b70dba8..3ab88e18a0 100644
--- a/plugins/UserInfoEx/src/dlg_propsheet.cpp
+++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp
@@ -793,15 +793,15 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
static const WORD idMove[] = { IDC_PAGETITLE, IDC_PAGETITLEBG, IDC_PAGETITLEBG2, IDOK, IDCANCEL, IDAPPLY };
HWND hCtrl;
- for (int i = 0; i < _countof(idResize); i++) {
- if (hCtrl = GetDlgItem(hDlg, idResize[i])) {
+ for (auto &it : idResize) {
+ if (hCtrl = GetDlgItem(hDlg, it)) {
GetWindowRect(hCtrl, &rc);
OffsetRect(&rc, -pt.x, -pt.y);
MoveWindow(hCtrl, rc.left, rc.top, rc.right - rc.left + addWidth, rc.bottom - rc.top, FALSE);
}
}
- for (int k = 0; k < _countof(idMove); k++) {
- if (hCtrl = GetDlgItem(hDlg, idMove[k])) {
+ for (auto &it : idMove) {
+ if (hCtrl = GetDlgItem(hDlg, it)) {
GetWindowRect(hCtrl, &rc);
OffsetRect(&rc, -pt.x, -pt.y);
MoveWindow(hCtrl, rc.left + addWidth, rc.top, rc.right - rc.left, rc.bottom - rc.top, FALSE);
diff --git a/plugins/UserInfoEx/src/mir_icolib.cpp b/plugins/UserInfoEx/src/mir_icolib.cpp
index cdb2783326..a197d9d27c 100644
--- a/plugins/UserInfoEx/src/mir_icolib.cpp
+++ b/plugins/UserInfoEx/src/mir_icolib.cpp
@@ -134,10 +134,10 @@ LPTSTR IcoLib_GetDefaultIconFileName()
};
wchar_t absolute[MAX_PATH];
- for (int i = 0; i < _countof(path); i++) {
- PathToAbsoluteW(path[i], absolute);
+ for (auto &it : path) {
+ PathToAbsoluteW(it, absolute);
if (PathFileExists(absolute))
- return path[i];
+ return it;
}
return nullptr;
}
@@ -330,8 +330,6 @@ void IcoLib_LoadModule()
// load default icon if required
ghDefIcon = (HICON)IcoLib_GetIcon(ICO_COMMON_DEFAULT, false);
- for (int i = 0; i < _countof(icoDesc); i++)
- IcoLib_RegisterIconHandleEx(
- icoDesc[i].pszName, icoDesc[i].pszDesc, icoDesc[i].pszSection,
- szDefaultFile, icoDesc[i].idResource, icoDesc[i].size, ghDefIcon);
+ for (auto &it : icoDesc)
+ IcoLib_RegisterIconHandleEx(it.pszName, it.pszDesc, it.pszSection, szDefaultFile, it.idResource, it.size, ghDefIcon);
}
diff --git a/plugins/UserInfoEx/src/psp_options.cpp b/plugins/UserInfoEx/src/psp_options.cpp
index 0bab0f9a8d..f878983d09 100644
--- a/plugins/UserInfoEx/src/psp_options.cpp
+++ b/plugins/UserInfoEx/src/psp_options.cpp
@@ -276,22 +276,22 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam,
switch (((LPNMHDR)lParam)->code) {
case PSN_INFOCHANGED:
bInitialized = 0;
- {
- // menu item settings
- for (int i = 0; i < _countof(ctrl_Menu); i++) {
- int flag = db_get_b(NULL, MODNAME, ctrl_Menu[i].pszKey, 2);
- // check button and enable / disable control
- int idEnable[] = { ctrl_Menu[i].idCheckbox + 1, ctrl_Menu[i].idNONE, ctrl_Menu[i].idALL, ctrl_Menu[i].idEXIMPORT };
- EnableControls(hDlg, idEnable, _countof(idEnable), DBGetCheckBtn(hDlg, ctrl_Menu[i].idCheckbox, ctrl_Menu[i].pszKey, 0));
- // set radio button state
- int id = ctrl_Menu[i].idNONE; //default
- if ((flag & 4) == 4)
- id = ctrl_Menu[i].idALL;
- else if ((flag & 8) == 8)
- id = ctrl_Menu[i].idEXIMPORT;
- CheckRadioButton(hDlg, ctrl_Menu[i].idNONE, ctrl_Menu[i].idEXIMPORT, id);
- }
+
+ // menu item settings
+ for (auto &it : ctrl_Menu) {
+ int flag = db_get_b(NULL, MODNAME, it.pszKey, 2);
+ // check button and enable / disable control
+ int idEnable[] = { it.idCheckbox + 1, it.idNONE, it.idALL, it.idEXIMPORT };
+ EnableControls(hDlg, idEnable, _countof(idEnable), DBGetCheckBtn(hDlg, it.idCheckbox, it.pszKey, 0));
+ // set radio button state
+ int id = it.idNONE; //default
+ if ((flag & 4) == 4)
+ id = it.idALL;
+ else if ((flag & 8) == 8)
+ id = it.idEXIMPORT;
+ CheckRadioButton(hDlg, it.idNONE, it.idEXIMPORT, id);
}
+
// extra icon settings
CheckDlgButton(hDlg, CHECK_OPT_GENDER, g_eiGender ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hDlg, CHECK_OPT_EMAILICON, g_eiEmail ? BST_CHECKED : BST_UNCHECKED);
@@ -308,12 +308,12 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam,
case PSN_APPLY:
// menu item settings
- for (int i = 0; i < _countof(ctrl_Menu); i++) {
- int flag = IsDlgButtonChecked(hDlg, ctrl_Menu[i].idCheckbox);
- flag |= IsDlgButtonChecked(hDlg, ctrl_Menu[i].idNONE) ? 2 : 0;
- flag |= IsDlgButtonChecked(hDlg, ctrl_Menu[i].idALL) ? 4 : 0;
- flag |= IsDlgButtonChecked(hDlg, ctrl_Menu[i].idEXIMPORT) ? 8 : 0;
- db_set_b(NULL, MODNAME, ctrl_Menu[i].pszKey, (BYTE)flag);
+ for (auto &it : ctrl_Menu) {
+ int flag = IsDlgButtonChecked(hDlg, it.idCheckbox);
+ flag |= IsDlgButtonChecked(hDlg, it.idNONE) ? 2 : 0;
+ flag |= IsDlgButtonChecked(hDlg, it.idALL) ? 4 : 0;
+ flag |= IsDlgButtonChecked(hDlg, it.idEXIMPORT) ? 8 : 0;
+ db_set_b(NULL, MODNAME, it.pszKey, (BYTE)flag);
}
RebuildMenu();
@@ -359,9 +359,9 @@ static INT_PTR CALLBACK DlgProc_CommonOpts(HWND hDlg, UINT uMsg, WPARAM wParam,
case CHECK_OPT_MI_GROUP:
case CHECK_OPT_MI_SUBGROUP:
case CHECK_OPT_MI_ACCOUNT:
- for (int i = 0; i < _countof(ctrl_Menu); i++) {
- if (ctrl_Menu[i].idCheckbox == LOWORD(wParam)) {
- const int idMenuItems[] = { ctrl_Menu[i].idCheckbox + 1, ctrl_Menu[i].idNONE, ctrl_Menu[i].idALL, ctrl_Menu[i].idEXIMPORT };
+ for (auto &it : ctrl_Menu) {
+ if (it.idCheckbox == LOWORD(wParam)) {
+ const int idMenuItems[] = { it.idCheckbox + 1, it.idNONE, it.idALL, it.idEXIMPORT };
EnableControls(hDlg, idMenuItems, _countof(idMenuItems), Button_GetCheck((HWND)lParam));
break;
}
diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp
index a48187a13f..0b50dfd8ed 100644
--- a/plugins/UserInfoEx/src/svc_reminder.cpp
+++ b/plugins/UserInfoEx/src/svc_reminder.cpp
@@ -598,11 +598,11 @@ void SvcReminderCheckAll(const ENotify notify)
static int OnCListRebuildIcons(WPARAM, LPARAM)
{
- for (int i = 0; i < _countof(ghCListAnnivIcons); i++)
- ghCListAnnivIcons[i] = INVALID_HANDLE_VALUE;
+ for (auto &it : ghCListAnnivIcons)
+ it = INVALID_HANDLE_VALUE;
- for (int k = 0; k < _countof(ghCListBirthdayIcons); k++)
- ghCListBirthdayIcons[k] = INVALID_HANDLE_VALUE;
+ for (auto &it : ghCListBirthdayIcons)
+ it = INVALID_HANDLE_VALUE;
return 0;
}
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index c9a5785f16..270ae015b8 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -99,9 +99,9 @@ BYTE getContactInfoType(wchar_t* type)
if (type == nullptr || mir_wstrlen(type) == 0)
return 0;
- for (int i = 0; i < _countof(builtinCnfs); i++)
- if (!mir_wstrcmp(builtinCnfs[i].str, type))
- return builtinCnfs[i].cnfCode;
+ for (auto &it : builtinCnfs)
+ if (!mir_wstrcmp(it.str, type))
+ return it.cnfCode;
return 0;
}
diff --git a/plugins/Weather/src/weather_icons.cpp b/plugins/Weather/src/weather_icons.cpp
index e9b4c52174..1840dcde66 100644
--- a/plugins/Weather/src/weather_icons.cpp
+++ b/plugins/Weather/src/weather_icons.cpp
@@ -51,9 +51,9 @@ HICON LoadIconEx(const char* name, bool big)
HANDLE GetIconHandle(const char* name)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (mir_strcmp(iconList[i].szName, name) == 0)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (mir_strcmp(it.szName, name) == 0)
+ return it.hIcolib;
return nullptr;
}
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 6531bf9f32..91466a877f 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -64,9 +64,9 @@ void InitIcons(void)
HANDLE GetIconHandle(const char* name)
{
- for (size_t i = 0; i < _countof(icons); i++)
- if (mir_strcmp(icons[i].szName, name) == 0)
- return icons[i].hIcolib;
+ for (auto &it : icons)
+ if (mir_strcmp(it.szName, name) == 0)
+ return it.hIcolib;
return nullptr;
}
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp
index 0fedca772e..3378b84e5f 100644
--- a/protocols/IRCG/src/options.cpp
+++ b/protocols/IRCG/src/options.cpp
@@ -209,18 +209,18 @@ void InitIcons(void)
HICON LoadIconEx(int iconId, bool big)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return IcoLib_GetIconByHandle(iconList[i].hIcolib, big);
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return IcoLib_GetIconByHandle(it.hIcolib, big);
return nullptr;
}
HANDLE GetIconHandle(int iconId)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
}
@@ -352,8 +352,8 @@ struct CServerDlg : public CProtoDlgBase<CIrcProto>
void OnOk(CCtrlButton*)
{
- for (int k = 0; k < _countof(sttRequiredFields); k++)
- if (!GetWindowTextLength(GetDlgItem(m_hwnd, sttRequiredFields[k]))) {
+ for (auto &it : sttRequiredFields)
+ if (!GetWindowTextLength(GetDlgItem(m_hwnd, it))) {
MessageBox(m_hwnd, TranslateT("Please complete all fields"), TranslateT("IRC error"), MB_OK | MB_ICONERROR);
return;
}
diff --git a/protocols/IcqOscarJ/src/capabilities.cpp b/protocols/IcqOscarJ/src/capabilities.cpp
index 9bc780ea4d..4a35b19ea6 100644
--- a/protocols/IcqOscarJ/src/capabilities.cpp
+++ b/protocols/IcqOscarJ/src/capabilities.cpp
@@ -84,12 +84,12 @@ void NetLog_CapabilityChange(CIcqProto *ppro, const char *szChange, DWORD fdwCap
if (!fdwCapabilities) return;
- for (int nIndex = 0; nIndex < _countof(CapabilityNames); nIndex++) {
+ for (auto &it : CapabilityNames) {
// Check if the current capability is present
- if ((fdwCapabilities & CapabilityNames[nIndex].capID) == CapabilityNames[nIndex].capID) {
+ if ((fdwCapabilities & it.capID) == it.capID) {
if (mir_strlen(szBuffer))
mir_strcat(szBuffer, ", ");
- mir_strcat(szBuffer, CapabilityNames[nIndex].capName);
+ mir_strcat(szBuffer, it.capName);
}
}
// Log the change
diff --git a/protocols/IcqOscarJ/src/dlgproc.cpp b/protocols/IcqOscarJ/src/dlgproc.cpp
index d0ddd84eec..b754a2e5ab 100644
--- a/protocols/IcqOscarJ/src/dlgproc.cpp
+++ b/protocols/IcqOscarJ/src/dlgproc.cpp
@@ -458,7 +458,8 @@ INT_PTR CALLBACK ChangeInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
if (ack->type != ACKTYPE_SETINFO) break;
if (ack->result == ACKRESULT_SUCCESS) {
for (i = 0; i < _countof(dat->hUpload); i++)
- if (dat->hUpload[i] && ack->hProcess == dat->hUpload[i]) break;
+ if (dat->hUpload[i] && ack->hProcess == dat->hUpload[i])
+ break;
if (i == _countof(dat->hUpload)) break;
dat->hUpload[i] = nullptr;
diff --git a/protocols/JabberG/src/jabber_caps.cpp b/protocols/JabberG/src/jabber_caps.cpp
index ae95ee5216..4b99b77219 100755
--- a/protocols/JabberG/src/jabber_caps.cpp
+++ b/protocols/JabberG/src/jabber_caps.cpp
@@ -276,9 +276,9 @@ JabberCapsBits CJabberProto::GetResourceCapabilities(const wchar_t *jid, pResour
wchar_t *token = wcstok(caps, L" ");
while (token) {
- for (int i = 0; i < _countof(g_JabberFeatCapPairsExt); i++) {
- if (!mir_wstrcmp(g_JabberFeatCapPairsExt[i].szFeature, token)) {
- jcbCaps |= g_JabberFeatCapPairsExt[i].jcbCap;
+ for (auto &it : g_JabberFeatCapPairsExt) {
+ if (!mir_wstrcmp(it.szFeature, token)) {
+ jcbCaps |= it.jcbCap;
break;
}
}
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp
index 016a549279..bc0a6b43fb 100644
--- a/protocols/JabberG/src/jabber_chat.cpp
+++ b/protocols/JabberG/src/jabber_chat.cpp
@@ -121,10 +121,10 @@ int CJabberProto::GcInit(JABBER_LIST_ITEM *item)
return 1;
// translate string for menus (this can't be done in initializer)
- for (int i = 0; i < _countof(sttAffiliationItems); i++)
- sttAffiliationItems[i].translate();
- for (int i = 0; i < _countof(sttRoleItems); i++)
- sttRoleItems[i].translate();
+ for (auto &it : sttAffiliationItems)
+ it.translate();
+ for (auto &it : sttRoleItems)
+ it.translate();
ptrW szNick(JabberNickFromJID(item->jid));
GCSessionInfoBase *si = Chat_NewSession(GCW_CHATROOM, m_szModuleName, item->jid, szNick);
@@ -568,16 +568,16 @@ int CJabberProto::JabberGcMenuHook(WPARAM, LPARAM lParam)
for (; idx <= IDM_LINK9; ++idx)
sttFindGcMenuItem(_countof(sttListItems), sttListItems, idx)->uType = 0;
- for (i = 0; i < _countof(sttAffiliationItems); i++) {
- gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, sttAffiliationItems[i].id);
- pItem->uType = (him->m_affiliation == sttAffiliationItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
- pItem->bDisabled = !(force || sttAffiliationItems[i].check(me, him));
+ for (auto &it : sttAffiliationItems) {
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, it.id);
+ pItem->uType = (him->m_affiliation == it.value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
+ pItem->bDisabled = !(force || it.check(me, him));
}
- for (i = 0; i < _countof(sttRoleItems); i++) {
- gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, sttRoleItems[i].id);
- pItem->uType = (him->m_role == sttRoleItems[i].value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
- pItem->bDisabled = !(force || sttRoleItems[i].check(me, him));
+ for (auto &it : sttRoleItems) {
+ gc_item *pItem = sttFindGcMenuItem(_countof(sttListItems), sttListItems, it.id);
+ pItem->uType = (him->m_role == it.value) ? MENU_POPUPCHECK : MENU_POPUPITEM;
+ pItem->bDisabled = !(force || it.check(me, him));
}
if (him->m_tszRealJid && *him->m_tszRealJid) {
@@ -847,21 +847,22 @@ static INT_PTR CALLBACK sttUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
SetDlgItemText(hwndDlg, IDC_TXT_JID, dat->him->m_tszRealJid ? dat->him->m_tszRealJid : TranslateT("Real JID not available"));
SetDlgItemText(hwndDlg, IDC_TXT_STATUS, dat->him->m_tszStatusMessage);
- for (int i = 0; i < _countof(sttRoleItems); i++) {
- if ((sttRoleItems[i].value == dat->him->m_role) || sttRoleItems[i].check(dat->me, dat->him)) {
+ for (auto &it : sttRoleItems) {
+ if ((it.value == dat->him->m_role) || it.check(dat->me, dat->him)) {
SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_SETITEMDATA,
- idx = SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_ADDSTRING, 0, (LPARAM)sttRoleItems[i].title),
- sttRoleItems[i].value);
- if (sttRoleItems[i].value == dat->him->m_role)
+ idx = SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_ADDSTRING, 0, (LPARAM)it.title),
+ it.value);
+ if (it.value == dat->him->m_role)
SendDlgItemMessage(hwndDlg, IDC_TXT_ROLE, CB_SETCURSEL, idx, 0);
}
}
- for (int i = 0; i < _countof(sttAffiliationItems); i++) {
- if ((sttAffiliationItems[i].value == dat->him->m_affiliation) || sttAffiliationItems[i].check(dat->me, dat->him)) {
+
+ for (auto &it : sttAffiliationItems) {
+ if ((it.value == dat->him->m_affiliation) || it.check(dat->me, dat->him)) {
SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_SETITEMDATA,
- idx = SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_ADDSTRING, 0, (LPARAM)sttAffiliationItems[i].title),
- sttAffiliationItems[i].value);
- if (sttAffiliationItems[i].value == dat->him->m_affiliation)
+ idx = SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_ADDSTRING, 0, (LPARAM)it.title),
+ it.value);
+ if (it.value == dat->him->m_affiliation)
SendDlgItemMessage(hwndDlg, IDC_TXT_AFFILIATION, CB_SETCURSEL, idx, 0);
}
}
diff --git a/protocols/JabberG/src/jabber_console.cpp b/protocols/JabberG/src/jabber_console.cpp
index 6dcd528ddd..32ba0492f0 100644
--- a/protocols/JabberG/src/jabber_console.cpp
+++ b/protocols/JabberG/src/jabber_console.cpp
@@ -370,18 +370,20 @@ void CJabberDlgConsole::OnInitDialog()
{ IDC_BTN_FILTER_REFRESH, "Refresh list", "sd_nav_refresh", false, FALSE},
};
- for (int i=0; i < _countof(buttons); i++) {
- SendDlgItemMessage(m_hwnd, buttons[i].idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(buttons[i].icon));
- SendDlgItemMessage(m_hwnd, buttons[i].idc, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(m_hwnd, buttons[i].idc, BUTTONADDTOOLTIP, (WPARAM)buttons[i].title, 0);
- if (buttons[i].push) SendDlgItemMessage(m_hwnd, buttons[i].idc, BUTTONSETASPUSHBTN, TRUE, 0);
- if (buttons[i].pushed) CheckDlgButton(m_hwnd, buttons[i].idc, BST_CHECKED);
+ for (auto &it : buttons) {
+ SendDlgItemMessage(m_hwnd, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0);
+ if (it.push)
+ SendDlgItemMessage(m_hwnd, it.idc, BUTTONSETASPUSHBTN, TRUE, 0);
+ if (it.pushed)
+ CheckDlgButton(m_hwnd, it.idc, BST_CHECKED);
}
- for (int i=0; i < _countof(filter_modes); i++)
- if (filter_modes[i].type == m_proto->m_filterInfo.type) {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
- SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon));
+ for (auto &it : filter_modes)
+ if (it.type == m_proto->m_filterInfo.type) {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
+ SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon));
break;
}
@@ -563,12 +565,9 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
break;
case IDC_BTN_FILTER:
- int i;
HMENU hMenu = CreatePopupMenu();
- for (i = 0; i < _countof(filter_modes); i++)
- AppendMenu(hMenu,
- MF_STRING | ((filter_modes[i].type == m_proto->m_filterInfo.type) ? MF_CHECKED : 0),
- filter_modes[i].type + 1, TranslateW(filter_modes[i].title));
+ for (auto &it : filter_modes)
+ AppendMenu(hMenu, MF_STRING | ((it.type == m_proto->m_filterInfo.type) ? MF_CHECKED : 0), it.type + 1, TranslateW(it.title));
RECT rc; GetWindowRect(GetDlgItem(m_hwnd, IDC_BTN_FILTER), &rc);
CheckDlgButton(m_hwnd, IDC_BTN_FILTER, BST_CHECKED);
@@ -578,9 +577,9 @@ INT_PTR CJabberDlgConsole::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam)
if (res) {
m_proto->m_filterInfo.type = (TFilterInfo::Type)(res - 1);
- for (i = 0; i < _countof(filter_modes); i++) {
- if (filter_modes[i].type == m_proto->m_filterInfo.type) {
- IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(filter_modes[i].icon)));
+ for (auto &it : filter_modes) {
+ if (it.type == m_proto->m_filterInfo.type) {
+ IcoLib_ReleaseIcon((HICON)SendDlgItemMessage(m_hwnd, IDC_BTN_FILTER, BM_SETIMAGE, IMAGE_ICON, (LPARAM)m_proto->LoadIconEx(it.icon)));
break;
}
}
diff --git a/protocols/JabberG/src/jabber_disco.cpp b/protocols/JabberG/src/jabber_disco.cpp
index 3d22509c35..04dae8fcf2 100644
--- a/protocols/JabberG/src/jabber_disco.cpp
+++ b/protocols/JabberG/src/jabber_disco.cpp
@@ -512,25 +512,26 @@ void CJabberProto::ApplyNodeIcon(HTREELISTITEM hItem, CJabberSDNode *pNode)
iOverlay = SD_OVERLAY_NONE;
}
- for (int i = 0; i < _countof(sttNodeIcons); i++) {
- if (!sttNodeIcons[i].iconIndex && !sttNodeIcons[i].iconName) continue;
+ for (auto &it : sttNodeIcons) {
+ if (!it.iconIndex && !it.iconName)
+ continue;
- if (sttNodeIcons[i].category) {
+ if (it.category) {
CJabberSDIdentity *iIdentity;
for (iIdentity = pNode->GetFirstIdentity(); iIdentity; iIdentity = iIdentity->GetNext())
- if (!mir_wstrcmp(iIdentity->GetCategory(), sttNodeIcons[i].category) &&
- (!sttNodeIcons[i].type || !mir_wstrcmp(iIdentity->GetType(), sttNodeIcons[i].type))) {
- iIcon = sttNodeIcons[i].listIndex;
+ if (!mir_wstrcmp(iIdentity->GetCategory(), it.category) &&
+ (!it.type || !mir_wstrcmp(iIdentity->GetType(), it.type))) {
+ iIcon = it.listIndex;
break;
}
if (iIdentity) break;
}
- if (sttNodeIcons[i].feature) {
+ if (it.feature) {
CJabberSDFeature *iFeature;
for (iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!mir_wstrcmp(iFeature->GetVar(), sttNodeIcons[i].feature)) {
- iIcon = sttNodeIcons[i].listIndex;
+ if (!mir_wstrcmp(iFeature->GetVar(), it.feature)) {
+ iIcon = it.listIndex;
break;
}
if (iFeature) break;
@@ -677,19 +678,19 @@ void CJabberDlgDiscovery::OnInitDialog()
TreeList_Create(hwndList);
TreeList_AddIcon(hwndList, m_proto->LoadIconEx("main"), 0);
- for (int i = 0; i < _countof(sttNodeIcons); i++) {
+ for (auto &it : sttNodeIcons) {
bool needDestroy = false;
HICON hIcon;
- if ((sttNodeIcons[i].iconIndex == SKINICON_STATUS_ONLINE) && sttNodeIcons[i].iconName) {
- hIcon = (HICON)CallProtoService(sttNodeIcons[i].iconName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
+ if ((it.iconIndex == SKINICON_STATUS_ONLINE) && it.iconName) {
+ hIcon = (HICON)CallProtoService(it.iconName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
needDestroy = true;
}
- else if (sttNodeIcons[i].iconName)
- hIcon = m_proto->LoadIconEx(sttNodeIcons[i].iconName);
- else if (sttNodeIcons[i].iconIndex)
- hIcon = Skin_LoadIcon(sttNodeIcons[i].iconIndex);
+ else if (it.iconName)
+ hIcon = m_proto->LoadIconEx(it.iconName);
+ else if (it.iconIndex)
+ hIcon = Skin_LoadIcon(it.iconIndex);
else continue;
- sttNodeIcons[i].listIndex = TreeList_AddIcon(hwndList, hIcon, 0);
+ it.listIndex = TreeList_AddIcon(hwndList, hIcon, 0);
if (needDestroy) DestroyIcon(hIcon);
}
TreeList_AddIcon(hwndList, m_proto->LoadIconEx("disco_fail"), SD_OVERLAY_FAIL);
@@ -1207,37 +1208,37 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
HMENU hMenu = CreatePopupMenu();
BOOL lastSeparator = TRUE;
bool bFilterItems = !GetAsyncKeyState(VK_CONTROL);
- for (int i = 0; i < _countof(items); i++) {
+ for (auto &it : items) {
JABBER_LIST_ITEM *rosterItem = nullptr;
if (bFilterItems) {
- if ((items[i].flags & SD_FLG_NONODE) && pNode->GetNode())
+ if ((it.flags & SD_FLG_NONODE) && pNode->GetNode())
continue;
- if ((items[i].flags & SD_FLG_NOTONROSTER) && (rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
+ if ((it.flags & SD_FLG_NOTONROSTER) && (rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
continue;
- if ((items[i].flags & SD_FLG_ONROSTER) && !(rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
+ if ((it.flags & SD_FLG_ONROSTER) && !(rosterItem = ListGetItemPtr(LIST_ROSTER, pNode->GetJid())))
continue;
- if ((items[i].flags & SD_FLG_SUBSCRIBED) && (!rosterItem || (rosterItem->subscription == SUB_NONE)))
+ if ((it.flags & SD_FLG_SUBSCRIBED) && (!rosterItem || (rosterItem->subscription == SUB_NONE)))
continue;
- if ((items[i].flags & SD_FLG_NOTSUBSCRIBED) && (rosterItem && (rosterItem->subscription != SUB_NONE)))
+ if ((it.flags & SD_FLG_NOTSUBSCRIBED) && (rosterItem && (rosterItem->subscription != SUB_NONE)))
continue;
- if ((items[i].flags & SD_FLG_ONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus != ID_STATUS_OFFLINE))
+ if ((it.flags & SD_FLG_ONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus != ID_STATUS_OFFLINE))
continue;
- if ((items[i].flags & SD_FLG_NOTONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus == ID_STATUS_OFFLINE))
+ if ((it.flags & SD_FLG_NOTONLINE) && rosterItem && (rosterItem->getTemp()->m_iStatus == ID_STATUS_OFFLINE))
continue;
- if ((items[i].flags & SD_FLG_NORESOURCE) && wcschr(pNode->GetJid(), '/'))
+ if ((it.flags & SD_FLG_NORESOURCE) && wcschr(pNode->GetJid(), '/'))
continue;
- if ((items[i].flags & SD_FLG_HASUSER) && !wcschr(pNode->GetJid(), '@'))
+ if ((it.flags & SD_FLG_HASUSER) && !wcschr(pNode->GetJid(), '@'))
continue;
}
- if (!items[i].feature) {
- if (items[i].title) {
+ if (!it.feature) {
+ if (it.title) {
MCONTACT hContact;
- if ((items[i].action == SD_ACT_USERMENU) && (hContact = HContactFromJID(pNode->GetJid()))) {
+ if ((it.action == SD_ACT_USERMENU) && (hContact = HContactFromJID(pNode->GetJid()))) {
HMENU hContactMenu = Menu_BuildContactMenu(hContact);
- AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hContactMenu, TranslateW(items[i].title));
+ AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT_PTR)hContactMenu, TranslateW(it.title));
}
- else AppendMenu(hMenu, MF_STRING, items[i].action, TranslateW(items[i].title));
+ else AppendMenu(hMenu, MF_STRING, it.action, TranslateW(it.title));
lastSeparator = FALSE;
}
else if (!lastSeparator) {
@@ -1250,14 +1251,14 @@ void CJabberProto::ServiceDiscoveryShowMenu(CJabberSDNode *pNode, HTREELISTITEM
bool bFeatureOk = !bFilterItems;
if (bFilterItems)
for (CJabberSDFeature *iFeature = pNode->GetFirstFeature(); iFeature; iFeature = iFeature->GetNext())
- if (!mir_wstrcmp(iFeature->GetVar(), items[i].feature)) {
+ if (!mir_wstrcmp(iFeature->GetVar(), it.feature)) {
bFeatureOk = true;
break;
}
if (bFeatureOk) {
- if (items[i].title) {
- AppendMenu(hMenu, MF_STRING, items[i].action, TranslateW(items[i].title));
+ if (it.title) {
+ AppendMenu(hMenu, MF_STRING, it.action, TranslateW(it.title));
lastSeparator = FALSE;
}
else if (!lastSeparator) {
diff --git a/protocols/JabberG/src/jabber_groupchat.cpp b/protocols/JabberG/src/jabber_groupchat.cpp
index 378716e219..c93f8397e0 100644
--- a/protocols/JabberG/src/jabber_groupchat.cpp
+++ b/protocols/JabberG/src/jabber_groupchat.cpp
@@ -369,10 +369,10 @@ static void sttJoinDlgShowRecentItems(HWND hwndDlg, int newCount)
RECT rc;
int ctrls[] = { IDC_BOOKMARKS, IDOK, IDCANCEL };
- for (int i = 0; i < _countof(ctrls); i++) {
- GetWindowRect(GetDlgItem(hwndDlg, ctrls[i]), &rc);
+ for (auto &it : ctrls) {
+ GetWindowRect(GetDlgItem(hwndDlg, it), &rc);
MapWindowPoints(nullptr, hwndDlg, (LPPOINT)&rc, 2);
- SetWindowPos(GetDlgItem(hwndDlg, ctrls[i]), nullptr, rc.left, rc.top + offset, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
+ SetWindowPos(GetDlgItem(hwndDlg, it), nullptr, rc.left, rc.top + offset, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
}
GetWindowRect(hwndDlg, &rc);
diff --git a/protocols/JabberG/src/jabber_icolib.cpp b/protocols/JabberG/src/jabber_icolib.cpp
index af4f030dd3..5eb0a99b24 100644
--- a/protocols/JabberG/src/jabber_icolib.cpp
+++ b/protocols/JabberG/src/jabber_icolib.cpp
@@ -423,8 +423,8 @@ BOOL CJabberProto::DBCheckIsTransportedContact(const wchar_t *jid, MCONTACT hCon
if (resourcepos != nullptr)
*resourcepos = '\0';
- for (int i = 0; i < _countof(TransportProtoTable); i++)
- if (MatchMask(domain, TransportProtoTable[i].mask)) {
+ for (auto &it : TransportProtoTable)
+ if (MatchMask(domain, it.mask)) {
GetTransportStatusIconIndex(GetTransportProtoID(domain), ID_STATUS_OFFLINE);
isTransported = TRUE;
break;
@@ -530,23 +530,21 @@ void g_IconsInit()
HANDLE g_GetIconHandle(int iconId)
{
- int i;
-
- for (i = 0; i < _countof(sharedIconList1); i++)
- if (sharedIconList1[i].defIconID == iconId)
- return sharedIconList1[i].hIcolib;
+ for (auto &it : sharedIconList1)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
- for (i = 0; i < _countof(sharedIconList2); i++)
- if (sharedIconList2[i].defIconID == iconId)
- return sharedIconList2[i].hIcolib;
+ for (auto &it : sharedIconList2)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
- for (i = 0; i < _countof(sharedIconList3); i++)
- if (sharedIconList3[i].defIconID == iconId)
- return sharedIconList3[i].hIcolib;
+ for (auto &it : sharedIconList3)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
- for (i = 0; i < _countof(sharedIconList4); i++)
- if (sharedIconList4[i].defIconID == iconId)
- return sharedIconList4[i].hIcolib;
+ for (auto &it : sharedIconList4)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
}
diff --git a/protocols/JabberG/src/jabber_iqid_muc.cpp b/protocols/JabberG/src/jabber_iqid_muc.cpp
index 576589110f..7610621e28 100644
--- a/protocols/JabberG/src/jabber_iqid_muc.cpp
+++ b/protocols/JabberG/src/jabber_iqid_muc.cpp
@@ -199,12 +199,12 @@ static INT_PTR CALLBACK JabberMucJidListDlgProc(HWND hwndDlg, UINT msg, WPARAM w
SendMessage(hwndDlg, WM_JABBER_REFRESH, 0, lParam);
dat = (JABBER_MUC_JIDLIST_INFO*)lParam;
- for (int i = 0; i < _countof(buttons); i++) {
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)dat->ppro->LoadIconEx(buttons[i].icon));
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONADDTOOLTIP, (WPARAM)buttons[i].title, 0);
- if (buttons[i].push)
- SendDlgItemMessage(hwndDlg, buttons[i].idc, BUTTONSETASPUSHBTN, TRUE, 0);
+ for (auto &it : buttons) {
+ SendDlgItemMessage(hwndDlg, it.idc, BM_SETIMAGE, IMAGE_ICON, (LPARAM)dat->ppro->LoadIconEx(it.icon));
+ SendDlgItemMessage(hwndDlg, it.idc, BUTTONSETASFLATBTN, TRUE, 0);
+ SendDlgItemMessage(hwndDlg, it.idc, BUTTONADDTOOLTIP, (WPARAM)it.title, 0);
+ if (it.push)
+ SendDlgItemMessage(hwndDlg, it.idc, BUTTONSETASPUSHBTN, TRUE, 0);
}
Utils_RestoreWindowPosition(hwndDlg, 0, dat->ppro->m_szModuleName, "jidListWnd_");
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index b90a09bc53..7c1c4a0b5b 100755
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -262,9 +262,9 @@ static sttCapsNodeToName_Map[] =
const wchar_t* CJabberProto::GetSoftName(const wchar_t *wszName)
{
// search through known software list
- for (int i = 0; i < _countof(sttCapsNodeToName_Map); i++)
- if (wcsstr(wszName, sttCapsNodeToName_Map[i].node))
- return sttCapsNodeToName_Map[i].name;
+ for (auto &it : sttCapsNodeToName_Map)
+ if (wcsstr(wszName, it.node))
+ return it.name;
return nullptr;
}
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index 6387b0ab1c..5b751fc96f 100755
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -435,8 +435,8 @@ protected:
// fill predefined resources
wchar_t *szResources[] = { L"Home", L"Work", L"Office", L"Miranda" };
- for (int i = 0; i < _countof(szResources); i++)
- m_cbResource.AddString(szResources[i]);
+ for (auto &it : szResources)
+ m_cbResource.AddString(it);
// append computer name to the resource list
wchar_t szCompName[MAX_COMPUTERNAME_LENGTH + 1];
@@ -1585,8 +1585,8 @@ protected:
// fill predefined resources
wchar_t *szResources[] = { L"Home", L"Work", L"Office", L"Miranda" };
- for (int i = 0; i < _countof(szResources); i++)
- m_cbResource.AddString(szResources[i]);
+ for (auto &it : szResources)
+ m_cbResource.AddString(it);
// append computer name to the resource list
wchar_t szCompName[MAX_COMPUTERNAME_LENGTH + 1];
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index 6ae2f75dc1..f189e90b17 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -378,9 +378,9 @@ public:
SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_RESETCONTENT, 0, 0);
wchar_t *szSubscriptions[] = { L"none", L"from", L"to", L"both" };
- for (i=0; i < _countof(szSubscriptions); i++) {
- LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_ADDSTRING, 0, (LPARAM)TranslateW(szSubscriptions[i]));
- SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETITEMDATA, nItem, (LPARAM)szSubscriptions[i]);
+ for (auto &it : szSubscriptions) {
+ LRESULT nItem = SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
+ SendDlgItemMessage(m_hwnd, IDC_COMBO_VALUE, CB_SETITEMDATA, nItem, (LPARAM)it);
}
PostMessage(m_hwnd, WM_COMMAND, MAKEWPARAM(IDC_COMBO_TYPE, CBN_SELCHANGE), 0);
@@ -945,11 +945,11 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
else if (lpdis->CtlID == IDC_LB_LISTS)
DrawLists(lpdis);
else if (lpdis->CtlID == IDC_CANVAS) {
- int i, totalWidth = -5; // spacing for last item
- for (i=0; i < _countof(drawItems); i++) {
+ int totalWidth = -5; // spacing for last item
+ for (auto &it : drawItems) {
SIZE sz = {0};
- drawItems[i].text = TranslateW(drawItems[i].textEng);
- GetTextExtentPoint32(lpdis->hDC, drawItems[i].text, (int)mir_wstrlen(drawItems[i].text), &sz);
+ it.text = TranslateW(it.textEng);
+ GetTextExtentPoint32(lpdis->hDC, it.text, (int)mir_wstrlen(it.text), &sz);
totalWidth += sz.cx + 18 + 5; // 18 pixels for icon, 5 pixel spacing
}
@@ -957,11 +957,11 @@ BOOL CJabberDlgPrivacyLists::OnWmDrawItem(UINT, WPARAM, LPARAM lParam)
RECT rc = lpdis->rcItem;
rc.left = (rc.left + rc.right - totalWidth)/2;
- for (i=0; i < _countof(drawItems); i++) {
- DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(drawItems[i].icon),
+ for (auto &it : drawItems) {
+ DrawIconEx(lpdis->hDC, rc.left, (rc.top+rc.bottom-16)/2, m_proto->LoadIconEx(it.icon),
16, 16, 0, nullptr, DI_NORMAL);
rc.left += 18;
- DrawNextRulePart(lpdis->hDC, clText, drawItems[i].text, &rc);
+ DrawNextRulePart(lpdis->hDC, clText, it.text, &rc);
rc.left += 5;
}
}
diff --git a/protocols/MRA/src/MraChat.cpp b/protocols/MRA/src/MraChat.cpp
index 237e486312..9d80158bb0 100644
--- a/protocols/MRA/src/MraChat.cpp
+++ b/protocols/MRA/src/MraChat.cpp
@@ -31,8 +31,8 @@ INT_PTR CMraProto::MraChatSessionNew(MCONTACT hContact)
if (Chat_NewSession(GCW_CHATROOM, m_szModuleName, wszEMail, pcli->pfnGetContactDisplayName(hContact, 0), (void*)hContact))
return 1;
- for (int i = 0; i < _countof(lpwszStatuses); i++)
- Chat_AddGroup(m_szModuleName, wszEMail, TranslateW(lpwszStatuses[i]));
+ for (auto &it : lpwszStatuses)
+ Chat_AddGroup(m_szModuleName, wszEMail, TranslateW(it));
Chat_Control(m_szModuleName, wszEMail, SESSION_INITDONE);
Chat_Control(m_szModuleName, wszEMail, SESSION_ONLINE);
diff --git a/protocols/MSN/src/msn_chat.cpp b/protocols/MSN/src/msn_chat.cpp
index 9021cfbbd7..e8f8b87265 100644
--- a/protocols/MSN/src/msn_chat.cpp
+++ b/protocols/MSN/src/msn_chat.cpp
@@ -60,8 +60,8 @@ int CMsnProto::MSN_ChatInit(GCThreadData *info, const char *pszID, const char *p
m_tszUserName, TranslateT("Chat #"), m_chatID);
Chat_NewSession(GCW_CHATROOM, m_szModuleName, info->mChatID, szName);
- for (int j = 0; j < _countof(m_ptszRoles); j++)
- Chat_AddGroup(m_szModuleName, info->mChatID, TranslateW(m_ptszRoles[j]));
+ for (auto &it : m_ptszRoles)
+ Chat_AddGroup(m_szModuleName, info->mChatID, TranslateW(it));
Chat_Control(m_szModuleName, info->mChatID, SESSION_INITDONE);
Chat_Control(m_szModuleName, info->mChatID, SESSION_ONLINE);
diff --git a/protocols/MSN/src/msn_menu.cpp b/protocols/MSN/src/msn_menu.cpp
index 18b2bc5231..9112c3fec0 100644
--- a/protocols/MSN/src/msn_menu.cpp
+++ b/protocols/MSN/src/msn_menu.cpp
@@ -177,8 +177,8 @@ void CMsnProto::MsnInitMainMenu(void)
void CMsnProto::MSN_EnableMenuItems(bool bEnable)
{
- for (int i = 0; i < _countof(menuItemsMain); i++)
- Menu_ModifyItem(menuItemsMain[i], nullptr, INVALID_HANDLE_VALUE, bEnable ? 0 : CMIF_GRAYED);
+ for (auto &it : menuItemsMain)
+ Menu_ModifyItem(it, nullptr, INVALID_HANDLE_VALUE, bEnable ? 0 : CMIF_GRAYED);
if (bEnable)
Menu_ShowItem(menuItemsMain[1], emailEnabled);
diff --git a/protocols/MSN/src/msn_mime.cpp b/protocols/MSN/src/msn_mime.cpp
index 8fb9e6149a..0eabb6c3e7 100644
--- a/protocols/MSN/src/msn_mime.cpp
+++ b/protocols/MSN/src/msn_mime.cpp
@@ -339,9 +339,9 @@ static const struct _tag_cpltbl
static unsigned FindCP(const char* mimecp)
{
unsigned cp = CP_ACP;
- for (unsigned i = 0; i < _countof(cptbl); ++i) {
- if (_stricmp(mimecp, cptbl[i].mimecp) == 0) {
- cp = cptbl[i].cp;
+ for (auto &it : cptbl) {
+ if (_stricmp(mimecp, it.mimecp) == 0) {
+ cp = it.cp;
break;
}
}
diff --git a/protocols/MSN/src/msn_opts.cpp b/protocols/MSN/src/msn_opts.cpp
index ac1a002b6c..8549350c1d 100644
--- a/protocols/MSN/src/msn_opts.cpp
+++ b/protocols/MSN/src/msn_opts.cpp
@@ -59,9 +59,9 @@ HICON LoadIconEx(const char* name, bool big)
HANDLE GetIconHandle(int iconId)
{
- for (unsigned i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iconId)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
}
diff --git a/protocols/SkypeWeb/src/skype_db.cpp b/protocols/SkypeWeb/src/skype_db.cpp
index 62210653cc..95cba6049c 100644
--- a/protocols/SkypeWeb/src/skype_db.cpp
+++ b/protocols/SkypeWeb/src/skype_db.cpp
@@ -150,9 +150,7 @@ void CSkypeProto::InitDBEvents()
dbEventType.iconService = MODULE "/GetEventIcon";
dbEventType.textService = MODULE "/GetEventText";
- for (size_t i = 0; i < _countof(g_SkypeDBTypes); i++) {
- SkypeDBType &cur = g_SkypeDBTypes[i];
-
+ for (auto &cur : g_SkypeDBTypes) {
dbEventType.eventType = cur.type;
dbEventType.descr = Translate(cur.name);
dbEventType.flags |= cur.flags;
diff --git a/protocols/SkypeWeb/src/skype_icons.cpp b/protocols/SkypeWeb/src/skype_icons.cpp
index 13427fa894..412d0c0043 100644
--- a/protocols/SkypeWeb/src/skype_icons.cpp
+++ b/protocols/SkypeWeb/src/skype_icons.cpp
@@ -37,16 +37,16 @@ void CSkypeProto::InitIcons()
HICON CSkypeProto::GetIcon(int iconId)
{
- for (size_t i = 0; i < _countof(Icons); i++)
- if (Icons[i].defIconID == iconId)
- return IcoLib_GetIconByHandle(Icons[i].hIcolib);
+ for (auto &it : Icons)
+ if (it.defIconID == iconId)
+ return IcoLib_GetIconByHandle(it.hIcolib);
return nullptr;
}
HANDLE CSkypeProto::GetIconHandle(int iconId)
{
- for (size_t i = 0; i < _countof(Icons); i++)
- if (Icons[i].defIconID == iconId)
- return Icons[i].hIcolib;
+ for (auto &it : Icons)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
} \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp
index 305b35ab1d..bcf3f98315 100644
--- a/protocols/SkypeWeb/src/skype_menus.cpp
+++ b/protocols/SkypeWeb/src/skype_menus.cpp
@@ -45,8 +45,8 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
int CSkypeProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
{
- for (int i = 0; i < _countof(ContactMenuItems); i++)
- Menu_ShowItem(ContactMenuItems[i], false);
+ for (auto &it : ContactMenuItems)
+ Menu_ShowItem(it, false);
CSkypeProto *proto = CSkypeProto::GetContactAccount(hContact);
return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
}
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index fdb3a97b3c..cd85c2db04 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -405,9 +405,9 @@ char *CSkypeProto::RemoveHtml(const char *text)
}
else {
// Keyword replacement
- for (int j = 0; j < _countof(htmlEntities); j++) {
- if (!mir_strcmpi(entity.c_str(), htmlEntities[j].entity)) {
- new_string += htmlEntities[j].symbol;
+ for (auto &it : htmlEntities) {
+ if (!mir_strcmpi(entity.c_str(), it.entity)) {
+ new_string += it.symbol;
found = true;
break;
}
diff --git a/protocols/Tox/src/tox_icons.cpp b/protocols/Tox/src/tox_icons.cpp
index 5e95d49c24..a94405982e 100644
--- a/protocols/Tox/src/tox_icons.cpp
+++ b/protocols/Tox/src/tox_icons.cpp
@@ -14,16 +14,16 @@ void CToxProto::InitIcons()
HANDLE CToxProto::GetIconHandle(int iconId)
{
- for (size_t i = 0; i < _countof(Icons); i++)
- if (Icons[i].defIconID == iconId)
- return Icons[i].hIcolib;
+ for (auto &it : Icons)
+ if (it.defIconID == iconId)
+ return it.hIcolib;
return nullptr;
}
HICON CToxProto::GetIcon(int iconId)
{
- for (size_t i = 0; i < _countof(Icons); i++)
- if (Icons[i].defIconID == iconId)
- return IcoLib_GetIconByHandle(Icons[i].hIcolib);
+ for (auto &it : Icons)
+ if (it.defIconID == iconId)
+ return IcoLib_GetIconByHandle(it.hIcolib);
return nullptr;
}
diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp
index 88d7129713..5694689e1a 100644
--- a/protocols/Tox/src/tox_menus.cpp
+++ b/protocols/Tox/src/tox_menus.cpp
@@ -26,8 +26,8 @@ int CToxProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM)
int CToxProto::PrebuildContactMenu(WPARAM hContact, LPARAM lParam)
{
- for (int i = 0; i < _countof(ContactMenuItems); i++)
- Menu_ShowItem(ContactMenuItems[i], FALSE);
+ for (auto &it : ContactMenuItems)
+ Menu_ShowItem(it, FALSE);
CToxProto *proto = CToxProto::GetContactAccount(hContact);
return proto ? proto->OnPrebuildContactMenu(hContact, lParam) : 0;
}
diff --git a/protocols/Twitter/src/theme.cpp b/protocols/Twitter/src/theme.cpp
index 2e22f7398e..c7e7c69f55 100644
--- a/protocols/Twitter/src/theme.cpp
+++ b/protocols/Twitter/src/theme.cpp
@@ -46,9 +46,9 @@ void InitIcons(void)
HANDLE GetIconHandle(const char *name)
{
- for (size_t i = 0; i < _countof(icons); i++)
- if (mir_strcmp(icons[i].szName, name) == 0)
- return icons[i].hIcolib;
+ for (auto &it : icons)
+ if (mir_strcmp(it.szName, name) == 0)
+ return it.hIcolib;
return nullptr;
}
@@ -111,6 +111,6 @@ void InitContactMenus()
void ShowContactMenus(bool show)
{
- for (size_t i = 0; i < _countof(g_hMenuItems); i++)
- Menu_ShowItem(g_hMenuItems[i], show);
+ for (auto &it : g_hMenuItems)
+ Menu_ShowItem(it, show);
}
diff --git a/protocols/Twitter/src/ui.cpp b/protocols/Twitter/src/ui.cpp
index a94395829a..d7164be99e 100644
--- a/protocols/Twitter/src/ui.cpp
+++ b/protocols/Twitter/src/ui.cpp
@@ -50,8 +50,8 @@ INT_PTR CALLBACK first_run_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
db_free(&dbv);
}
- for (size_t i = 0; i < _countof(sites); i++)
- SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(sites[i]));
+ for (auto &it : sites)
+ SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(it));
if (!proto->getString(TWITTER_KEY_BASEURL, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_SERVER, dbv.pszVal);
@@ -180,8 +180,8 @@ INT_PTR CALLBACK options_proc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
CheckDlgButton(hwndDlg, IDC_CHATFEED, proto->getByte(TWITTER_KEY_CHATFEED) ? BST_CHECKED : BST_UNCHECKED);
- for (size_t i = 0; i < _countof(sites); i++)
- SendDlgItemMessage(hwndDlg, IDC_BASEURL, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(sites[i]));
+ for (auto &it : sites)
+ SendDlgItemMessage(hwndDlg, IDC_BASEURL, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(it));
if (!proto->getString(TWITTER_KEY_BASEURL, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_BASEURL, dbv.pszVal);
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 1169de5b01..95510c591d 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -84,9 +84,9 @@ void InitIcons()
HANDLE GetIconHandle(int iCommand)
{
- for (int i = 0; i < _countof(iconList); i++)
- if (iconList[i].defIconID == iCommand)
- return iconList[i].hIcolib;
+ for (auto &it : iconList)
+ if (it.defIconID == iCommand)
+ return it.hIcolib;
return nullptr;
}
@@ -847,10 +847,10 @@ CMStringA CVkProto::GetAttachmentsFromMessage(const char *Msg)
iOwner = 0,
iId = 0;
- for (int i = 0; i < _countof(szAttachmentMasks); i++) {
- iRes = sscanf(pos, szAttachmentMasks[i], &iOwner, &iId);
+ for (auto &it : szAttachmentMasks) {
+ iRes = sscanf(pos, it, &iOwner, &iId);
if (iRes == 2) {
- CMStringA szAttachment(FORMAT, szAttachmentMasks[i], iOwner, iId);
+ CMStringA szAttachment(FORMAT, it, iOwner, iId);
CMStringA szAttachment2;
if (nextpos)
@@ -934,11 +934,11 @@ CMStringW CVkProto::SpanVKNotificationType(CMStringW& wszType, VKObjType& vkFeed
CMStringW wszRes;
vkFeedback = vkParent = vkNull;
- for (int i = 0; i < _countof(vkNotification); i++)
- if (wszType == vkNotification[i].pwszType) {
- vkFeedback = vkNotification[i].vkFeedback;
- vkParent = vkNotification[i].vkParent;
- wszRes = vkNotification[i].pwszTranslate;
+ for (auto &it : vkNotification)
+ if (wszType == it.pwszType) {
+ vkFeedback = it.vkFeedback;
+ vkParent = it.vkParent;
+ wszRes = it.pwszTranslate;
break;
}
return wszRes;
@@ -952,8 +952,8 @@ CMStringW CVkProto::GetVkPhotoItem(const JSONNode &jnPhoto, BBCSupport iBBC)
return wszRes;
CMStringW wszLink, wszPreviewLink;
- for (int i = 0; i < _countof(szImageTypes); i++) {
- const JSONNode &n = jnPhoto[szImageTypes[i]];
+ for (auto &it : szImageTypes) {
+ const JSONNode &n = jnPhoto[it];
if (n) {
wszLink = n.as_mstring();
break;
@@ -1022,9 +1022,9 @@ CMStringW CVkProto::SetBBCString(LPCWSTR pwszString, BBCSupport iBBC, VKBBCType
return CMStringW();
wchar_t *pwszFormat = nullptr;
- for (int i = 0; i < _countof(bbcItem); i++)
- if (bbcItem[i].vkBBCType == bbcType && bbcItem[i].vkBBCSettings == iBBC) {
- pwszFormat = bbcItem[i].pwszTempate;
+ for (auto &it : bbcItem)
+ if (it.vkBBCType == bbcType && it.vkBBCSettings == iBBC) {
+ pwszFormat = it.pwszTempate;
break;
}
@@ -1178,8 +1178,8 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
}
else {
CMStringW wszLink;
- for (int i = 0; i < _countof(szImageTypes); i++) {
- const JSONNode &n = jnSticker[szImageTypes[i]];
+ for (auto &it : szImageTypes) {
+ const JSONNode &n = jnSticker[it];
if (n) {
wszLink = n.as_mstring();
break;
@@ -1251,8 +1251,8 @@ CMStringW CVkProto::GetAttachmentDescr(const JSONNode &jnAttachments, BBCSupport
continue;
CMStringW wszLink;
- for (int i = 0; i < _countof(szGiftTypes); i++) {
- const JSONNode &n = jnGift[szGiftTypes[i]];
+ for (auto &it : szGiftTypes) {
+ const JSONNode &n = jnGift[it];
if (n) {
wszLink = n.as_mstring();
break;
@@ -1397,9 +1397,9 @@ CMStringW CVkProto::RemoveBBC(CMStringW& wszSrc)
CMStringW wszLow(wszSrc);
wszLow.MakeLower();
- for (int i = 0; i < _countof(wszSimpleBBCodes); i++) {
- CMStringW wszOpenTag(wszSimpleBBCodes[i][0]);
- CMStringW wszCloseTag(wszSimpleBBCodes[i][1]);
+ for (auto &it : wszSimpleBBCodes) {
+ CMStringW wszOpenTag(it[0]);
+ CMStringW wszCloseTag(it[1]);
int lenOpen = wszOpenTag.GetLength();
int lenClose = wszCloseTag.GetLength();
@@ -1423,9 +1423,9 @@ CMStringW CVkProto::RemoveBBC(CMStringW& wszSrc)
}
}
- for (int i = 0; i < _countof(wszParamBBCodes); i++) {
- CMStringW wszOpenTag(wszParamBBCodes[i][0]);
- CMStringW wszCloseTag(wszParamBBCodes[i][1]);
+ for (auto &it : wszParamBBCodes) {
+ CMStringW wszOpenTag(it[0]);
+ CMStringW wszCloseTag(it[1]);
int lenOpen = wszOpenTag.GetLength();
int lenClose = wszCloseTag.GetLength();
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 4540783d48..a9016dde16 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -458,15 +458,15 @@ MCONTACT CVkProto::SetContactInfo(const JSONNode &jnItem, bool flag, VKContactTy
int iInteres = 0;
- for (int i = 0; i < _countof(vkInteres); i++) {
- wszValue = jnItem[vkInteres[i].szField].as_mstring();
+ for (auto &it : vkInteres) {
+ wszValue = jnItem[it.szField].as_mstring();
if (wszValue.IsEmpty())
continue;
CMStringA InteresCat(FORMAT, "Interest%dCat", iInteres);
CMStringA InteresText(FORMAT, "Interest%dText", iInteres);
- setWString(hContact, InteresCat, vkInteres[i].pwszTranslate);
+ setWString(hContact, InteresCat, it.pwszTranslate);
setWString(hContact, InteresText, wszValue);
iInteres++;
diff --git a/src/core/stdaway/src/sendmsg.cpp b/src/core/stdaway/src/sendmsg.cpp
index f7357e4f08..14ec7baffb 100644
--- a/src/core/stdaway/src/sendmsg.cpp
+++ b/src/core/stdaway/src/sendmsg.cpp
@@ -374,28 +374,28 @@ static INT_PTR CALLBACK DlgProcAwayMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam
dat = (AwayMsgDlgData*)mir_alloc(sizeof(AwayMsgDlgData));
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->oldPage = -1;
- for (int i = 0; i < _countof(statusModes); i++) {
- if (!(protoModeMsgFlags & Proto_Status2Flag(statusModes[i])))
+ for (auto &it : statusModes) {
+ if (!(protoModeMsgFlags & Proto_Status2Flag(it)))
continue;
int j;
if (hLst) {
- j = SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0));
- SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETITEMDATA, j, statusModes[i]);
+ j = SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(it, 0));
+ SendDlgItemMessage(hwndDlg, IDC_LST_STATUS, LB_SETITEMDATA, j, it);
}
else {
- j = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(statusModes[i], 0));
- SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, statusModes[i]);
+ j = SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)pcli->pfnGetStatusModeDescription(it, 0));
+ SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_SETITEMDATA, j, it);
}
- dat->info[j].ignore = GetStatusModeByte(statusModes[i], "Ignore");
- dat->info[j].noDialog = GetStatusModeByte(statusModes[i], "NoDlg", true);
- dat->info[j].usePrevious = GetStatusModeByte(statusModes[i], "UsePrev");
+ dat->info[j].ignore = GetStatusModeByte(it, "Ignore");
+ dat->info[j].noDialog = GetStatusModeByte(it, "NoDlg", true);
+ dat->info[j].usePrevious = GetStatusModeByte(it, "UsePrev");
DBVARIANT dbv;
- if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Default"), &dbv))
- if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(statusModes[i], "Msg"), &dbv))
- dbv.ptszVal = mir_wstrdup(GetDefaultMessage(statusModes[i]));
+ if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(it, "Default"), &dbv))
+ if (db_get_ws(NULL, "SRAway", StatusModeToDbSetting(it, "Msg"), &dbv))
+ dbv.ptszVal = mir_wstrdup(GetDefaultMessage(it));
mir_wstrcpy(dat->info[j].msg, dbv.ptszVal);
mir_free(dbv.ptszVal);
}
diff --git a/src/core/stdclist/src/clcopts.cpp b/src/core/stdclist/src/clcopts.cpp
index 7b889c2a21..932e546e52 100644
--- a/src/core/stdclist/src/clcopts.cpp
+++ b/src/core/stdclist/src/clcopts.cpp
@@ -149,12 +149,9 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), GWL_STYLE,
GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_HIDEOFFLINEOPTS), GWL_STYLE) | TVS_NOHSCROLL | TVS_CHECKBOXES);
{
- int i;
DWORD exStyle = db_get_dw(NULL, "CLC", "ExStyle", pcli->pfnGetDefaultExStyle());
- for (i = 0; i < _countof(checkBoxToStyleEx); i++)
- CheckDlgButton(hwndDlg, checkBoxToStyleEx[i].id,
- (exStyle & checkBoxToStyleEx[i].flag) ^ (checkBoxToStyleEx[i].flag *
- checkBoxToStyleEx[i].not) ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : checkBoxToStyleEx)
+ CheckDlgButton(hwndDlg, it.id, (exStyle & it.flag) ^ (it.flag * it.not) ? BST_CHECKED : BST_UNCHECKED);
}
{
UDACCEL accel[2] = { { 0, 10 }, { 2, 50 } };
@@ -242,11 +239,10 @@ static INT_PTR CALLBACK DlgProcClcMainOpts(HWND hwndDlg, UINT msg, WPARAM wParam
case 0:
if (((LPNMHDR)lParam)->code == PSN_APPLY) {
- int i;
DWORD exStyle = 0;
- for (i = 0; i < _countof(checkBoxToStyleEx); i++)
- if ((IsDlgButtonChecked(hwndDlg, checkBoxToStyleEx[i].id) == 0) == checkBoxToStyleEx[i].not)
- exStyle |= checkBoxToStyleEx[i].flag;
+ for (auto &it : checkBoxToStyleEx)
+ if ((IsDlgButtonChecked(hwndDlg, it.id) == 0) == it.not)
+ exStyle |= it.flag;
db_set_dw(NULL, "CLC", "ExStyle", exStyle);
{
diff --git a/src/core/stdclist/src/contact.cpp b/src/core/stdclist/src/contact.cpp
index b3b46976a5..d03630e45b 100644
--- a/src/core/stdclist/src/contact.cpp
+++ b/src/core/stdclist/src/contact.cpp
@@ -44,10 +44,10 @@ static statusModeOrder[] = {
int GetStatusModeOrdering(int statusMode)
{
- int i;
- for (i = 0; i < _countof(statusModeOrder); i++)
- if (statusModeOrder[i].status == statusMode)
- return statusModeOrder[i].order;
+ for (auto &it : statusModeOrder)
+ if (it.status == statusMode)
+ return it.order;
+
return 1000;
}
diff --git a/src/core/stdidle/src/options.cpp b/src/core/stdidle/src/options.cpp
index a3753db6d1..e9e670fe51 100644
--- a/src/core/stdidle/src/options.cpp
+++ b/src/core/stdidle/src/options.cpp
@@ -94,8 +94,8 @@ public:
spinIdle.SetRange(60, 1);
spinIdle.SetPosition(S.iIdleTime1st);
- for (int j = 0; j < _countof(aa_Status); j++)
- cmbAAStatus.AddString(pcli->pfnGetStatusModeDescription(aa_Status[j], 0));
+ for (auto &it : aa_Status)
+ cmbAAStatus.AddString(pcli->pfnGetStatusModeDescription(it, 0));
cmbAAStatus.SetCurSel(IdleGetStatusIndex(S.bAAStatus));
ShowHide();
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp
index 1ec5bbbd1c..58d6ecf2a7 100644
--- a/src/core/stdmsg/src/msglog.cpp
+++ b/src/core/stdmsg/src/msglog.cpp
@@ -500,6 +500,6 @@ void LoadMsgLogIcons(void)
void FreeMsgLogIcons(void)
{
- for (int i = 0; i < _countof(pLogIconBmpBits); i++)
- mir_free(pLogIconBmpBits[i]);
+ for (auto &it : pLogIconBmpBits)
+ mir_free(it);
}
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp
index 79cae04ddc..34bb77028c 100644
--- a/src/core/stdmsg/src/msgoptions.cpp
+++ b/src/core/stdmsg/src/msgoptions.cpp
@@ -166,11 +166,11 @@ class COptionMainDlg : public CPluginDlgBase
tvis.hParent = nullptr;
tvis.hInsertAfter = TVI_LAST;
tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE;
- for (int i = 0; i < _countof(statusValues); i++) {
- tvis.item.lParam = statusValues[i].style;
- tvis.item.pszText = TranslateW(statusValues[i].szDescr);
+ for (auto &it : statusValues) {
+ tvis.item.lParam = it.style;
+ tvis.item.pszText = TranslateW(it.szDescr);
tvis.item.stateMask = TVIS_STATEIMAGEMASK;
- tvis.item.iImage = (style & statusValues[i].style) != 0;
+ tvis.item.iImage = (style & it.style) != 0;
tree.InsertItem(&tvis);
}
}
diff --git a/src/mir_app/src/DefaultExtraIcons.cpp b/src/mir_app/src/DefaultExtraIcons.cpp
index f98f44fe11..26e9ae9d1f 100644
--- a/src/mir_app/src/DefaultExtraIcons.cpp
+++ b/src/mir_app/src/DefaultExtraIcons.cpp
@@ -144,9 +144,7 @@ static void SetExtraIcons(MCONTACT hContact)
if ( IsEmpty(proto))
return;
- for (unsigned int i = 0; i < _countof(infos); i++) {
- Info &p = infos[i];
-
+ for (auto &p : infos) {
for (unsigned int j = 0; j < _countof(p.db); j += 2) {
if (p.db[j + 1] == nullptr)
break;
@@ -181,9 +179,7 @@ static int SettingChanged(WPARAM hContact, LPARAM lParam)
return 0;
}
- for (int i = 0; i < _countof(infos); i++) {
- Info &p = infos[i];
-
+ for (auto &p : infos) {
for (int j = 0; j < _countof(p.db); j += 2) {
if (p.db[j + 1] == nullptr)
break;
@@ -308,8 +304,7 @@ void DefaultExtraIcons_Load()
hExtraProto = ExtraIcon_RegisterCallback("protocol", "Account", Skin_GetIconName(SKINICON_OTHER_ACCMGR),
&ProtocolRebuildIcons, &ProtocolApplyIcon, &ProtocolOnClick, 0, EIF_DISABLED_BY_DEFAULT);
- for (int i = 0; i < _countof(infos); i++) {
- Info &p = infos[i];
+ for (auto &p : infos) {
p.hIcolib = Skin_GetIconHandle(p.iSkinIcon);
if (p.OnClick)
p.hExtraIcon = ExtraIcon_RegisterIcolib(p.name, p.desc, Skin_GetIconName(p.iSkinIcon), DefaultOnClick, (LPARAM)&p, p.flags);
diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp
index 35e35a0f29..a3240c2ef3 100644
--- a/src/mir_app/src/chat_tools.cpp
+++ b/src/mir_app/src/chat_tools.cpp
@@ -681,8 +681,8 @@ wchar_t* GetChatLogsFilename(SESSION_INFO *si, time_t tTime)
PathToAbsoluteW(tszParsedName, si->pszLogFileName);
mir_free(tszParsedName);
- for (int i = 0; i < _countof(rva); i++)
- mir_free(rva[i].value.w);
+ for (auto &it : rva)
+ mir_free(it.value.w);
for (wchar_t *p = si->pszLogFileName + 2; *p; ++p)
if (*p == ':' || *p == '*' || *p == '?' || *p == '"' || *p == '<' || *p == '>' || *p == '|')
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index 30ffa63b80..2f4c7876a4 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -435,8 +435,8 @@ int LoadContactListModule2(void)
ImageList_AddIcon_NotShared(hCListImages, MAKEINTRESOURCE(IDI_BLANK));
// now all core skin icons are loaded via icon lib. so lets release them
- for (int i = 0; i < _countof(statusModeList); i++)
- ImageList_AddIcon_IconLibLoaded(hCListImages, skinIconStatusList[i]);
+ for (auto &it : statusModeList)
+ ImageList_AddIcon_IconLibLoaded(hCListImages, it);
// see IMAGE_GROUP... in clist.h if you add more images above here
ImageList_AddIcon_IconLibLoaded(hCListImages, SKINICON_OTHER_GROUPOPEN);
diff --git a/src/mir_app/src/findadd.cpp b/src/mir_app/src/findadd.cpp
index 58132b95b9..bc1e252a0c 100644
--- a/src/mir_app/src/findadd.cpp
+++ b/src/mir_app/src/findadd.cpp
@@ -284,8 +284,8 @@ static const int controls[] = { IDC_BYPROTOID, IDC_BYEMAIL, IDC_BYNAME, IDC_BYAD
static void CheckSearchTypeRadioButton(HWND hwndDlg, int idControl)
{
- for (int i = 0; i < _countof(controls); i++)
- CheckDlgButton(hwndDlg, controls[i], idControl == controls[i] ? BST_CHECKED : BST_UNCHECKED);
+ for (auto &it : controls)
+ CheckDlgButton(hwndDlg, it, idControl == it ? BST_CHECKED : BST_UNCHECKED);
}
#define sttErrMsg TranslateT("You haven't filled in the search field. Please enter a search term and try again.")
diff --git a/src/mir_app/src/ignore.cpp b/src/mir_app/src/ignore.cpp
index f5dfb0f254..f0c9032a0a 100644
--- a/src/mir_app/src/ignore.cpp
+++ b/src/mir_app/src/ignore.cpp
@@ -314,8 +314,9 @@ static INT_PTR CALLBACK DlgProcIgnoreOpts(HWND hwndDlg, UINT msg, WPARAM, LPARAM
break;
case WM_DESTROY:
- for (int i = 0; i < _countof(hIcons); i++)
- DestroyIcon(hIcons[i]);
+ for (auto &it : hIcons)
+ DestroyIcon(it);
+
HIMAGELIST hIml = (HIMAGELIST)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGELIST, 0, 0);
ImageList_Destroy(hIml);
break;
diff --git a/src/mir_app/src/netliblog.cpp b/src/mir_app/src/netliblog.cpp
index 226da520bf..6bb9fc32a3 100644
--- a/src/mir_app/src/netliblog.cpp
+++ b/src/mir_app/src/netliblog.cpp
@@ -103,10 +103,10 @@ static INT_PTR CALLBACK LogOptionsDlgProc(HWND hwndDlg, UINT message, WPARAM wPa
CheckDlgButton(hwndDlg, IDC_DUMPSSL, logOptions.dumpSsl ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_TEXTDUMPS, logOptions.textDumps ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_AUTODETECTTEXT, logOptions.autoDetectText ? BST_CHECKED : BST_UNCHECKED);
- {
- for (int i=0; i < _countof(szTimeFormats); i++)
- SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateW(szTimeFormats[i]));
- }
+
+ for (auto &it : szTimeFormats)
+ SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_ADDSTRING, 0, (LPARAM)TranslateW(it));
+
SendDlgItemMessage(hwndDlg, IDC_TIMEFORMAT, CB_SETCURSEL, logOptions.timeFormat, 0);
CheckDlgButton(hwndDlg, IDC_SHOWNAMES, logOptions.showUser ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_TOOUTPUTDEBUGSTRING, logOptions.toOutputDebugString ? BST_CHECKED : BST_UNCHECKED);
diff --git a/src/mir_app/src/newplugins.cpp b/src/mir_app/src/newplugins.cpp
index 2ab86f710d..f16ba12347 100644
--- a/src/mir_app/src/newplugins.cpp
+++ b/src/mir_app/src/newplugins.cpp
@@ -121,8 +121,8 @@ static const MUUID pluginBannedList[] =
static bool isPluginBanned(const MUUID& u1)
{
- for (int i = 0; i < _countof(pluginBannedList); i++)
- if (pluginBannedList[i] == u1)
+ for (auto &it : pluginBannedList)
+ if (it == u1)
return true;
return false;
@@ -156,11 +156,11 @@ int getDefaultPluginIdx(const MUUID &muuid)
int LoadStdPlugins()
{
- for (int i = 0; i < _countof(pluginDefault); i++) {
- if (pluginDefault[i].pImpl)
+ for (auto &it : pluginDefault) {
+ if (it.pImpl)
continue;
- if (!LoadCorePlugin(pluginDefault[i]))
+ if (!LoadCorePlugin(it))
return 1;
}
@@ -380,9 +380,9 @@ int Plugin_UnloadDyn(pluginEntry *p)
// mark default plugins to be loaded
if (!(p->pclass & PCLASS_CORE))
- for (int i = 0; i < _countof(pluginDefault); i++)
- if (pluginDefault[i].pImpl == p)
- pluginDefault[i].pImpl = nullptr;
+ for (auto &it : pluginDefault)
+ if (it.pImpl == p)
+ it.pImpl = nullptr;
return TRUE;
}
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index ef8c5d4e86..269027909d 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -413,8 +413,8 @@ void UnloadAccountsModule()
}
accounts.destroy();
- for (int i = 0; i < _countof(hHooks); i++)
- UnhookEvent(hHooks[i]);
+ for (auto &it : hHooks)
+ UnhookEvent(it);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/skinicons.cpp b/src/mir_app/src/skinicons.cpp
index c27b8386a0..c54dea3dcd 100644
--- a/src/mir_app/src/skinicons.cpp
+++ b/src/mir_app/src/skinicons.cpp
@@ -341,9 +341,9 @@ MIR_APP_DLL(HICON) Skin_LoadProtoIcon(const char *szProto, int status, bool big)
MIR_APP_DLL(HANDLE) Skin_GetIconHandle(int idx)
{
- for (int i = 0; i < _countof(mainIcons); i++)
- if (idx == mainIcons[i].id)
- return mainIcons[i].hIcolib;
+ for (auto &it : mainIcons)
+ if (idx == it.id)
+ return it.hIcolib;
return nullptr;
}
diff --git a/src/mir_app/src/utils.cpp b/src/mir_app/src/utils.cpp
index 167a397a58..170c7db7c2 100644
--- a/src/mir_app/src/utils.cpp
+++ b/src/mir_app/src/utils.cpp
@@ -292,18 +292,18 @@ static CountryListEntry countries[] = {
static INT_PTR GetCountryByNumber(WPARAM wParam, LPARAM)
{
- for (int i = 0; i < _countof(countries); i++)
- if ((int)wParam == countries[i].id)
- return (INT_PTR)countries[i].szName;
+ for (auto &it : countries)
+ if ((int)wParam == it.id)
+ return (INT_PTR)it.szName;
return 0;
}
static INT_PTR GetCountryByISOCode(WPARAM wParam, LPARAM)
{
- for (int i = 0; i < _countof(countries); i++)
- if ( mir_strcmpi((char*)wParam, countries[i].ISOcode) == 0)
- return (INT_PTR)countries[i].szName;
+ for (auto &it : countries)
+ if ( mir_strcmpi((char*)wParam, it.ISOcode) == 0)
+ return (INT_PTR)it.szName;
return 0;
}
diff --git a/src/mir_app/src/visibility.cpp b/src/mir_app/src/visibility.cpp
index 8abdfabaf5..5946ca3159 100644
--- a/src/mir_app/src/visibility.cpp
+++ b/src/mir_app/src/visibility.cpp
@@ -50,7 +50,7 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt
else
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
while (hItem) {
- for (int i=0; i < _countof(iconOn); i++) {
+ for (int i = 0; i < _countof(iconOn); i++) {
int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, i);
if (iconOn[i] && iImage == 0) iconOn[i] = 0;
if (iImage != EMPTY_EXTRA_ICON)
@@ -59,9 +59,9 @@ static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentIt
hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- for (int i=0; i < _countof(iconOn); i++) {
- SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i]?(iconOn[i]?i+1:0):EMPTY_EXTRA_ICON));
- if (groupChildCount) groupChildCount[i]+=childCount[i];
+ for (int i = 0; i < _countof(iconOn); i++) {
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(i, childCount[i] ? (iconOn[i] ? i + 1 : 0) : EMPTY_EXTRA_ICON));
+ if (groupChildCount) groupChildCount[i] += childCount[i];
}
}